Ejemplo n.º 1
0
        protected IRestResponse GetRawResponse(RestRequest request)
        {
            var resp = _crmFactory.GetRestClient().Execute(request);

            // log here as may fail deserialisation
            var body = request.Parameters.SingleOrDefault(x => x.Type == ParameterType.RequestBody)?.Value?.ToString();
            var msg  = $"[{request.Resource}] {body} --> [{resp.StatusCode}] {resp.Content}";

            LogInformation(msg);

            // relog errors explicitly so they are more prominent
            if (resp.StatusCode >= HttpStatusCode.BadRequest)
            {
                _logger.LogError(msg);
            }

            return(resp);
        }
 public ArticleService(IRestClientFactory restClientFactory, IOptions <ApiOptions> options)
 {
     _restClient = restClientFactory.GetRestClient();
     _apiConfig  = options.Value;
 }
Ejemplo n.º 3
0
 public MessageClient(IClientConfig config, IRestClientFactory restClientFactory)
 {
     _restClientFactory = restClientFactory;
     _config            = config;
     _client            = restClientFactory.GetRestClient();
 }