public async Task <MumbdoErrorDto> ParseErrorAsync(HttpResponseMessage responseMessage) { var json = await responseMessage.Content.ReadAsStringAsync(); try { return(await _json.DeserializeAsync <MumbdoErrorDto>(json)); } catch (Exception) { return(null); } }
public async Task <JwtTokenDto> GetTokenAsync() { var json = await _localStorageManager.Get(TokenStorageKey); if (json is null || string.IsNullOrWhiteSpace(json)) { return(null); } return(await _json.DeserializeAsync <JwtTokenDto>(json)); }
public async Task <IHttpResponse <TReturn> > PostAsync <T, TReturn>(string url, T data) where TReturn : class { HttpResponseMessage response = null; try { response = await _client.PostAsync(url, Json(await _json.SerializeAsync(data))); } catch (HttpRequestException) { return(new HttpResponse <TReturn>(null, null, true)); } if (response.IsSuccessStatusCode) { var content = await response.Content.ReadAsStringAsync(); return(new HttpResponse <TReturn>(response, await _json.DeserializeAsync <TReturn>(content))); } return(new HttpResponse <TReturn>(response, null)); }