Class: TrophyApiClient::Admin::AsyncStreaksClient
- Inherits:
-
Object
- Object
- TrophyApiClient::Admin::AsyncStreaksClient
- Defined in:
- lib/trophy_api_client/admin/streaks/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #initialize(request_client:) ⇒ TrophyApiClient::Admin::AsyncStreaksClient constructor
-
#restore(users:, request_options: nil) ⇒ TrophyApiClient::RestoreStreaksResponse
Restore streaks for multiple users to the maximum previously achieved streak length found within the current restore window: the last 90 days for daily streaks, weekly periods starting with the week containing the start of the current calendar year for weekly streaks, and monthly periods starting at the beginning of the previous calendar year for monthly streaks.
Constructor Details
#initialize(request_client:) ⇒ TrophyApiClient::Admin::AsyncStreaksClient
62 63 64 |
# File 'lib/trophy_api_client/admin/streaks/client.rb', line 62 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ TrophyApiClient::AsyncRequestClient (readonly)
58 59 60 |
# File 'lib/trophy_api_client/admin/streaks/client.rb', line 58 def request_client @request_client end |
Instance Method Details
#restore(users:, request_options: nil) ⇒ TrophyApiClient::RestoreStreaksResponse
Restore streaks for multiple users to the maximum previously achieved streak
length found within the current restore window: the last 90 days for daily
streaks, weekly periods starting with the week containing the start of the
current calendar year for weekly streaks, and monthly periods starting at the
beginning of the previous calendar year for monthly streaks.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/trophy_api_client/admin/streaks/client.rb', line 83 def restore(users:, 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 = { **(&.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 end |