internal virtual async Task <T> RequestAsync <T>( HttpMethod method, string api, string path, object model = null, CancellationToken cancellationToken = default(CancellationToken)) { string endpoint = api + path; var request = new HttpRequestMessage(method, endpoint); if (model != null) { var requestBody = JsonConvert.SerializeObject(model); request.Content = GetJsonContent(requestBody); } var response = await _throttler.ThrottleAsync( () => _togglHttpClient.SendAsync(request, cancellationToken), cancellationToken); var responseBody = await response.Content.ReadAsStringAsync(); if (!response.IsSuccessStatusCode) { throw new TogglApiException(responseBody, response); } var result = JsonConvert.DeserializeObject <T>(responseBody); return(result); }