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
201 202 203 |
# File 'lib/trophy_api_client/admin/points/systems/client.rb', line 201 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ TrophyApiClient::AsyncRequestClient (readonly)
197 198 199 |
# File 'lib/trophy_api_client/admin/points/systems/client.rb', line 197 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.
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/trophy_api_client/admin/points/systems/client.rb', line 260 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["Tenant-ID"] = .tenant_id unless &.tenant_id.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.
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 |
# File 'lib/trophy_api_client/admin/points/systems/client.rb', line 293 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["Tenant-ID"] = .tenant_id unless &.tenant_id.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.
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 |
# File 'lib/trophy_api_client/admin/points/systems/client.rb', line 359 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["Tenant-ID"] = .tenant_id unless &.tenant_id.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.
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/trophy_api_client/admin/points/systems/client.rb', line 218 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["Tenant-ID"] = .tenant_id unless &.tenant_id.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.
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 |
# File 'lib/trophy_api_client/admin/points/systems/client.rb', line 326 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["Tenant-ID"] = .tenant_id unless &.tenant_id.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 |