Skip to content

Commit dde334d

Browse files
Automatically update Ruby SDK
1 parent af16022 commit dde334d

33 files changed

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

lib/requests.rb

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,17 @@ class RequestClient
2121
# @param max_retries [Long] The number of times to retry a failed request, defaults to 2.
2222
# @param timeout_in_seconds [Long]
2323
# @param api_key [String]
24+
# @param tenant_id [String] The tenant identifier for multi-tenant organisations. Required when the
25+
# organisation has multi-tenancy enabled. The value should be your internal ID for
26+
# the tenant. Ignored for single-tenant organisations.
2427
# @return [TrophyApiClient::RequestClient]
2528
def initialize(api_key:, base_url: nil, environment: TrophyApiClient::Environment::PRODUCTION, max_retries: nil,
26-
timeout_in_seconds: nil)
29+
timeout_in_seconds: nil, tenant_id: nil)
2730
@default_environment = environment
2831
@api_key = api_key
29-
@conn = Faraday.new do |faraday|
32+
@headers = {}
33+
@headers["Tenant-ID"] = tenant_id unless tenant_id.nil?
34+
@conn = Faraday.new(headers: @headers) do |faraday|
3035
faraday.request :json
3136
faraday.response :raise_error, include_request: true
3237
faraday.request :retry, { max: max_retries } unless max_retries.nil?
@@ -64,12 +69,17 @@ class AsyncRequestClient
6469
# @param max_retries [Long] The number of times to retry a failed request, defaults to 2.
6570
# @param timeout_in_seconds [Long]
6671
# @param api_key [String]
72+
# @param tenant_id [String] The tenant identifier for multi-tenant organisations. Required when the
73+
# organisation has multi-tenancy enabled. The value should be your internal ID for
74+
# the tenant. Ignored for single-tenant organisations.
6775
# @return [TrophyApiClient::AsyncRequestClient]
6876
def initialize(api_key:, base_url: nil, environment: TrophyApiClient::Environment::PRODUCTION, max_retries: nil,
69-
timeout_in_seconds: nil)
77+
timeout_in_seconds: nil, tenant_id: nil)
7078
@default_environment = environment
7179
@api_key = api_key
72-
@conn = Faraday.new do |faraday|
80+
@headers = {}
81+
@headers["Tenant-ID"] = tenant_id unless tenant_id.nil?
82+
@conn = Faraday.new(headers: @headers) do |faraday|
7383
faraday.request :json
7484
faraday.response :raise_error, include_request: true
7585
faraday.adapter :async_http
@@ -100,6 +110,10 @@ class RequestOptions
100110
attr_reader :base_url
101111
# @return [String]
102112
attr_reader :api_key
113+
# @return [String] The tenant identifier for multi-tenant organisations. Required when the
114+
# organisation has multi-tenancy enabled. The value should be your internal ID for
115+
# the tenant. Ignored for single-tenant organisations.
116+
attr_reader :tenant_id
103117
# @return [Hash{String => Object}]
104118
attr_reader :additional_headers
105119
# @return [Hash{String => Object}]
@@ -111,15 +125,19 @@ class RequestOptions
111125

112126
# @param base_url [String]
113127
# @param api_key [String]
128+
# @param tenant_id [String] The tenant identifier for multi-tenant organisations. Required when the
129+
# organisation has multi-tenancy enabled. The value should be your internal ID for
130+
# the tenant. Ignored for single-tenant organisations.
114131
# @param additional_headers [Hash{String => Object}]
115132
# @param additional_query_parameters [Hash{String => Object}]
116133
# @param additional_body_parameters [Hash{String => Object}]
117134
# @param timeout_in_seconds [Long]
118135
# @return [TrophyApiClient::RequestOptions]
119-
def initialize(base_url: nil, api_key: nil, additional_headers: nil, additional_query_parameters: nil,
120-
additional_body_parameters: nil, timeout_in_seconds: nil)
136+
def initialize(base_url: nil, api_key: nil, tenant_id: nil, additional_headers: nil,
137+
additional_query_parameters: nil, additional_body_parameters: nil, timeout_in_seconds: nil)
121138
@base_url = base_url
122139
@api_key = api_key
140+
@tenant_id = tenant_id
123141
@additional_headers = additional_headers
124142
@additional_query_parameters = additional_query_parameters
125143
@additional_body_parameters = additional_body_parameters
@@ -134,6 +152,10 @@ class IdempotencyRequestOptions
134152
attr_reader :base_url
135153
# @return [String]
136154
attr_reader :api_key
155+
# @return [String] The tenant identifier for multi-tenant organisations. Required when the
156+
# organisation has multi-tenancy enabled. The value should be your internal ID for
157+
# the tenant. Ignored for single-tenant organisations.
158+
attr_reader :tenant_id
137159
# @return [Hash{String => Object}]
138160
attr_reader :additional_headers
139161
# @return [Hash{String => Object}]
@@ -145,15 +167,19 @@ class IdempotencyRequestOptions
145167

146168
# @param base_url [String]
147169
# @param api_key [String]
170+
# @param tenant_id [String] The tenant identifier for multi-tenant organisations. Required when the
171+
# organisation has multi-tenancy enabled. The value should be your internal ID for
172+
# the tenant. Ignored for single-tenant organisations.
148173
# @param additional_headers [Hash{String => Object}]
149174
# @param additional_query_parameters [Hash{String => Object}]
150175
# @param additional_body_parameters [Hash{String => Object}]
151176
# @param timeout_in_seconds [Long]
152177
# @return [TrophyApiClient::IdempotencyRequestOptions]
153-
def initialize(base_url: nil, api_key: nil, additional_headers: nil, additional_query_parameters: nil,
154-
additional_body_parameters: nil, timeout_in_seconds: nil)
178+
def initialize(base_url: nil, api_key: nil, tenant_id: nil, additional_headers: nil,
179+
additional_query_parameters: nil, additional_body_parameters: nil, timeout_in_seconds: nil)
155180
@base_url = base_url
156181
@api_key = api_key
182+
@tenant_id = tenant_id
157183
@additional_headers = additional_headers
158184
@additional_query_parameters = additional_query_parameters
159185
@additional_body_parameters = additional_body_parameters

lib/trophy_api_client.rb

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,19 @@ class Client
3333
# @param max_retries [Long] The number of times to retry a failed request, defaults to 2.
3434
# @param timeout_in_seconds [Long]
3535
# @param api_key [String]
36+
# @param tenant_id [String] The tenant identifier for multi-tenant organisations. Required when the
37+
# organisation has multi-tenancy enabled. The value should be your internal ID for
38+
# the tenant. Ignored for single-tenant organisations.
3639
# @return [TrophyApiClient::Client]
3740
def initialize(api_key:, base_url: nil, environment: TrophyApiClient::Environment::PRODUCTION, max_retries: nil,
38-
timeout_in_seconds: nil)
41+
timeout_in_seconds: nil, tenant_id: nil)
3942
@request_client = TrophyApiClient::RequestClient.new(
4043
base_url: base_url,
4144
environment: environment,
4245
max_retries: max_retries,
4346
timeout_in_seconds: timeout_in_seconds,
44-
api_key: api_key
47+
api_key: api_key,
48+
tenant_id: tenant_id
4549
)
4650
@achievements = TrophyApiClient::AchievementsClient.new(request_client: @request_client)
4751
@metrics = TrophyApiClient::MetricsClient.new(request_client: @request_client)
@@ -74,15 +78,19 @@ class AsyncClient
7478
# @param max_retries [Long] The number of times to retry a failed request, defaults to 2.
7579
# @param timeout_in_seconds [Long]
7680
# @param api_key [String]
81+
# @param tenant_id [String] The tenant identifier for multi-tenant organisations. Required when the
82+
# organisation has multi-tenancy enabled. The value should be your internal ID for
83+
# the tenant. Ignored for single-tenant organisations.
7784
# @return [TrophyApiClient::AsyncClient]
7885
def initialize(api_key:, base_url: nil, environment: TrophyApiClient::Environment::PRODUCTION, max_retries: nil,
79-
timeout_in_seconds: nil)
86+
timeout_in_seconds: nil, tenant_id: nil)
8087
@async_request_client = TrophyApiClient::AsyncRequestClient.new(
8188
base_url: base_url,
8289
environment: environment,
8390
max_retries: max_retries,
8491
timeout_in_seconds: timeout_in_seconds,
85-
api_key: api_key
92+
api_key: api_key,
93+
tenant_id: tenant_id
8694
)
8795
@achievements = TrophyApiClient::AsyncAchievementsClient.new(request_client: @async_request_client)
8896
@metrics = TrophyApiClient::AsyncMetricsClient.new(request_client: @async_request_client)

lib/trophy_api_client/achievements/client.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def all(user_attributes: nil, request_options: nil)
3636
response = @request_client.conn.get do |req|
3737
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
3838
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
39+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
3940
req.headers = {
4041
**(req.headers || {}),
4142
**@request_client.get_headers,
@@ -81,6 +82,7 @@ def complete(key:, user:, request_options: nil)
8182
response = @request_client.conn.post do |req|
8283
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
8384
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
85+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
8486
req.headers = {
8587
**(req.headers || {}),
8688
**@request_client.get_headers,
@@ -126,6 +128,7 @@ def all(user_attributes: nil, request_options: nil)
126128
response = @request_client.conn.get do |req|
127129
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
128130
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
131+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
129132
req.headers = {
130133
**(req.headers || {}),
131134
**@request_client.get_headers,
@@ -173,6 +176,7 @@ def complete(key:, user:, request_options: nil)
173176
response = @request_client.conn.post do |req|
174177
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
175178
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
179+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
176180
req.headers = {
177181
**(req.headers || {}),
178182
**@request_client.get_headers,

lib/trophy_api_client/admin/attributes/client.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def list(limit: nil, skip: nil, request_options: nil)
4040
response = @request_client.conn.get do |req|
4141
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
4242
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
43+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
4344
req.headers = {
4445
**(req.headers || {}),
4546
**@request_client.get_headers,
@@ -74,6 +75,7 @@ def create(request:, request_options: nil)
7475
response = @request_client.conn.post do |req|
7576
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
7677
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
78+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
7779
req.headers = {
7880
**(req.headers || {}),
7981
**@request_client.get_headers,
@@ -105,6 +107,7 @@ def delete(ids: nil, request_options: nil)
105107
response = @request_client.conn.delete do |req|
106108
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
107109
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
110+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
108111
req.headers = {
109112
**(req.headers || {}),
110113
**@request_client.get_headers,
@@ -135,6 +138,7 @@ def update(request:, request_options: nil)
135138
response = @request_client.conn.patch do |req|
136139
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
137140
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
141+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
138142
req.headers = {
139143
**(req.headers || {}),
140144
**@request_client.get_headers,
@@ -165,6 +169,7 @@ def get(id:, request_options: nil)
165169
response = @request_client.conn.get do |req|
166170
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
167171
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
172+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
168173
req.headers = {
169174
**(req.headers || {}),
170175
**@request_client.get_headers,
@@ -210,6 +215,7 @@ def list(limit: nil, skip: nil, request_options: nil)
210215
response = @request_client.conn.get do |req|
211216
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
212217
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
218+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
213219
req.headers = {
214220
**(req.headers || {}),
215221
**@request_client.get_headers,
@@ -250,6 +256,7 @@ def create(request:, request_options: nil)
250256
response = @request_client.conn.post do |req|
251257
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
252258
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
259+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
253260
req.headers = {
254261
**(req.headers || {}),
255262
**@request_client.get_headers,
@@ -283,6 +290,7 @@ def delete(ids: nil, request_options: nil)
283290
response = @request_client.conn.delete do |req|
284291
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
285292
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
293+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
286294
req.headers = {
287295
**(req.headers || {}),
288296
**@request_client.get_headers,
@@ -315,6 +323,7 @@ def update(request:, request_options: nil)
315323
response = @request_client.conn.patch do |req|
316324
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
317325
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
326+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
318327
req.headers = {
319328
**(req.headers || {}),
320329
**@request_client.get_headers,
@@ -347,6 +356,7 @@ def get(id:, request_options: nil)
347356
response = @request_client.conn.get do |req|
348357
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
349358
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
359+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
350360
req.headers = {
351361
**(req.headers || {}),
352362
**@request_client.get_headers,

lib/trophy_api_client/admin/client.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
require_relative "metrics/client"
66
require_relative "leaderboards/client"
77
require_relative "streaks/client"
8+
require_relative "tenants/client"
89
require_relative "points/client"
910

1011
module TrophyApiClient
@@ -18,6 +19,8 @@ class Client
1819
attr_reader :leaderboards
1920
# @return [TrophyApiClient::Admin::StreaksClient]
2021
attr_reader :streaks
22+
# @return [TrophyApiClient::Admin::TenantsClient]
23+
attr_reader :tenants
2124
# @return [TrophyApiClient::Admin::Points::Client]
2225
attr_reader :admin
2326

@@ -28,6 +31,7 @@ def initialize(request_client:)
2831
@metrics = TrophyApiClient::Admin::MetricsClient.new(request_client: request_client)
2932
@leaderboards = TrophyApiClient::Admin::LeaderboardsClient.new(request_client: request_client)
3033
@streaks = TrophyApiClient::Admin::StreaksClient.new(request_client: request_client)
34+
@tenants = TrophyApiClient::Admin::TenantsClient.new(request_client: request_client)
3135
@admin = TrophyApiClient::Admin::Points::Client.new(request_client: request_client)
3236
end
3337
end
@@ -41,6 +45,8 @@ class AsyncClient
4145
attr_reader :leaderboards
4246
# @return [TrophyApiClient::Admin::AsyncStreaksClient]
4347
attr_reader :streaks
48+
# @return [TrophyApiClient::Admin::AsyncTenantsClient]
49+
attr_reader :tenants
4450
# @return [TrophyApiClient::Admin::Points::AsyncClient]
4551
attr_reader :admin
4652

@@ -51,6 +57,7 @@ def initialize(request_client:)
5157
@metrics = TrophyApiClient::Admin::AsyncMetricsClient.new(request_client: request_client)
5258
@leaderboards = TrophyApiClient::Admin::AsyncLeaderboardsClient.new(request_client: request_client)
5359
@streaks = TrophyApiClient::Admin::AsyncStreaksClient.new(request_client: request_client)
60+
@tenants = TrophyApiClient::Admin::AsyncTenantsClient.new(request_client: request_client)
5461
@admin = TrophyApiClient::Admin::Points::AsyncClient.new(request_client: request_client)
5562
end
5663
end

0 commit comments

Comments
 (0)