Skip to content

Commit 619e4ba

Browse files
Automatically update Ruby SDK
1 parent 04cb8f3 commit 619e4ba

14 files changed

Lines changed: 232 additions & 126 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.3.4"
5+
VERSION = "1.4.0"
66
AUTHORS = ["Trophy Labs, Inc"].freeze
77
EMAIL = ""
88
SUMMARY = "Ruby library for the Trophy API."

lib/trophy_api_client/admin/points/boosts/client.rb

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
require_relative "../../../../requests"
44
require_relative "types/create_points_boosts_request_boosts_item"
55
require_relative "../../../types/create_points_boosts_response"
6-
require_relative "../../../types/archive_points_boosts_response"
6+
require_relative "../../../types/delete_points_boosts_response"
77
require "async"
88

99
module TrophyApiClient
@@ -22,7 +22,7 @@ def initialize(request_client:)
2222
# Create points boosts for multiple users.
2323
#
2424
# @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
25+
# @param boosts [Array<Hash>] Array of boosts to create. Maximum 100 boosts per request.Request of type Array<TrophyApiClient::Admin::Points::Boosts::CreatePointsBoostsRequestBoostsItem>, as a Hash
2626
# * :user_id (String)
2727
# * :name (String)
2828
# * :start (String)
@@ -64,7 +64,7 @@ def create(system_key:, boosts:, request_options: nil)
6464
#
6565
# @param ids [String] A list of up to 100 boost IDs.
6666
# @param request_options [TrophyApiClient::RequestOptions]
67-
# @return [TrophyApiClient::ArchivePointsBoostsResponse]
67+
# @return [TrophyApiClient::DeletePointsBoostsResponse]
6868
# @example
6969
# api = TrophyApiClient::Client.new(
7070
# base_url: "https://api.example.com",
@@ -87,14 +87,14 @@ def batch_archive(ids: nil, request_options: nil)
8787
end
8888
req.url "#{@request_client.get_url(environment: admin, request_options: request_options)}/points/boosts"
8989
end
90-
TrophyApiClient::ArchivePointsBoostsResponse.from_json(json_object: response.body)
90+
TrophyApiClient::DeletePointsBoostsResponse.from_json(json_object: response.body)
9191
end
9292

9393
# Archive a points boost by ID.
9494
#
9595
# @param id [String] The UUID of the points boost to archive
9696
# @param request_options [TrophyApiClient::RequestOptions]
97-
# @return [Void]
97+
# @return [TrophyApiClient::DeletePointsBoostsResponse]
9898
# @example
9999
# api = TrophyApiClient::Client.new(
100100
# base_url: "https://api.example.com",
@@ -103,7 +103,7 @@ def batch_archive(ids: nil, request_options: nil)
103103
# )
104104
# api.admin.points.boosts.archive(id: "id")
105105
def archive(id:, request_options: nil)
106-
@request_client.conn.delete do |req|
106+
response = @request_client.conn.delete do |req|
107107
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
108108
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
109109
req.headers = {
@@ -120,6 +120,7 @@ def archive(id:, request_options: nil)
120120
req.url "#{@request_client.get_url(environment: admin,
121121
request_options: request_options)}/points/boosts/#{id}"
122122
end
123+
TrophyApiClient::DeletePointsBoostsResponse.from_json(json_object: response.body)
123124
end
124125
end
125126

@@ -136,7 +137,7 @@ def initialize(request_client:)
136137
# Create points boosts for multiple users.
137138
#
138139
# @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+
# @param boosts [Array<Hash>] Array of boosts to create. Maximum 100 boosts per request.Request of type Array<TrophyApiClient::Admin::Points::Boosts::CreatePointsBoostsRequestBoostsItem>, as a Hash
140141
# * :user_id (String)
141142
# * :name (String)
142143
# * :start (String)
@@ -180,7 +181,7 @@ def create(system_key:, boosts:, request_options: nil)
180181
#
181182
# @param ids [String] A list of up to 100 boost IDs.
182183
# @param request_options [TrophyApiClient::RequestOptions]
183-
# @return [TrophyApiClient::ArchivePointsBoostsResponse]
184+
# @return [TrophyApiClient::DeletePointsBoostsResponse]
184185
# @example
185186
# api = TrophyApiClient::Client.new(
186187
# base_url: "https://api.example.com",
@@ -204,15 +205,15 @@ def batch_archive(ids: nil, request_options: nil)
204205
end
205206
req.url "#{@request_client.get_url(environment: admin, request_options: request_options)}/points/boosts"
206207
end
207-
TrophyApiClient::ArchivePointsBoostsResponse.from_json(json_object: response.body)
208+
TrophyApiClient::DeletePointsBoostsResponse.from_json(json_object: response.body)
208209
end
209210
end
210211

211212
# Archive a points boost by ID.
212213
#
213214
# @param id [String] The UUID of the points boost to archive
214215
# @param request_options [TrophyApiClient::RequestOptions]
215-
# @return [Void]
216+
# @return [TrophyApiClient::DeletePointsBoostsResponse]
216217
# @example
217218
# api = TrophyApiClient::Client.new(
218219
# base_url: "https://api.example.com",
@@ -222,7 +223,7 @@ def batch_archive(ids: nil, request_options: nil)
222223
# api.admin.points.boosts.archive(id: "id")
223224
def archive(id:, request_options: nil)
224225
Async do
225-
@request_client.conn.delete do |req|
226+
response = @request_client.conn.delete do |req|
226227
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
227228
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
228229
req.headers = {
@@ -239,6 +240,7 @@ def archive(id:, request_options: nil)
239240
req.url "#{@request_client.get_url(environment: admin,
240241
request_options: request_options)}/points/boosts/#{id}"
241242
end
243+
TrophyApiClient::DeletePointsBoostsResponse.from_json(json_object: response.body)
242244
end
243245
end
244246
end

lib/trophy_api_client/admin/streaks/client.rb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ def initialize(request_client:)
1717
@request_client = request_client
1818
end
1919

20-
# Restore streaks for multiple users to the maximum length in the last 90 days (in
21-
# the case of daily streaks), one year (in the case of weekly streaks), or two
22-
# years (in the case of monthly streaks).
20+
# Restore streaks for multiple users to the maximum previously achieved streak
21+
# length found within the current restore window: the last 90 days for daily
22+
# streaks, weekly periods starting with the week containing the start of the
23+
# current calendar year for weekly streaks, and monthly periods starting at the
24+
# beginning of the previous calendar year for monthly streaks.
2325
#
2426
# @param users [Array<Hash>] Array of users to restore streaks for. Maximum 100 users per request.Request of type Array<TrophyApiClient::Admin::Streaks::RestoreStreaksRequestUsersItem>, as a Hash
2527
# * :id (String)
@@ -61,9 +63,11 @@ def initialize(request_client:)
6163
@request_client = request_client
6264
end
6365

64-
# Restore streaks for multiple users to the maximum length in the last 90 days (in
65-
# the case of daily streaks), one year (in the case of weekly streaks), or two
66-
# years (in the case of monthly streaks).
66+
# Restore streaks for multiple users to the maximum previously achieved streak
67+
# length found within the current restore window: the last 90 days for daily
68+
# streaks, weekly periods starting with the week containing the start of the
69+
# current calendar year for weekly streaks, and monthly periods starting at the
70+
# beginning of the previous calendar year for monthly streaks.
6771
#
6872
# @param users [Array<Hash>] Array of users to restore streaks for. Maximum 100 users per request.Request of type Array<TrophyApiClient::Admin::Streaks::RestoreStreaksRequestUsersItem>, as a Hash
6973
# * :id (String)

lib/trophy_api_client/admin/streaks/freezes/client.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def initialize(request_client:)
2020

2121
# Create streak freezes for multiple users.
2222
#
23-
# @param freezes [Array<Hash>] Array of freezes to create. Maximum 1,000 freezes per request.Request of type Array<TrophyApiClient::Admin::Streaks::Freezes::CreateStreakFreezesRequestFreezesItem>, as a Hash
23+
# @param freezes [Array<Hash>] Array of freezes to create. Maximum 100 freezes per request.Request of type Array<TrophyApiClient::Admin::Streaks::Freezes::CreateStreakFreezesRequestFreezesItem>, as a Hash
2424
# * :user_id (String)
2525
# @param request_options [TrophyApiClient::RequestOptions]
2626
# @return [TrophyApiClient::CreateStreakFreezesResponse]
@@ -62,7 +62,7 @@ def initialize(request_client:)
6262

6363
# Create streak freezes for multiple users.
6464
#
65-
# @param freezes [Array<Hash>] Array of freezes to create. Maximum 1,000 freezes per request.Request of type Array<TrophyApiClient::Admin::Streaks::Freezes::CreateStreakFreezesRequestFreezesItem>, as a Hash
65+
# @param freezes [Array<Hash>] Array of freezes to create. Maximum 100 freezes per request.Request of type Array<TrophyApiClient::Admin::Streaks::Freezes::CreateStreakFreezesRequestFreezesItem>, as a Hash
6666
# * :user_id (String)
6767
# @param request_options [TrophyApiClient::RequestOptions]
6868
# @return [TrophyApiClient::CreateStreakFreezesResponse]
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# frozen_string_literal: true
2+
3+
require_relative "admin_issue_severity"
4+
require "ostruct"
5+
require "json"
6+
7+
module TrophyApiClient
8+
# An issue encountered while processing an item in an admin API request.
9+
class AdminIssue
10+
# @return [String] The ID of the user the issue relates to, when applicable.
11+
attr_reader :user_id
12+
# @return [String] The ID of the points boost the issue relates to, when applicable.
13+
attr_reader :boost_id
14+
# @return [Integer] The zero-based index of the item the issue relates to, when no resource ID
15+
# exists yet.
16+
attr_reader :index
17+
# @return [TrophyApiClient::AdminIssueSeverity] The severity level of the issue.
18+
attr_reader :severity
19+
# @return [String] A human-readable description of the issue.
20+
attr_reader :message
21+
# @return [OpenStruct] Additional properties unmapped to the current class definition
22+
attr_reader :additional_properties
23+
# @return [Object]
24+
attr_reader :_field_set
25+
protected :_field_set
26+
27+
OMIT = Object.new
28+
29+
# @param user_id [String] The ID of the user the issue relates to, when applicable.
30+
# @param boost_id [String] The ID of the points boost the issue relates to, when applicable.
31+
# @param index [Integer] The zero-based index of the item the issue relates to, when no resource ID
32+
# exists yet.
33+
# @param severity [TrophyApiClient::AdminIssueSeverity] The severity level of the issue.
34+
# @param message [String] A human-readable description of the issue.
35+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
36+
# @return [TrophyApiClient::AdminIssue]
37+
def initialize(severity:, message:, user_id: OMIT, boost_id: OMIT, index: OMIT, additional_properties: nil)
38+
@user_id = user_id if user_id != OMIT
39+
@boost_id = boost_id if boost_id != OMIT
40+
@index = index if index != OMIT
41+
@severity = severity
42+
@message = message
43+
@additional_properties = additional_properties
44+
@_field_set = {
45+
"userId": user_id,
46+
"boostId": boost_id,
47+
"index": index,
48+
"severity": severity,
49+
"message": message
50+
}.reject do |_k, v|
51+
v == OMIT
52+
end
53+
end
54+
55+
# Deserialize a JSON object to an instance of AdminIssue
56+
#
57+
# @param json_object [String]
58+
# @return [TrophyApiClient::AdminIssue]
59+
def self.from_json(json_object:)
60+
struct = JSON.parse(json_object, object_class: OpenStruct)
61+
parsed_json = JSON.parse(json_object)
62+
user_id = parsed_json["userId"]
63+
boost_id = parsed_json["boostId"]
64+
index = parsed_json["index"]
65+
severity = parsed_json["severity"]
66+
message = parsed_json["message"]
67+
new(
68+
user_id: user_id,
69+
boost_id: boost_id,
70+
index: index,
71+
severity: severity,
72+
message: message,
73+
additional_properties: struct
74+
)
75+
end
76+
77+
# Serialize an instance of AdminIssue to a JSON object
78+
#
79+
# @return [String]
80+
def to_json(*_args)
81+
@_field_set&.to_json
82+
end
83+
84+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
85+
# hash and check each fields type against the current object's property
86+
# definitions.
87+
#
88+
# @param obj [Object]
89+
# @return [Void]
90+
def self.validate_raw(obj:)
91+
obj.user_id&.is_a?(String) != false || raise("Passed value for field obj.user_id is not the expected type, validation failed.")
92+
obj.boost_id&.is_a?(String) != false || raise("Passed value for field obj.boost_id is not the expected type, validation failed.")
93+
obj.index&.is_a?(Integer) != false || raise("Passed value for field obj.index is not the expected type, validation failed.")
94+
obj.severity.is_a?(TrophyApiClient::AdminIssueSeverity) != false || raise("Passed value for field obj.severity is not the expected type, validation failed.")
95+
obj.message.is_a?(String) != false || raise("Passed value for field obj.message is not the expected type, validation failed.")
96+
end
97+
end
98+
end

lib/trophy_api_client/types/bulk_insert_issue_level.rb renamed to lib/trophy_api_client/types/admin_issue_severity.rb

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

33
module TrophyApiClient
44
# The severity level of the issue.
5-
class BulkInsertIssueLevel
5+
class AdminIssueSeverity
66
ERROR = "error"
77
WARNING = "warning"
88
end

lib/trophy_api_client/types/bulk_insert_issue.rb

Lines changed: 0 additions & 74 deletions
This file was deleted.

lib/trophy_api_client/types/create_points_boosts_response.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
require_relative "created_points_boost"
4-
require_relative "bulk_insert_issue"
4+
require_relative "admin_issue"
55
require "ostruct"
66
require "json"
77

@@ -11,7 +11,7 @@ module TrophyApiClient
1111
class CreatePointsBoostsResponse
1212
# @return [Array<TrophyApiClient::CreatedPointsBoost>] Array of successfully created boosts.
1313
attr_reader :created
14-
# @return [Array<TrophyApiClient::BulkInsertIssue>] Array of issues encountered during boost creation.
14+
# @return [Array<TrophyApiClient::AdminIssue>] Array of issues encountered during boost creation.
1515
attr_reader :issues
1616
# @return [OpenStruct] Additional properties unmapped to the current class definition
1717
attr_reader :additional_properties
@@ -22,7 +22,7 @@ class CreatePointsBoostsResponse
2222
OMIT = Object.new
2323

2424
# @param created [Array<TrophyApiClient::CreatedPointsBoost>] Array of successfully created boosts.
25-
# @param issues [Array<TrophyApiClient::BulkInsertIssue>] Array of issues encountered during boost creation.
25+
# @param issues [Array<TrophyApiClient::AdminIssue>] Array of issues encountered during boost creation.
2626
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
2727
# @return [TrophyApiClient::CreatePointsBoostsResponse]
2828
def initialize(created:, issues:, additional_properties: nil)
@@ -45,7 +45,7 @@ def self.from_json(json_object:)
4545
end
4646
issues = parsed_json["issues"]&.map do |item|
4747
item = item.to_json
48-
TrophyApiClient::BulkInsertIssue.from_json(json_object: item)
48+
TrophyApiClient::AdminIssue.from_json(json_object: item)
4949
end
5050
new(
5151
created: created,

0 commit comments

Comments
 (0)