private HttpResponseMessage InvokeMethod <I>(ExternalServiceCallParameter <I> input) { var apiUrl = input.APIUrl; var request = new RestWebRequest <I> { Method = input.ApiMethod, RequestBody = input.Request, ServiceBaseUrl = apiUrl, MediaType = input.MediaType }; ServiceUrl = apiUrl + request.Method; return(input.WebCall.Invoke(request)); }
protected GenericResponse <O> CallWebClient <I, O>(ExternalServiceCallParameter <I> input) { HttpResponseMessage response = InvokeMethod(input); if (response == null) { return(GetGenericFailResponse <O>()); } var result = Newtonsoft.Json.JsonConvert.DeserializeObject <GenericResponse <O> >(GetResultFromResponse(response)); if (result != null && result.Code == 401) { var error = result.Errors.FirstOrDefault(x => x.Code == "Unauthorized"); if (error != null) { _errorCollector.Errors.Add(new ErrorMessage(error.Code, error.Message)); } } return(result); }