public async Task <IEnumerable <AlbumDto> > Handle(GetAlbumsQuery request, CancellationToken cancellationToken) { Uri requestUrl = new Uri(_httpClient.BaseAddress, ApiConstants.GetAlbumsUrl); AuthenticationHeaderValue authHeader = await _localStorage.GetAuthHeaderValueAsync(); return(await _httpClient.PostAsJsonAsync <GetAlbumsQuery, ICollection <AlbumDto> >(requestUrl, request, authHeader)); }
public async Task <AlbumDto> Handle(CreateAlbumCommand request, CancellationToken cancellationToken) { Uri requestUrl = new Uri(_httpClient.BaseAddress, ApiConstants.CreateAlbum); var authHeader = await _localStorage.GetAuthHeaderValueAsync(); return(await _httpClient.PostAsJsonAsync <CreateAlbumCommand, AlbumDto>(requestUrl, request, authHeader)); }
public async Task <Unit> Handle(ActivateRefreshTokenCommand request, CancellationToken cancellationToken) { var authHeader = await _localStorage.GetAuthHeaderValueAsync(); Uri requestUrl = new Uri(_httpClient.BaseAddress, ApiConstants.ActivateRefreshToken); HttpResponseMessage response = await _httpClient.PostAsJsonAsync(requestUrl, request, authHeader); response.EnsureSuccessStatusCode(); return(Unit.Value); }
public async Task <string> Handle(GetAccessTokenQuery request, CancellationToken cancellationToken) { Uri requestUrl = new Uri(_httpClient.BaseAddress, ApiConstants.GetAccessTokenUrl); var authHeader = await _localStorage.GetAuthHeaderValueAsync(); HttpResponseMessage response = await _httpClient.PostAsJsonAsync(requestUrl, request, authHeader); response.EnsureSuccessStatusCode(); return(await response.Content.ReadAsStringAsync()); }
public async Task <Unit> Handle(DeleteAlbumCommand request, CancellationToken cancellationToken) { Uri requestUrl = new Uri(_httpClient.BaseAddress, ApiConstants.DeleteAlbum); var authHeader = await _localStorage.GetAuthHeaderValueAsync(); var response = await _httpClient.PostAsJsonAsync(requestUrl, request, authHeader); response.EnsureSuccessStatusCode(); return(Unit.Value); }
public async Task <PictureDto> Handle(CreatePictureCommand request, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); Uri requestUrl = new Uri(_httpClient.BaseAddress, ApiConstants.CreateImage); AuthenticationHeaderValue authHeader = await _localStorage.GetAuthHeaderValueAsync(); var multipart = await CreateMultipartFormDataContent(request, cancellationToken); HttpRequestMessage requestMessage = CreateRequestMessage(requestUrl, multipart, authHeader); HttpResponseMessage responseMessage = await _httpClient.SendAsync(requestMessage, cancellationToken); responseMessage.EnsureSuccessStatusCode(); return(await DeserializeResponseAsync(responseMessage)); }