private async Task <HttpResponseMessage> SendHttpRequestAsync(PartyGoer user, SpotifyEndpoint spotifyEndpoint, ApiParameters queryStringParameters, object requestBodyParameters) { await RefreshTokenForUserAsync(user.Id); using (var requestMessage = new HttpRequestMessage(spotifyEndpoint.HttpMethod, spotifyEndpoint.EndpointUrl + AddQueryStrings(queryStringParameters))) { requestMessage.Headers.Authorization = await _spotifyAuthentication.GetAuthenticationHeaderForPartyGoerAsync(user.Id); if (requestBodyParameters != null) { requestMessage.Content = new StringContent(JsonConvert.SerializeObject(requestBodyParameters)); } return(await _httpClient.SendAsync(requestMessage)); } }
private async Task <HttpResponseMessage> SendHttpRequestAsync(string spotifyId, SpotifyEndpoint spotifyEndpoint, object content = null, bool useQueryString = false) { await RefreshTokenForUserAsync(spotifyId); using (var requestMessage = new HttpRequestMessage(spotifyEndpoint.HttpMethod, spotifyEndpoint.EndpointUrl + (useQueryString ? $"?{content}" : string.Empty))) { requestMessage.Headers.Authorization = await _spotifyAuthentication.GetAuthenticationHeaderForPartyGoerAsync(spotifyId); if (content != null) { if (!useQueryString) { requestMessage.Content = new StringContent(JsonConvert.SerializeObject(content)); } } return(await _httpClient.SendAsync(requestMessage)); } }
private async Task <HttpResponseMessage> SendHttpRequestAsync(PartyGoer user, SpotifyEndpoint spotifyEndpoint, object content = null, bool useQueryString = false) { return(await SendHttpRequestAsync(user.Id, spotifyEndpoint, content, useQueryString)); }