Exemplo n.º 1
0
 private static Action <HttpRequestMessage> ConfigurarRequisicao <T>(ConfiguracoesRequisicaoRest configuracoesRequisicaoRest)
 {
     return(d =>
     {
         if (configuracoesRequisicaoRest.RequestHeaders != null)
         {
             foreach (var header in configuracoesRequisicaoRest.RequestHeaders)
             {
                 d.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(header));
             }
         }
         if (configuracoesRequisicaoRest.RequestHeadersNomeValor == null)
         {
             return;
         }
         {
             foreach (var header in configuracoesRequisicaoRest.RequestHeadersNomeValor)
             {
                 d.Headers.Add(header.Key, header.Value);
             }
         }
         if (!string.IsNullOrEmpty(configuracoesRequisicaoRest.BearerToken))
         {
             d.Headers.Authorization = new AuthenticationHeaderValue("bearer", configuracoesRequisicaoRest.BearerToken);
         }
         d.Headers.Add("Accept-Encoding", "gzip");
     });
 }
Exemplo n.º 2
0
 public RestHelper(IHttpClientHelper httpClientHelper, ICompactacaoHelper compactacaoHelper)
 {
     _httpClientHelper            = httpClientHelper;
     _compactacaoHelper           = compactacaoHelper;
     _configuracoesRequisicaoRest = new ConfiguracoesRequisicaoRest
     {
         TimeOut = TimeSpan.FromMinutes(5)
     };
 }
Exemplo n.º 3
0
 public async Task <T> Delete <T>(string endereco, ConfiguracoesRequisicaoRest configuracoesRequisicaoRest = null)
 {
     _configuracoesRequisicaoRest = configuracoesRequisicaoRest;
     return(await ObterResponseRetornoRequisicao <object, T>(endereco, TipoRequisicaoRest.Delete, null));
 }
Exemplo n.º 4
0
 public async Task <TR> Put <TR, T>(string endereco, T valor, ConfiguracoesRequisicaoRest configuracoesRequisicaoRest = null)
 {
     _configuracoesRequisicaoRest = configuracoesRequisicaoRest;
     return(await ObterResponseRetornoRequisicao <T, TR>(endereco, TipoRequisicaoRest.Put, valor));
 }