Class: TrophyApiClient::Admin::Points::AsyncSystemsClient
- Inherits:
-
Object
- Object
- TrophyApiClient::Admin::Points::AsyncSystemsClient
- Defined in:
- lib/trophy_api_client/admin/points/systems/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#create(request:, request_options: nil) ⇒ TrophyApiClient::CreatePointsSystemsResponse
Create points systems.
-
#delete(ids: nil, request_options: nil) ⇒ TrophyApiClient::DeletePointsSystemsResponse
Delete (archive) points systems by ID.
-
#get(id:, request_options: nil) ⇒ TrophyApiClient::AdminPointsSystem
Get a points system by ID.
- #initialize(request_client:) ⇒ TrophyApiClient::Admin::Points::AsyncSystemsClient constructor
-
#list(limit: nil, skip: nil, request_options: nil) ⇒ TrophyApiClient::LIST_POINTS_SYSTEMS_RESPONSE
List points systems.
-
#update(request:, request_options: nil) ⇒ TrophyApiClient::UpdatePointsSystemsResponse
Update points systems by ID.
Constructor Details
#initialize(request_client:) ⇒ TrophyApiClient::Admin::Points::AsyncSystemsClient
196 197 198 |
# File 'lib/trophy_api_client/admin/points/systems/client.rb', line 196 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ TrophyApiClient::AsyncRequestClient (readonly)
192 193 194 |
# File 'lib/trophy_api_client/admin/points/systems/client.rb', line 192 def request_client @request_client end |
Instance Method Details
#create(request:, request_options: nil) ⇒ TrophyApiClient::CreatePointsSystemsResponse
Create points systems. Optionally include sub-entities (levels, boosts,
triggers) in each system payload to create them alongside the system.
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
# File 'lib/trophy_api_client/admin/points/systems/client.rb', line 254 def create(request:, request_options: nil) Async do response = @request_client.conn.post do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["X-API-KEY"] = .api_key unless &.api_key.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end req.body = { **(request || {}), **(&.additional_body_parameters || {}) }.compact req.url "#{@request_client.get_url(environment: admin, request_options: )}/points" end TrophyApiClient::CreatePointsSystemsResponse.from_json(json_object: response.body) end end |
#delete(ids: nil, request_options: nil) ⇒ TrophyApiClient::DeletePointsSystemsResponse
Delete (archive) points systems by ID.
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
# File 'lib/trophy_api_client/admin/points/systems/client.rb', line 286 def delete(ids: nil, request_options: nil) Async do response = @request_client.conn.delete do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["X-API-KEY"] = .api_key unless &.api_key.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "ids": ids }.compact unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(environment: admin, request_options: )}/points" end TrophyApiClient::DeletePointsSystemsResponse.from_json(json_object: response.body) end end |
#get(id:, request_options: nil) ⇒ TrophyApiClient::AdminPointsSystem
Get a points system by ID.
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 |
# File 'lib/trophy_api_client/admin/points/systems/client.rb', line 350 def get(id:, request_options: nil) Async do response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["X-API-KEY"] = .api_key unless &.api_key.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(environment: admin, request_options: )}/points/#{id}" end TrophyApiClient::AdminPointsSystem.from_json(json_object: response.body) end end |
#list(limit: nil, skip: nil, request_options: nil) ⇒ TrophyApiClient::LIST_POINTS_SYSTEMS_RESPONSE
List points systems.
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
# File 'lib/trophy_api_client/admin/points/systems/client.rb', line 213 def list(limit: nil, skip: nil, request_options: nil) Async do response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["X-API-KEY"] = .api_key unless &.api_key.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "limit": limit, "skip": skip }.compact unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(environment: admin, request_options: )}/points" end parsed_json = JSON.parse(response.body) parsed_json&.map do |item| item = item.to_json TrophyApiClient::AdminPointsSystem.from_json(json_object: item) end end end |
#update(request:, request_options: nil) ⇒ TrophyApiClient::UpdatePointsSystemsResponse
Update points systems by ID.
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
# File 'lib/trophy_api_client/admin/points/systems/client.rb', line 318 def update(request:, request_options: nil) Async do response = @request_client.conn.patch do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["X-API-KEY"] = .api_key unless &.api_key.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end req.body = { **(request || {}), **(&.additional_body_parameters || {}) }.compact req.url "#{@request_client.get_url(environment: admin, request_options: )}/points" end TrophyApiClient::UpdatePointsSystemsResponse.from_json(json_object: response.body) end end |