Class: TrophyApiClient::AsyncPointsClient
- Inherits:
-
Object
- Object
- TrophyApiClient::AsyncPointsClient
- Defined in:
- lib/trophy_api_client/points/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#boosts(key:, include_finished: nil, request_options: nil) ⇒ Array<TrophyApiClient::PointsBoost>
Get all global boosts for a points system.
- #initialize(request_client:) ⇒ TrophyApiClient::AsyncPointsClient constructor
-
#level_summary(key:, request_options: nil) ⇒ TrophyApiClient::POINTS_LEVEL_SUMMARY_RESPONSE
Get a breakdown of the number of users at each level in a points system.
-
#levels(key:, request_options: nil) ⇒ Array<TrophyApiClient::PointsLevel>
Get all levels for a points system.
-
#summary(key:, user_attributes: nil, request_options: nil) ⇒ TrophyApiClient::POINTS_SUMMARY_RESPONSE
Get a breakdown of the number of users with points in each range.
-
#system(key:, request_options: nil) ⇒ TrophyApiClient::PointsSystemResponse
Get a points system with its triggers.
Constructor Details
#initialize(request_client:) ⇒ TrophyApiClient::AsyncPointsClient
215 216 217 |
# File 'lib/trophy_api_client/points/client.rb', line 215 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ TrophyApiClient::AsyncRequestClient (readonly)
211 212 213 |
# File 'lib/trophy_api_client/points/client.rb', line 211 def request_client @request_client end |
Instance Method Details
#boosts(key:, include_finished: nil, request_options: nil) ⇒ Array<TrophyApiClient::PointsBoost>
Get all global boosts for a points system. Finished boosts are excluded by
default.
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
# File 'lib/trophy_api_client/points/client.rb', line 310 def boosts(key:, include_finished: 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 || {}), "includeFinished": include_finished }.compact unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(environment: api, request_options: )}/points/#{key}/boosts" end parsed_json = JSON.parse(response.body) parsed_json&.map do |item| item = item.to_json TrophyApiClient::PointsBoost.from_json(json_object: item) end end end |
#level_summary(key:, request_options: nil) ⇒ TrophyApiClient::POINTS_LEVEL_SUMMARY_RESPONSE
Get a breakdown of the number of users at each level in a points system.
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 |
# File 'lib/trophy_api_client/points/client.rb', line 387 def level_summary(key:, 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: api, request_options: )}/points/#{key}/level-summary" end parsed_json = JSON.parse(response.body) parsed_json&.map do |item| item = item.to_json TrophyApiClient::PointsLevelSummaryResponseItem.from_json(json_object: item) end end end |
#levels(key:, request_options: nil) ⇒ Array<TrophyApiClient::PointsLevel>
Get all levels for a points system.
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 |
# File 'lib/trophy_api_client/points/client.rb', line 349 def levels(key:, 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: api, request_options: )}/points/#{key}/levels" end parsed_json = JSON.parse(response.body) parsed_json&.map do |item| item = item.to_json TrophyApiClient::PointsLevel.from_json(json_object: item) end end end |
#summary(key:, user_attributes: nil, request_options: nil) ⇒ TrophyApiClient::POINTS_SUMMARY_RESPONSE
Get a breakdown of the number of users with points in each range.
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
# File 'lib/trophy_api_client/points/client.rb', line 234 def summary(key:, user_attributes: 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 || {}), "userAttributes": user_attributes }.compact unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(environment: api, request_options: )}/points/#{key}/summary" end parsed_json = JSON.parse(response.body) parsed_json&.map do |item| item = item.to_json TrophyApiClient::PointsRange.from_json(json_object: item) end end end |
#system(key:, request_options: nil) ⇒ TrophyApiClient::PointsSystemResponse
Get a points system with its triggers.
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
# File 'lib/trophy_api_client/points/client.rb', line 273 def system(key:, 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: api, request_options: )}/points/#{key}" end TrophyApiClient::PointsSystemResponse.from_json(json_object: response.body) end end |