trophy_api_client 1.0.42 → 1.1.0.pre.beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/gemconfig.rb +1 -1
- data/lib/trophy_api_client/admin/client.rb +7 -0
- data/lib/trophy_api_client/admin/points/boosts/client.rb +247 -0
- data/lib/trophy_api_client/admin/points/boosts/types/create_points_boosts_request_boosts_item.rb +111 -0
- data/lib/trophy_api_client/admin/points/boosts/types/create_points_boosts_request_boosts_item_rounding.rb +16 -0
- data/lib/trophy_api_client/admin/points/client.rb +32 -0
- data/lib/trophy_api_client/leaderboards/client.rb +20 -12
- data/lib/trophy_api_client/points/client.rb +85 -2
- data/lib/trophy_api_client/types/archive_points_boosts_response.rb +56 -0
- data/lib/trophy_api_client/types/create_points_boosts_response.rb +75 -0
- data/lib/trophy_api_client/types/created_points_boost.rb +122 -0
- data/lib/trophy_api_client/types/created_points_boost_rounding.rb +10 -0
- data/lib/trophy_api_client/types/created_points_boost_status.rb +10 -0
- data/lib/trophy_api_client/types/metric_event_points_response.rb +10 -9
- data/lib/trophy_api_client/types/points_award.rb +15 -2
- data/lib/trophy_api_client/types/points_boost.rb +112 -0
- data/lib/trophy_api_client/types/points_boost_rounding.rb +10 -0
- data/lib/trophy_api_client/types/points_boost_status.rb +10 -0
- data/lib/trophy_api_client/types/points_boost_webhook_payload.rb +149 -0
- data/lib/trophy_api_client/types/points_boost_webhook_payload_rounding.rb +10 -0
- data/lib/trophy_api_client/types/points_boost_webhook_payload_status.rb +9 -0
- data/lib/trophy_api_client/types/webhooks_points_boost_finished_payload.rb +79 -0
- data/lib/trophy_api_client/types/webhooks_points_boost_started_payload.rb +79 -0
- data/lib/trophy_api_client/types/webhooks_points_changed_payload.rb +5 -5
- data/lib/trophy_api_client/users/client.rb +81 -0
- data/lib/trophy_api_client/version.rb +1 -1
- data/lib/types_export.rb +15 -0
- metadata +18 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 84037a3c1bb14f574aa104a7221aff8070d2f6366587204798cd5bf663181a5a
|
|
4
|
+
data.tar.gz: 6e53759b78f13e9688ea98a40111e3f73e39a30b05fb312aee23b22ccee8d5ee
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1df8fb6bc8ac268da8de24d71e92bdc5ce964c78eaaa096568b97136afbf0c96dfb13370263312fd294a4aa9e853818d6b8a8b5d4a8d1821d3c3fe49855d1b10
|
|
7
|
+
data.tar.gz: 03b69808c5c0a369cbad11e3bdfe4e70282ea37c565d02a4d9a86be72be47d7482f10e3b1483c6604ca8369f1a5dff7e16ae1881b34422c862a86c8d14d5a3e2
|
data/lib/gemconfig.rb
CHANGED
|
@@ -2,28 +2,35 @@
|
|
|
2
2
|
|
|
3
3
|
require_relative "../../requests"
|
|
4
4
|
require_relative "streaks/client"
|
|
5
|
+
require_relative "points/client"
|
|
5
6
|
|
|
6
7
|
module TrophyApiClient
|
|
7
8
|
module Admin
|
|
8
9
|
class Client
|
|
9
10
|
# @return [TrophyApiClient::Admin::StreaksClient]
|
|
10
11
|
attr_reader :streaks
|
|
12
|
+
# @return [TrophyApiClient::Admin::Points::Client]
|
|
13
|
+
attr_reader :admin
|
|
11
14
|
|
|
12
15
|
# @param request_client [TrophyApiClient::RequestClient]
|
|
13
16
|
# @return [TrophyApiClient::Admin::Client]
|
|
14
17
|
def initialize(request_client:)
|
|
15
18
|
@streaks = TrophyApiClient::Admin::StreaksClient.new(request_client: request_client)
|
|
19
|
+
@admin = TrophyApiClient::Admin::Points::Client.new(request_client: request_client)
|
|
16
20
|
end
|
|
17
21
|
end
|
|
18
22
|
|
|
19
23
|
class AsyncClient
|
|
20
24
|
# @return [TrophyApiClient::Admin::AsyncStreaksClient]
|
|
21
25
|
attr_reader :streaks
|
|
26
|
+
# @return [TrophyApiClient::Admin::Points::AsyncClient]
|
|
27
|
+
attr_reader :admin
|
|
22
28
|
|
|
23
29
|
# @param request_client [TrophyApiClient::AsyncRequestClient]
|
|
24
30
|
# @return [TrophyApiClient::Admin::AsyncClient]
|
|
25
31
|
def initialize(request_client:)
|
|
26
32
|
@streaks = TrophyApiClient::Admin::AsyncStreaksClient.new(request_client: request_client)
|
|
33
|
+
@admin = TrophyApiClient::Admin::Points::AsyncClient.new(request_client: request_client)
|
|
27
34
|
end
|
|
28
35
|
end
|
|
29
36
|
end
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../../../../requests"
|
|
4
|
+
require_relative "types/create_points_boosts_request_boosts_item"
|
|
5
|
+
require_relative "../../../types/create_points_boosts_response"
|
|
6
|
+
require_relative "../../../types/archive_points_boosts_response"
|
|
7
|
+
require "async"
|
|
8
|
+
|
|
9
|
+
module TrophyApiClient
|
|
10
|
+
module Admin
|
|
11
|
+
module Points
|
|
12
|
+
class BoostsClient
|
|
13
|
+
# @return [TrophyApiClient::RequestClient]
|
|
14
|
+
attr_reader :request_client
|
|
15
|
+
|
|
16
|
+
# @param request_client [TrophyApiClient::RequestClient]
|
|
17
|
+
# @return [TrophyApiClient::Admin::Points::BoostsClient]
|
|
18
|
+
def initialize(request_client:)
|
|
19
|
+
@request_client = request_client
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Create points boosts for multiple users.
|
|
23
|
+
#
|
|
24
|
+
# @param system_key [String] The key of the points system to create boosts for.
|
|
25
|
+
# @param boosts [Array<Hash>] Array of boosts to create. Maximum 1,000 boosts per request.Request of type Array<TrophyApiClient::Admin::Points::Boosts::CreatePointsBoostsRequestBoostsItem>, as a Hash
|
|
26
|
+
# * :user_id (String)
|
|
27
|
+
# * :name (String)
|
|
28
|
+
# * :start (String)
|
|
29
|
+
# * :end_ (String)
|
|
30
|
+
# * :multiplier (Float)
|
|
31
|
+
# * :rounding (TrophyApiClient::Admin::Points::Boosts::CreatePointsBoostsRequestBoostsItemRounding)
|
|
32
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
33
|
+
# @return [TrophyApiClient::CreatePointsBoostsResponse]
|
|
34
|
+
# @example
|
|
35
|
+
# api = TrophyApiClient::Client.new(
|
|
36
|
+
# base_url: "https://api.example.com",
|
|
37
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
38
|
+
# api_key: "YOUR_API_KEY"
|
|
39
|
+
# )
|
|
40
|
+
# api.admin.points.boosts.create(system_key: "xp", boosts: [{ user_id: "user-123", name: "Double XP Weekend", start: "2024-01-01", end_: "2024-01-03", multiplier: 2 }, { user_id: "user-456", name: "Holiday Bonus", start: "2024-12-25", multiplier: 1.5, rounding: UP }])
|
|
41
|
+
def create(system_key:, boosts:, request_options: nil)
|
|
42
|
+
response = @request_client.conn.post do |req|
|
|
43
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
44
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
45
|
+
req.headers = {
|
|
46
|
+
**(req.headers || {}),
|
|
47
|
+
**@request_client.get_headers,
|
|
48
|
+
**(request_options&.additional_headers || {})
|
|
49
|
+
}.compact
|
|
50
|
+
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
|
51
|
+
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
|
52
|
+
end
|
|
53
|
+
req.body = {
|
|
54
|
+
**(request_options&.additional_body_parameters || {}),
|
|
55
|
+
systemKey: system_key,
|
|
56
|
+
boosts: boosts
|
|
57
|
+
}.compact
|
|
58
|
+
req.url "#{@request_client.get_url(environment: admin, request_options: request_options)}/points/boosts"
|
|
59
|
+
end
|
|
60
|
+
TrophyApiClient::CreatePointsBoostsResponse.from_json(json_object: response.body)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Archive multiple points boosts by ID.
|
|
64
|
+
#
|
|
65
|
+
# @param ids [String] A list of up to 100 boost IDs.
|
|
66
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
67
|
+
# @return [TrophyApiClient::ArchivePointsBoostsResponse]
|
|
68
|
+
# @example
|
|
69
|
+
# api = TrophyApiClient::Client.new(
|
|
70
|
+
# base_url: "https://api.example.com",
|
|
71
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
72
|
+
# api_key: "YOUR_API_KEY"
|
|
73
|
+
# )
|
|
74
|
+
# api.admin.points.boosts.batch_archive
|
|
75
|
+
def batch_archive(ids: nil, request_options: nil)
|
|
76
|
+
response = @request_client.conn.delete do |req|
|
|
77
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
78
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
79
|
+
req.headers = {
|
|
80
|
+
**(req.headers || {}),
|
|
81
|
+
**@request_client.get_headers,
|
|
82
|
+
**(request_options&.additional_headers || {})
|
|
83
|
+
}.compact
|
|
84
|
+
req.params = { **(request_options&.additional_query_parameters || {}), "ids": ids }.compact
|
|
85
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
|
86
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
|
87
|
+
end
|
|
88
|
+
req.url "#{@request_client.get_url(environment: admin, request_options: request_options)}/points/boosts"
|
|
89
|
+
end
|
|
90
|
+
TrophyApiClient::ArchivePointsBoostsResponse.from_json(json_object: response.body)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Archive a points boost by ID.
|
|
94
|
+
#
|
|
95
|
+
# @param id [String] The UUID of the points boost to archive
|
|
96
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
97
|
+
# @return [Void]
|
|
98
|
+
# @example
|
|
99
|
+
# api = TrophyApiClient::Client.new(
|
|
100
|
+
# base_url: "https://api.example.com",
|
|
101
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
102
|
+
# api_key: "YOUR_API_KEY"
|
|
103
|
+
# )
|
|
104
|
+
# api.admin.points.boosts.archive(id: "id")
|
|
105
|
+
def archive(id:, request_options: nil)
|
|
106
|
+
@request_client.conn.delete do |req|
|
|
107
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
108
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
109
|
+
req.headers = {
|
|
110
|
+
**(req.headers || {}),
|
|
111
|
+
**@request_client.get_headers,
|
|
112
|
+
**(request_options&.additional_headers || {})
|
|
113
|
+
}.compact
|
|
114
|
+
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
|
115
|
+
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
|
116
|
+
end
|
|
117
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
|
118
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
|
119
|
+
end
|
|
120
|
+
req.url "#{@request_client.get_url(environment: admin,
|
|
121
|
+
request_options: request_options)}/points/boosts/#{id}"
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
class AsyncBoostsClient
|
|
127
|
+
# @return [TrophyApiClient::AsyncRequestClient]
|
|
128
|
+
attr_reader :request_client
|
|
129
|
+
|
|
130
|
+
# @param request_client [TrophyApiClient::AsyncRequestClient]
|
|
131
|
+
# @return [TrophyApiClient::Admin::Points::AsyncBoostsClient]
|
|
132
|
+
def initialize(request_client:)
|
|
133
|
+
@request_client = request_client
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
# Create points boosts for multiple users.
|
|
137
|
+
#
|
|
138
|
+
# @param system_key [String] The key of the points system to create boosts for.
|
|
139
|
+
# @param boosts [Array<Hash>] Array of boosts to create. Maximum 1,000 boosts per request.Request of type Array<TrophyApiClient::Admin::Points::Boosts::CreatePointsBoostsRequestBoostsItem>, as a Hash
|
|
140
|
+
# * :user_id (String)
|
|
141
|
+
# * :name (String)
|
|
142
|
+
# * :start (String)
|
|
143
|
+
# * :end_ (String)
|
|
144
|
+
# * :multiplier (Float)
|
|
145
|
+
# * :rounding (TrophyApiClient::Admin::Points::Boosts::CreatePointsBoostsRequestBoostsItemRounding)
|
|
146
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
147
|
+
# @return [TrophyApiClient::CreatePointsBoostsResponse]
|
|
148
|
+
# @example
|
|
149
|
+
# api = TrophyApiClient::Client.new(
|
|
150
|
+
# base_url: "https://api.example.com",
|
|
151
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
152
|
+
# api_key: "YOUR_API_KEY"
|
|
153
|
+
# )
|
|
154
|
+
# api.admin.points.boosts.create(system_key: "xp", boosts: [{ user_id: "user-123", name: "Double XP Weekend", start: "2024-01-01", end_: "2024-01-03", multiplier: 2 }, { user_id: "user-456", name: "Holiday Bonus", start: "2024-12-25", multiplier: 1.5, rounding: UP }])
|
|
155
|
+
def create(system_key:, boosts:, request_options: nil)
|
|
156
|
+
Async do
|
|
157
|
+
response = @request_client.conn.post do |req|
|
|
158
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
159
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
160
|
+
req.headers = {
|
|
161
|
+
**(req.headers || {}),
|
|
162
|
+
**@request_client.get_headers,
|
|
163
|
+
**(request_options&.additional_headers || {})
|
|
164
|
+
}.compact
|
|
165
|
+
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
|
166
|
+
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
|
167
|
+
end
|
|
168
|
+
req.body = {
|
|
169
|
+
**(request_options&.additional_body_parameters || {}),
|
|
170
|
+
systemKey: system_key,
|
|
171
|
+
boosts: boosts
|
|
172
|
+
}.compact
|
|
173
|
+
req.url "#{@request_client.get_url(environment: admin, request_options: request_options)}/points/boosts"
|
|
174
|
+
end
|
|
175
|
+
TrophyApiClient::CreatePointsBoostsResponse.from_json(json_object: response.body)
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
# Archive multiple points boosts by ID.
|
|
180
|
+
#
|
|
181
|
+
# @param ids [String] A list of up to 100 boost IDs.
|
|
182
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
183
|
+
# @return [TrophyApiClient::ArchivePointsBoostsResponse]
|
|
184
|
+
# @example
|
|
185
|
+
# api = TrophyApiClient::Client.new(
|
|
186
|
+
# base_url: "https://api.example.com",
|
|
187
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
188
|
+
# api_key: "YOUR_API_KEY"
|
|
189
|
+
# )
|
|
190
|
+
# api.admin.points.boosts.batch_archive
|
|
191
|
+
def batch_archive(ids: nil, request_options: nil)
|
|
192
|
+
Async do
|
|
193
|
+
response = @request_client.conn.delete do |req|
|
|
194
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
195
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
196
|
+
req.headers = {
|
|
197
|
+
**(req.headers || {}),
|
|
198
|
+
**@request_client.get_headers,
|
|
199
|
+
**(request_options&.additional_headers || {})
|
|
200
|
+
}.compact
|
|
201
|
+
req.params = { **(request_options&.additional_query_parameters || {}), "ids": ids }.compact
|
|
202
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
|
203
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
|
204
|
+
end
|
|
205
|
+
req.url "#{@request_client.get_url(environment: admin, request_options: request_options)}/points/boosts"
|
|
206
|
+
end
|
|
207
|
+
TrophyApiClient::ArchivePointsBoostsResponse.from_json(json_object: response.body)
|
|
208
|
+
end
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
# Archive a points boost by ID.
|
|
212
|
+
#
|
|
213
|
+
# @param id [String] The UUID of the points boost to archive
|
|
214
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
215
|
+
# @return [Void]
|
|
216
|
+
# @example
|
|
217
|
+
# api = TrophyApiClient::Client.new(
|
|
218
|
+
# base_url: "https://api.example.com",
|
|
219
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
220
|
+
# api_key: "YOUR_API_KEY"
|
|
221
|
+
# )
|
|
222
|
+
# api.admin.points.boosts.archive(id: "id")
|
|
223
|
+
def archive(id:, request_options: nil)
|
|
224
|
+
Async do
|
|
225
|
+
@request_client.conn.delete do |req|
|
|
226
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
227
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
228
|
+
req.headers = {
|
|
229
|
+
**(req.headers || {}),
|
|
230
|
+
**@request_client.get_headers,
|
|
231
|
+
**(request_options&.additional_headers || {})
|
|
232
|
+
}.compact
|
|
233
|
+
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
|
234
|
+
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
|
235
|
+
end
|
|
236
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
|
237
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
|
238
|
+
end
|
|
239
|
+
req.url "#{@request_client.get_url(environment: admin,
|
|
240
|
+
request_options: request_options)}/points/boosts/#{id}"
|
|
241
|
+
end
|
|
242
|
+
end
|
|
243
|
+
end
|
|
244
|
+
end
|
|
245
|
+
end
|
|
246
|
+
end
|
|
247
|
+
end
|
data/lib/trophy_api_client/admin/points/boosts/types/create_points_boosts_request_boosts_item.rb
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "create_points_boosts_request_boosts_item_rounding"
|
|
4
|
+
require "ostruct"
|
|
5
|
+
require "json"
|
|
6
|
+
|
|
7
|
+
module TrophyApiClient
|
|
8
|
+
module Admin
|
|
9
|
+
module Points
|
|
10
|
+
class Boosts
|
|
11
|
+
class CreatePointsBoostsRequestBoostsItem
|
|
12
|
+
# @return [String] The ID of the user to create a boost for.
|
|
13
|
+
attr_reader :user_id
|
|
14
|
+
# @return [String] The name of the boost.
|
|
15
|
+
attr_reader :name
|
|
16
|
+
# @return [String] The start date of the boost (YYYY-MM-DD).
|
|
17
|
+
attr_reader :start
|
|
18
|
+
# @return [String] The end date of the boost (YYYY-MM-DD). If null, the boost has no end date.
|
|
19
|
+
attr_reader :end_
|
|
20
|
+
# @return [Float] The points multiplier. Must be greater than 0, not equal to 1, and less than
|
|
21
|
+
# 100.
|
|
22
|
+
attr_reader :multiplier
|
|
23
|
+
# @return [TrophyApiClient::Admin::Points::Boosts::CreatePointsBoostsRequestBoostsItemRounding] How to round the boosted points. Defaults to 'down'.
|
|
24
|
+
attr_reader :rounding
|
|
25
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
26
|
+
attr_reader :additional_properties
|
|
27
|
+
# @return [Object]
|
|
28
|
+
attr_reader :_field_set
|
|
29
|
+
protected :_field_set
|
|
30
|
+
|
|
31
|
+
OMIT = Object.new
|
|
32
|
+
|
|
33
|
+
# @param user_id [String] The ID of the user to create a boost for.
|
|
34
|
+
# @param name [String] The name of the boost.
|
|
35
|
+
# @param start [String] The start date of the boost (YYYY-MM-DD).
|
|
36
|
+
# @param end_ [String] The end date of the boost (YYYY-MM-DD). If null, the boost has no end date.
|
|
37
|
+
# @param multiplier [Float] The points multiplier. Must be greater than 0, not equal to 1, and less than
|
|
38
|
+
# 100.
|
|
39
|
+
# @param rounding [TrophyApiClient::Admin::Points::Boosts::CreatePointsBoostsRequestBoostsItemRounding] How to round the boosted points. Defaults to 'down'.
|
|
40
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
41
|
+
# @return [TrophyApiClient::Admin::Points::Boosts::CreatePointsBoostsRequestBoostsItem]
|
|
42
|
+
def initialize(user_id:, name:, start:, multiplier:, end_: OMIT, rounding: OMIT, additional_properties: nil)
|
|
43
|
+
@user_id = user_id
|
|
44
|
+
@name = name
|
|
45
|
+
@start = start
|
|
46
|
+
@end_ = end_ if end_ != OMIT
|
|
47
|
+
@multiplier = multiplier
|
|
48
|
+
@rounding = rounding if rounding != OMIT
|
|
49
|
+
@additional_properties = additional_properties
|
|
50
|
+
@_field_set = {
|
|
51
|
+
"userId": user_id,
|
|
52
|
+
"name": name,
|
|
53
|
+
"start": start,
|
|
54
|
+
"end": end_,
|
|
55
|
+
"multiplier": multiplier,
|
|
56
|
+
"rounding": rounding
|
|
57
|
+
}.reject do |_k, v|
|
|
58
|
+
v == OMIT
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Deserialize a JSON object to an instance of CreatePointsBoostsRequestBoostsItem
|
|
63
|
+
#
|
|
64
|
+
# @param json_object [String]
|
|
65
|
+
# @return [TrophyApiClient::Admin::Points::Boosts::CreatePointsBoostsRequestBoostsItem]
|
|
66
|
+
def self.from_json(json_object:)
|
|
67
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
68
|
+
parsed_json = JSON.parse(json_object)
|
|
69
|
+
user_id = parsed_json["userId"]
|
|
70
|
+
name = parsed_json["name"]
|
|
71
|
+
start = parsed_json["start"]
|
|
72
|
+
end_ = parsed_json["end"]
|
|
73
|
+
multiplier = parsed_json["multiplier"]
|
|
74
|
+
rounding = parsed_json["rounding"]
|
|
75
|
+
new(
|
|
76
|
+
user_id: user_id,
|
|
77
|
+
name: name,
|
|
78
|
+
start: start,
|
|
79
|
+
end_: end_,
|
|
80
|
+
multiplier: multiplier,
|
|
81
|
+
rounding: rounding,
|
|
82
|
+
additional_properties: struct
|
|
83
|
+
)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Serialize an instance of CreatePointsBoostsRequestBoostsItem to a JSON object
|
|
87
|
+
#
|
|
88
|
+
# @return [String]
|
|
89
|
+
def to_json(*_args)
|
|
90
|
+
@_field_set&.to_json
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
|
94
|
+
# hash and check each fields type against the current object's property
|
|
95
|
+
# definitions.
|
|
96
|
+
#
|
|
97
|
+
# @param obj [Object]
|
|
98
|
+
# @return [Void]
|
|
99
|
+
def self.validate_raw(obj:)
|
|
100
|
+
obj.user_id.is_a?(String) != false || raise("Passed value for field obj.user_id is not the expected type, validation failed.")
|
|
101
|
+
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
|
102
|
+
obj.start.is_a?(String) != false || raise("Passed value for field obj.start is not the expected type, validation failed.")
|
|
103
|
+
obj.end_&.is_a?(String) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.")
|
|
104
|
+
obj.multiplier.is_a?(Float) != false || raise("Passed value for field obj.multiplier is not the expected type, validation failed.")
|
|
105
|
+
obj.rounding&.is_a?(TrophyApiClient::Admin::Points::Boosts::CreatePointsBoostsRequestBoostsItemRounding) != false || raise("Passed value for field obj.rounding is not the expected type, validation failed.")
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module TrophyApiClient
|
|
4
|
+
module Admin
|
|
5
|
+
module Points
|
|
6
|
+
class Boosts
|
|
7
|
+
# How to round the boosted points. Defaults to 'down'.
|
|
8
|
+
class CreatePointsBoostsRequestBoostsItemRounding
|
|
9
|
+
DOWN = "down"
|
|
10
|
+
UP = "up"
|
|
11
|
+
NEAREST = "nearest"
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../../../requests"
|
|
4
|
+
require_relative "boosts/client"
|
|
5
|
+
|
|
6
|
+
module TrophyApiClient
|
|
7
|
+
module Admin
|
|
8
|
+
module Points
|
|
9
|
+
class Client
|
|
10
|
+
# @return [TrophyApiClient::Admin::Points::BoostsClient]
|
|
11
|
+
attr_reader :boosts
|
|
12
|
+
|
|
13
|
+
# @param request_client [TrophyApiClient::RequestClient]
|
|
14
|
+
# @return [TrophyApiClient::Admin::Points::Client]
|
|
15
|
+
def initialize(request_client:)
|
|
16
|
+
@boosts = TrophyApiClient::Admin::Points::BoostsClient.new(request_client: request_client)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
class AsyncClient
|
|
21
|
+
# @return [TrophyApiClient::Admin::Points::AsyncBoostsClient]
|
|
22
|
+
attr_reader :boosts
|
|
23
|
+
|
|
24
|
+
# @param request_client [TrophyApiClient::AsyncRequestClient]
|
|
25
|
+
# @return [TrophyApiClient::Admin::Points::AsyncClient]
|
|
26
|
+
def initialize(request_client:)
|
|
27
|
+
@boosts = TrophyApiClient::Admin::Points::AsyncBoostsClient.new(request_client: request_client)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -17,8 +17,11 @@ module TrophyApiClient
|
|
|
17
17
|
@request_client = request_client
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
# Get all
|
|
20
|
+
# Get all leaderboards for your organization. Finished leaderboards are excluded
|
|
21
|
+
# by default.
|
|
21
22
|
#
|
|
23
|
+
# @param include_finished [Boolean] When set to 'true', leaderboards with status 'finished' will be included in the
|
|
24
|
+
# response. By default, finished leaderboards are excluded.
|
|
22
25
|
# @param request_options [TrophyApiClient::RequestOptions]
|
|
23
26
|
# @return [Array<TrophyApiClient::Leaderboards::LeaderboardsAllResponseItem>]
|
|
24
27
|
# @example
|
|
@@ -27,8 +30,8 @@ module TrophyApiClient
|
|
|
27
30
|
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
28
31
|
# api_key: "YOUR_API_KEY"
|
|
29
32
|
# )
|
|
30
|
-
# api.leaderboards.all
|
|
31
|
-
def all(request_options: nil)
|
|
33
|
+
# api.leaderboards.all(include_finished: true)
|
|
34
|
+
def all(include_finished: nil, request_options: nil)
|
|
32
35
|
response = @request_client.conn.get do |req|
|
|
33
36
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
34
37
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
@@ -37,9 +40,10 @@ module TrophyApiClient
|
|
|
37
40
|
**@request_client.get_headers,
|
|
38
41
|
**(request_options&.additional_headers || {})
|
|
39
42
|
}.compact
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
req.params = {
|
|
44
|
+
**(request_options&.additional_query_parameters || {}),
|
|
45
|
+
"includeFinished": include_finished
|
|
46
|
+
}.compact
|
|
43
47
|
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
|
44
48
|
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
|
45
49
|
end
|
|
@@ -117,8 +121,11 @@ module TrophyApiClient
|
|
|
117
121
|
@request_client = request_client
|
|
118
122
|
end
|
|
119
123
|
|
|
120
|
-
# Get all
|
|
124
|
+
# Get all leaderboards for your organization. Finished leaderboards are excluded
|
|
125
|
+
# by default.
|
|
121
126
|
#
|
|
127
|
+
# @param include_finished [Boolean] When set to 'true', leaderboards with status 'finished' will be included in the
|
|
128
|
+
# response. By default, finished leaderboards are excluded.
|
|
122
129
|
# @param request_options [TrophyApiClient::RequestOptions]
|
|
123
130
|
# @return [Array<TrophyApiClient::Leaderboards::LeaderboardsAllResponseItem>]
|
|
124
131
|
# @example
|
|
@@ -127,8 +134,8 @@ module TrophyApiClient
|
|
|
127
134
|
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
128
135
|
# api_key: "YOUR_API_KEY"
|
|
129
136
|
# )
|
|
130
|
-
# api.leaderboards.all
|
|
131
|
-
def all(request_options: nil)
|
|
137
|
+
# api.leaderboards.all(include_finished: true)
|
|
138
|
+
def all(include_finished: nil, request_options: nil)
|
|
132
139
|
Async do
|
|
133
140
|
response = @request_client.conn.get do |req|
|
|
134
141
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
@@ -138,9 +145,10 @@ module TrophyApiClient
|
|
|
138
145
|
**@request_client.get_headers,
|
|
139
146
|
**(request_options&.additional_headers || {})
|
|
140
147
|
}.compact
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
148
|
+
req.params = {
|
|
149
|
+
**(request_options&.additional_query_parameters || {}),
|
|
150
|
+
"includeFinished": include_finished
|
|
151
|
+
}.compact
|
|
144
152
|
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
|
145
153
|
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
|
146
154
|
end
|
|
@@ -4,6 +4,7 @@ require_relative "../../requests"
|
|
|
4
4
|
require_relative "../types/points_summary_response"
|
|
5
5
|
require "json"
|
|
6
6
|
require_relative "../types/points_system_response"
|
|
7
|
+
require_relative "../types/points_boost"
|
|
7
8
|
require "async"
|
|
8
9
|
|
|
9
10
|
module TrophyApiClient
|
|
@@ -57,7 +58,7 @@ module TrophyApiClient
|
|
|
57
58
|
end
|
|
58
59
|
end
|
|
59
60
|
|
|
60
|
-
# Get a points system with
|
|
61
|
+
# Get a points system with its triggers.
|
|
61
62
|
#
|
|
62
63
|
# @param key [String] Key of the points system.
|
|
63
64
|
# @param request_options [TrophyApiClient::RequestOptions]
|
|
@@ -88,6 +89,46 @@ module TrophyApiClient
|
|
|
88
89
|
end
|
|
89
90
|
TrophyApiClient::PointsSystemResponse.from_json(json_object: response.body)
|
|
90
91
|
end
|
|
92
|
+
|
|
93
|
+
# Get all global boosts for a points system. Finished boosts are excluded by
|
|
94
|
+
# default.
|
|
95
|
+
#
|
|
96
|
+
# @param key [String] Key of the points system.
|
|
97
|
+
# @param include_finished [Boolean] When set to 'true', boosts that have finished (past their end date) will be
|
|
98
|
+
# included in the response. By default, finished boosts are excluded.
|
|
99
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
100
|
+
# @return [Array<TrophyApiClient::PointsBoost>]
|
|
101
|
+
# @example
|
|
102
|
+
# api = TrophyApiClient::Client.new(
|
|
103
|
+
# base_url: "https://api.example.com",
|
|
104
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
105
|
+
# api_key: "YOUR_API_KEY"
|
|
106
|
+
# )
|
|
107
|
+
# api.points.boosts(key: "points-system-key", include_finished: true)
|
|
108
|
+
def boosts(key:, include_finished: nil, request_options: nil)
|
|
109
|
+
response = @request_client.conn.get do |req|
|
|
110
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
111
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
112
|
+
req.headers = {
|
|
113
|
+
**(req.headers || {}),
|
|
114
|
+
**@request_client.get_headers,
|
|
115
|
+
**(request_options&.additional_headers || {})
|
|
116
|
+
}.compact
|
|
117
|
+
req.params = {
|
|
118
|
+
**(request_options&.additional_query_parameters || {}),
|
|
119
|
+
"includeFinished": include_finished
|
|
120
|
+
}.compact
|
|
121
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
|
122
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
|
123
|
+
end
|
|
124
|
+
req.url "#{@request_client.get_url(environment: api, request_options: request_options)}/points/#{key}/boosts"
|
|
125
|
+
end
|
|
126
|
+
parsed_json = JSON.parse(response.body)
|
|
127
|
+
parsed_json&.map do |item|
|
|
128
|
+
item = item.to_json
|
|
129
|
+
TrophyApiClient::PointsBoost.from_json(json_object: item)
|
|
130
|
+
end
|
|
131
|
+
end
|
|
91
132
|
end
|
|
92
133
|
|
|
93
134
|
class AsyncPointsClient
|
|
@@ -142,7 +183,7 @@ module TrophyApiClient
|
|
|
142
183
|
end
|
|
143
184
|
end
|
|
144
185
|
|
|
145
|
-
# Get a points system with
|
|
186
|
+
# Get a points system with its triggers.
|
|
146
187
|
#
|
|
147
188
|
# @param key [String] Key of the points system.
|
|
148
189
|
# @param request_options [TrophyApiClient::RequestOptions]
|
|
@@ -175,5 +216,47 @@ module TrophyApiClient
|
|
|
175
216
|
TrophyApiClient::PointsSystemResponse.from_json(json_object: response.body)
|
|
176
217
|
end
|
|
177
218
|
end
|
|
219
|
+
|
|
220
|
+
# Get all global boosts for a points system. Finished boosts are excluded by
|
|
221
|
+
# default.
|
|
222
|
+
#
|
|
223
|
+
# @param key [String] Key of the points system.
|
|
224
|
+
# @param include_finished [Boolean] When set to 'true', boosts that have finished (past their end date) will be
|
|
225
|
+
# included in the response. By default, finished boosts are excluded.
|
|
226
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
227
|
+
# @return [Array<TrophyApiClient::PointsBoost>]
|
|
228
|
+
# @example
|
|
229
|
+
# api = TrophyApiClient::Client.new(
|
|
230
|
+
# base_url: "https://api.example.com",
|
|
231
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
232
|
+
# api_key: "YOUR_API_KEY"
|
|
233
|
+
# )
|
|
234
|
+
# api.points.boosts(key: "points-system-key", include_finished: true)
|
|
235
|
+
def boosts(key:, include_finished: nil, request_options: nil)
|
|
236
|
+
Async do
|
|
237
|
+
response = @request_client.conn.get do |req|
|
|
238
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
239
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
240
|
+
req.headers = {
|
|
241
|
+
**(req.headers || {}),
|
|
242
|
+
**@request_client.get_headers,
|
|
243
|
+
**(request_options&.additional_headers || {})
|
|
244
|
+
}.compact
|
|
245
|
+
req.params = {
|
|
246
|
+
**(request_options&.additional_query_parameters || {}),
|
|
247
|
+
"includeFinished": include_finished
|
|
248
|
+
}.compact
|
|
249
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
|
250
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
|
251
|
+
end
|
|
252
|
+
req.url "#{@request_client.get_url(environment: api, request_options: request_options)}/points/#{key}/boosts"
|
|
253
|
+
end
|
|
254
|
+
parsed_json = JSON.parse(response.body)
|
|
255
|
+
parsed_json&.map do |item|
|
|
256
|
+
item = item.to_json
|
|
257
|
+
TrophyApiClient::PointsBoost.from_json(json_object: item)
|
|
258
|
+
end
|
|
259
|
+
end
|
|
260
|
+
end
|
|
178
261
|
end
|
|
179
262
|
end
|