Class: TrophyApiClient::Admin::StreaksClient
- Inherits:
-
Object
- Object
- TrophyApiClient::Admin::StreaksClient
- Defined in:
- lib/trophy_api_client/admin/streaks/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #initialize(request_client:) ⇒ TrophyApiClient::Admin::StreaksClient constructor
-
#restore(users:, request_options: nil) ⇒ TrophyApiClient::RestoreStreaksResponse
Restore streaks for multiple users to the maximum length in the last 90 days (in the case of daily streaks), one year (in the case of weekly streaks), or two years (in the case of monthly streaks).
Constructor Details
#initialize(request_client:) ⇒ TrophyApiClient::Admin::StreaksClient
16 17 18 |
# File 'lib/trophy_api_client/admin/streaks/client.rb', line 16 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ TrophyApiClient::RequestClient (readonly)
12 13 14 |
# File 'lib/trophy_api_client/admin/streaks/client.rb', line 12 def request_client @request_client end |
Instance Method Details
#restore(users:, request_options: nil) ⇒ TrophyApiClient::RestoreStreaksResponse
Restore streaks for multiple users to the maximum length in the last 90 days (in
the case of daily streaks), one year (in the case of weekly streaks), or two
years (in the case of monthly streaks).
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/trophy_api_client/admin/streaks/client.rb', line 35 def restore(users:, request_options: nil) 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 = { **(&.additional_body_parameters || {}), users: users }.compact req.url "#{@request_client.get_url(environment: admin, request_options: )}/streaks/restore" end TrophyApiClient::RestoreStreaksResponse.from_json(json_object: response.body) end |