Skip to content

Commit 00e8537

Browse files
Automatically update Ruby SDK
1 parent c7e3f5f commit 00e8537

27 files changed

Lines changed: 1377 additions & 32 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.42"
5+
VERSION = "1.1.0-beta.4"
66
AUTHORS = ["Trophy Labs, Inc"].freeze
77
EMAIL = ""
88
SUMMARY = "Ruby library for the Trophy API."

lib/trophy_api_client/admin/client.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,35 @@
22

33
require_relative "../../requests"
44
require_relative "streaks/client"
5+
require_relative "points/client"
56

67
module TrophyApiClient
78
module Admin
89
class Client
910
# @return [TrophyApiClient::Admin::StreaksClient]
1011
attr_reader :streaks
12+
# @return [TrophyApiClient::Admin::Points::Client]
13+
attr_reader :admin
1114

1215
# @param request_client [TrophyApiClient::RequestClient]
1316
# @return [TrophyApiClient::Admin::Client]
1417
def initialize(request_client:)
1518
@streaks = TrophyApiClient::Admin::StreaksClient.new(request_client: request_client)
19+
@admin = TrophyApiClient::Admin::Points::Client.new(request_client: request_client)
1620
end
1721
end
1822

1923
class AsyncClient
2024
# @return [TrophyApiClient::Admin::AsyncStreaksClient]
2125
attr_reader :streaks
26+
# @return [TrophyApiClient::Admin::Points::AsyncClient]
27+
attr_reader :admin
2228

2329
# @param request_client [TrophyApiClient::AsyncRequestClient]
2430
# @return [TrophyApiClient::Admin::AsyncClient]
2531
def initialize(request_client:)
2632
@streaks = TrophyApiClient::Admin::AsyncStreaksClient.new(request_client: request_client)
33+
@admin = TrophyApiClient::Admin::Points::AsyncClient.new(request_client: request_client)
2734
end
2835
end
2936
end
Lines changed: 247 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

0 commit comments

Comments
 (0)