private async Task <ResponseResult <TResult> > DeserializeAsync <TDto, TResult>(HttpResponseMessage response, Func <TDto, ResponseResult <TResult> > successFunc) where TDto : class where TResult : class { var content = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { return(successFunc(JsonConvert.DeserializeObject <TDto>(content))); } else { var errorResult = JsonConvert.DeserializeObject <Dto.FiskalyErrorResponse>(content); return(new ResponseResult <TResult>(errorResult: ErrorResult.Map(errorResult))); } }
private async Task <ResponseResult <TResult, TCode> > DeserializeAsync <TDto, TResult, TCode>(HttpResponseMessage response, Func <TDto, ResponseResult <TResult, TCode> > successFunc) where TDto : class where TResult : class where TCode : struct { var content = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { return(successFunc(XmlManipulator.Deserialize <TDto>(content))); } else { var errorResult = XmlManipulator.Deserialize <Dto.GeneralErrorResponse>(content); return(new ResponseResult <TResult, TCode>(generalErrorMessage: ErrorResult <TCode> .Map(errorResult))); } }