public async Task <ExternalServiceResponse <TData> > DeleteAsync <TData>(string endpoint) { var result = new ExternalServiceResponse <TData>(); var response = await base.DeleteAsync(endpoint); result.IsSuccess = response.IsSuccessStatusCode; if (!response.IsSuccessStatusCode) { return(result); } return(await GetObjectFromHttpMessage(result, response)); }
public async Task <ExternalServiceResponse <TData> > PostAsync <TData>(string endpoint, TData payload) { var result = new ExternalServiceResponse <TData>(); var stringContent = GetJsonSerializedStringContent(payload); var response = await base.PostAsync(endpoint, stringContent); result.IsSuccess = response.IsSuccessStatusCode; if (!response.IsSuccessStatusCode) { return(result); } return(await GetObjectFromHttpMessage(result, response)); }
private async Task <ExternalServiceResponse <TData> > GetObjectFromHttpMessage <TData>(ExternalServiceResponse <TData> result, HttpResponseMessage response) { var responseContent = await response.RequestMessage.Content.ReadAsStringAsync(); result.Data = responseContent.FromJson <TData>(); return(result); }