/// <summary>
        /// Serializa um objeto para uma string Json ou Xml
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="obj"></param>
        /// <param name="httpContentType"></param>
        /// <returns></returns>
        private string SerializeObject <T>(T obj, HttpContentTypeEnum httpContentType)
        {
            if (obj == null)
            {
                return(null);
            }

            string serializedString = string.Empty;

            // Classe de serialização Json
            XmlObjectSerializer serializer = null;

            if (httpContentType == HttpContentTypeEnum.Json)
            {
                serializer = new DataContractJsonSerializer(typeof(T));
            }
            else if (httpContentType == HttpContentTypeEnum.Xml)
            {
                serializer = new DataContractSerializer(typeof(T));
            }

            // Serializa o objeto para o memoryStream
            MemoryStream memoryStream = new MemoryStream();

            serializer.WriteObject(memoryStream, obj);

            // Recupera a string correspondente ao objeto serializado
            serializedString = Encoding.UTF8.GetString(memoryStream.ToArray());

            memoryStream.Close();

            return(serializedString);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 发送Post请求
 /// </summary>
 /// <param name="url">url地址</param>
 /// <param name="data">参数(Json字符串,XML文档,对象实体,字典string string)</param>
 /// <param name="contentType">Content-Type</param>
 /// <param name="timeout">超时时间</param>
 /// <returns>返回值</returns>
 public static string SendPost(string url, object data = null, HttpContentTypeEnum contentType = HttpContentTypeEnum.ApplicationJson, int timeout = 100)
 {
     if (url.MIsNullOrEmpty())
     {
         throw new MHttpRequestException($"参数{nameof(url)}不能为空");
     }
     using (var client = GetHttpClient(timeout))
     {
         var    ms = new MemoryStream();
         string resutlStr;
         using (var content = GetHttpContent(data, contentType, ref ms))
         {
             try
             {
                 using (var responseMessage = client.PostAsync(url, content).Result)
                 {
                     var resultBytes = responseMessage.Content.ReadAsByteArrayAsync().Result;
                     resutlStr = Encoding.UTF8.GetString(resultBytes);
                 }
             }
             finally
             {
                 ms.Close();
             }
         }
         return(resutlStr);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Realiza a deserialização de uma string Json ou Xml para um objeto
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="serializedObject"></param>
        /// <param name="httpContentType"></param>
        /// <returns></returns>
        private T DeserializeObject <T>(string serializedObject, HttpContentTypeEnum httpContentType)
        {
            // Obtém um serializador para o content type definido.
            ISerializer serializer = SerializerFactory.Create(httpContentType.ToString());

            // Realiza a deserialização da string para o objeto informado
            T obj = serializer.DeserializeObject <T>(serializedObject);

            return(obj);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Serializa um objeto para uma string Json ou Xml
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="obj"></param>
        /// <param name="httpContentType"></param>
        /// <returns></returns>
        private string SerializeObject <T>(T obj, HttpContentTypeEnum httpContentType)
        {
            // Obtém um serializador para o content type definido.
            ISerializer serializer = SerializerFactory.Create(httpContentType.ToString());

            // Recupera a string correspondente ao objeto serializado
            string serializedString = serializer.SerializeObject <T>(obj);

            return(serializedString);
        }
Ejemplo n.º 5
0
        private string GetContentTypeFromEnum(HttpContentTypeEnum httpContentType)
        {
            switch (httpContentType)
            {
            case HttpContentTypeEnum.Xml:
                return("application/xml");

            default:
                return("application/json");
            }
        }
        protected BaseResource(Guid merchantKey, PlatformEnvironment platformEnvironment, HttpContentTypeEnum httpContentType, string resourceName, Uri hostUri)
        {
            if (merchantKey == Guid.Empty) {
                merchantKey = this.GetConfigurationKey("GatewayService.MerchantKey");
            }

            this.HttpUtility = new HttpUtility();
            System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

            this.MerchantKey = merchantKey;
            this.PlatformEnvironment = platformEnvironment;
            this.HttpContentType = httpContentType;
            if (hostUri != null) {
                this._hostUri = hostUri.ToString();
                this._hostUri = this._hostUri.Remove(this._hostUri.Length - 1);
            }
            else {
                this._hostUri = this.GetServiceUri(platformEnvironment);
            }
            this._resourceName = resourceName;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// verilen urle, verilen entityi post eder cevabı R tipine çevirir.
        /// </summary>
        /// <param name="entity">T entity</param>
        /// <param name="url">String url</param>
        /// <returns>R</returns>
        public static R Post <R, T>(T entity, string url, HttpContentTypeEnum type = HttpContentTypeEnum.ApplicationJson)
        {
            var request = (HttpWebRequest)WebRequest.Create(url);

            var postString = entity.ToJson();
            var postData   = Encoding.UTF8.GetBytes(postString);

            request.Method        = HttpMethodEnum.Post.Description();
            request.ContentType   = type.Description();
            request.ContentLength = postData.Length;

            using (var stream = request.GetRequestStream())
            {
                stream.Write(postData, Int.Zero, postData.Length);
            }

            var response       = (HttpWebResponse)request.GetResponse();
            var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();

            return(responseString.FromJson <R>());
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 获得HttpContent
        /// </summary>
        /// <param name="contentType">Content-Type</param>
        /// <param name="data">参数</param>
        /// <param name="ms">记忆流</param>
        /// <returns></returns>
        private static HttpContent GetHttpContent(object data, HttpContentTypeEnum contentType, ref MemoryStream ms)
        {
            HttpContent content;

            switch (contentType)
            {
            case HttpContentTypeEnum.ApplicationJson:
                var dataJson = data.MToJson();
                content = GetHttpContentByFormDataBytes(ms, dataJson);
                content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                break;

            case HttpContentTypeEnum.ApplicationXml:
                content = GetHttpContentByFormDataBytes(ms, data.ToString());
                content.Headers.ContentType = new MediaTypeHeaderValue("application/xml");
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(contentType), contentType, null);
            }
            return(content);
        }
        /// <summary>
        /// Realiza a deserialização de uma string Json ou Xml para um objeto
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="serializedObject"></param>
        /// <param name="httpContentType"></param>
        /// <returns></returns>
        private T DeserializeObject <T>(string serializedObject, HttpContentTypeEnum httpContentType)
        {
            // Classe de serialização Json
            XmlObjectSerializer deserializer = null;

            if (httpContentType == HttpContentTypeEnum.Json)
            {
                deserializer = new DataContractJsonSerializer(typeof(T));
            }
            else if (httpContentType == HttpContentTypeEnum.Xml)
            {
                deserializer = new DataContractSerializer(typeof(T));
            }

            // Recupera os bytes correspondentes a string
            MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(serializedObject));

            // Realiza a deserialização da string para o objeto informado
            T obj = (T)deserializer.ReadObject(ms);

            return(obj);
        }
Ejemplo n.º 10
0
        public HttpResponse <TResponse> SubmitRequest <TResponse>(string serviceUri, HttpVerbEnum httpVerb, HttpContentTypeEnum contentType, NameValueCollection header)
        {
            TResponse responseObject          = this.DeserializeObject <TResponse>(MockRawResponse, contentType);
            HttpResponse <TResponse> response = new HttpResponse <TResponse>(responseObject, MockRawResponse, MockStatusCode);

            return(response);
        }
 public SaleResource(Guid merchantKey, PlatformEnvironment platformEnvironment, HttpContentTypeEnum httpContentType, Uri hostUri)
     : base(merchantKey, platformEnvironment, httpContentType, "/Sale", hostUri)
 {
 }
 public GatewayServiceClient(Guid merchantKey, PlatformEnvironment environment, HttpContentTypeEnum httpContentType)
     : this(merchantKey, environment, httpContentType, null)
 {
 }
 public GatewayServiceClient(Guid merchantKey, PlatformEnvironment environment, HttpContentTypeEnum httpContentType, Uri hostUri)
 {
     this._sale = new SaleResource(merchantKey, environment, httpContentType, hostUri);
     this._creditCard = new CreditCardResource(merchantKey, environment, httpContentType, hostUri);
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Chamada Async do HttoWebRequest
 /// </summary>
 /// <param name="dataToSend"></param>
 /// <param name="httpVerbEnum"></param>
 /// <param name="httpContentTypeEnum"></param>
 /// <param name="serviceEndpoint"></param>
 /// <param name="headerData"></param>
 /// <param name="allowInvalidCertificate"></param>
 public void SendHttpWebRequestAsync(string dataToSend, HttpVerbEnum httpVerbEnum, HttpContentTypeEnum httpContentTypeEnum, string serviceEndpoint, NameValueCollection headerData, bool allowInvalidCertificate = false)
 {
     Task.Factory.StartNew(() =>
     {
         bool ignoreResponse = true;
         SendHttpWebRequest(dataToSend, httpVerbEnum, httpContentTypeEnum, serviceEndpoint, headerData, allowInvalidCertificate, ignoreResponse);
     });
 }
 public GatewayServiceClient(Guid merchantKey, PlatformEnvironment environment, HttpContentTypeEnum httpContentType, Uri hostUri)
 {
     this._sale       = new SaleResource(merchantKey, environment, httpContentType, hostUri);
     this._creditCard = new CreditCardResource(merchantKey, environment, httpContentType, hostUri);
 }
 protected BaseResource(Guid merchantKey, PlatformEnvironment platformEnvironment, HttpContentTypeEnum httpContentType, string resourceName)
     : this(merchantKey, platformEnvironment, httpContentType, resourceName, null)
 {
 }
Ejemplo n.º 17
0
 /// <summary>
 /// 构造器
 /// </summary>
 /// <param name="type">表名</param>
 public HttpContentTypeAttribute(HttpContentTypeEnum type)
 {
     this.Type = type;
 }
Ejemplo n.º 18
0
        /// <summary>
        /// Envia uma requisição para o gateway
        /// </summary>
        /// <typeparam name="TRequest">Tipo de requisição enviada para o gateway</typeparam>
        /// <typeparam name="TResponse">Tipo de resposta do gateway</typeparam>
        /// <param name="request">Requisição enviada para o gateway</param>
        /// <param name="serviceUri">Url do serviço do gateway</param>
        /// <param name="httpVerb">HttpMethod utilizado na chamada ao serviço</param>
        /// <param name="contentType">Formato da requisição e da resposta (XML ou JSON)</param>
        /// <param name="header">Cabeçalho da requisição</param>
        /// <returns></returns>
        public HttpResponse <TResponse, TRequest> SubmitRequest <TRequest, TResponse>(TRequest request, string serviceUri, HttpVerbEnum httpVerb, HttpContentTypeEnum contentType, NameValueCollection header)
        {
            Uri uri = new Uri(serviceUri);

            HttpResponse <TResponse, TRequest> response = this.SendHttpWebRequest <TResponse, TRequest>(request, httpVerb, contentType, serviceUri.ToString(), header);

            return(response);
        }
Ejemplo n.º 19
0
        protected BaseResource(Guid merchantKey, PlatformEnvironment platformEnvironment, HttpContentTypeEnum httpContentType, string resourceName, Uri hostUri)
        {
            if (merchantKey == Guid.Empty)
            {
                merchantKey = this.GetConfigurationKey("GatewayService.MerchantKey");
            }

            this.HttpUtility = new HttpUtility();
            System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };

            this.MerchantKey         = merchantKey;
            this.PlatformEnvironment = platformEnvironment;
            this.HttpContentType     = httpContentType;
            if (hostUri != null)
            {
                this._hostUri = hostUri.ToString();
                this._hostUri = this._hostUri.Remove(this._hostUri.Length - 1);
            }
            else
            {
                this._hostUri = this.GetServiceUri(platformEnvironment);
            }
            this._resourceName = resourceName;
        }
Ejemplo n.º 20
0
        public HttpResponse <TResponse> SubmitRequest <TResponse>(string serviceUri, HttpVerbEnum httpVerb, HttpContentTypeEnum contentType, NameValueCollection header)
        {
            string    MockResponse            = "{\"ErrorReport\": null,  \"InternalTime\": 137,  \"MerchantKey\": \"F2A1F485-CFD4-49F5-8862-0EBC438AE923\",  \"RequestKey\": \"857a5a07-ff3c-46e3-946e-452e25f149eb\",  \"BoletoTransactionResultCollection\": [],  \"BuyerKey\": \"00000000-0000-0000-0000-000000000000\",  \"CreditCardTransactionResultCollection\": [    {      \"AcquirerMessage\": \"Simulator|Transação de simulação autorizada com sucesso\",      \"AcquirerName\": \"Simulator\",      \"AcquirerReturnCode\": \"0\",      \"AffiliationCode\": \"000000000\",      \"AmountInCents\": 10000,      \"AuthorizationCode\": \"168147\",      \"AuthorizedAmountInCents\": 10000,      \"CapturedAmountInCents\": 10000,      \"CapturedDate\": \"2015-12-04T19:51:11\",      \"CreditCard\": {        \"CreditCardBrand\": \"Visa\",        \"InstantBuyKey\": \"3b3b5b62-6660-428d-905e-96f49d46ae28\",        \"IsExpiredCreditCard\": false,        \"MaskedCreditCardNumber\": \"411111****1111\"      },      \"CreditCardOperation\": \"AuthAndCapture\",      \"CreditCardTransactionStatus\": \"Captured\",      \"DueDate\": null,      \"ExternalTime\": 0,      \"PaymentMethodName\": \"Simulator\",      \"RefundedAmountInCents\": null,      \"Success\": true,      \"TransactionIdentifier\": \"246844\",      \"TransactionKey\": \"20ba0520-7d09-44f8-8fbc-e4329e2b18d5\",      \"TransactionKeyToAcquirer\": \"20ba05207d0944f8\",      \"TransactionReference\": \"1c65eaf7-df3c-4c7f-af63-f90fb6200996\",      \"UniqueSequentialNumber\": \"636606\",      \"VoidedAmountInCents\": null    }  ],  \"OrderResult\": {    \"CreateDate\": \"2015-12-04T19:51:11\",    \"OrderKey\": \"219d7581-78e2-4aa9-b708-b7c585780bfc\",    \"OrderReference\": \"NúmeroDoPedido\"  }}";
            TResponse responseObject          = this.DeserializeObject <TResponse>(MockResponse, contentType);
            HttpResponse <TResponse> response = new HttpResponse <TResponse>(responseObject, MockResponse, System.Net.HttpStatusCode.Created);

            return(response);
        }
 public CreditCardResource(Guid merchantKey, PlatformEnvironment platformEnvironment, HttpContentTypeEnum httpContentType, Uri hostUri)
     : base(merchantKey, platformEnvironment, httpContentType, "/CreditCard", hostUri)
 {
 }
Ejemplo n.º 22
0
        /// <summary>
        /// Envio de HttpWebRequest
        /// </summary>
        /// <param name="dataToSend"></param>
        /// <param name="httpVerbEnum"></param>
        /// <param name="httpContentTypeEnum"></param>
        /// <param name="serviceEndpoint"></param>
        /// <param name="headerData"></param>
        /// <param name="allowInvalidCertificate"></param>
        /// <param name="ignoreResponse"></param>
        /// <returns></returns>
        public string SendHttpWebRequest(string dataToSend, HttpVerbEnum httpVerbEnum, HttpContentTypeEnum httpContentTypeEnum, string serviceEndpoint, NameValueCollection headerData, bool allowInvalidCertificate = false, bool ignoreResponse = false)
        {
            if (string.IsNullOrWhiteSpace(serviceEndpoint))
            {
                throw new ArgumentException("serviceEndpoint");
            }

            // Cria um objeto webRequest para referenciando a Url do serviço informado
            Uri serviceUri = new Uri(serviceEndpoint);

            HttpWebRequest httpWebRequest = WebRequest.Create(serviceUri) as HttpWebRequest;

            httpWebRequest.Method        = httpVerbEnum.ToString().ToUpper();
            httpWebRequest.ContentType   = httpContentTypeEnum == HttpContentTypeEnum.Json ? "application/json" : "text/xml";
            httpWebRequest.Accept        = httpContentTypeEnum == HttpContentTypeEnum.Json ? "application/json" : "text/xml";
            httpWebRequest.ContentLength = 0;

            // Verifica se certificados inválidos devem ser aceitos.
            ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) => allowInvalidCertificate);

            // Verifica se deverão ser enviados dados/chaves de cabeçalho
            if (headerData.Count > 0)
            {
                // Insere cada chave enviado no cabeçalho da requisição
                foreach (string key in headerData.Keys)
                {
                    httpWebRequest.Headers.Add(key, headerData[key].ToString());
                }
            }

            if (string.IsNullOrWhiteSpace(dataToSend) == false)
            {
                // Cria um array de bytes dos dados que serão postados
                byte[] byteData = UTF8Encoding.UTF8.GetBytes(dataToSend);

                // Configura o tamanho dos dados que serão enviados
                httpWebRequest.ContentLength = byteData.Length;

                // Escreve os dados na stream do WebRequest
                using (Stream stream = httpWebRequest.GetRequestStream())
                {
                    stream.Write(byteData, 0, byteData.Length);
                }
            }

            string returnString = string.Empty;

            try
            {
                // Dispara a requisição e recebe o resultado da mesma
                using (HttpWebResponse response = httpWebRequest.GetResponse() as HttpWebResponse)
                {
                    if (ignoreResponse == false)
                    {
                        // Recupera a stream com a resposta da solicitação
                        StreamReader streamReader = new StreamReader(response.GetResponseStream());
                        returnString = streamReader.ReadToEnd();
                    }
                }
            }
            catch (WebException ex)
            {
                throw ex;
            }

            return(returnString);
        }
Ejemplo n.º 23
0
        public HttpResponse <TResponse, TRequest> SubmitRequest <TRequest, TResponse>(TRequest request, string serviceUri, HttpVerbEnum httpVerb, HttpContentTypeEnum contentType, NameValueCollection header)
        {
            string    rawRequest     = this.SerializeObject <TRequest>(request, contentType);
            TResponse responseObject = this.DeserializeObject <TResponse>(MockRawResponse, contentType);
            HttpResponse <TResponse>           response_ = new HttpResponse <TResponse>(responseObject, MockRawResponse, System.Net.HttpStatusCode.Created);
            HttpResponse <TResponse, TRequest> response  = new HttpResponse <TResponse, TRequest>(request, rawRequest, responseObject, MockRawResponse, MockStatusCode);

            return(response);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// 发送Post请求(异步)
        /// </summary>
        /// <param name="url">url地址</param>
        /// <param name="data">参数</param>
        /// <param name="contentType">Content-Type</param>
        /// <param name="timeout">超时时间</param>
        /// <returns>返回值</returns>
        public static async Task <T> SendPostAsync <T>(string url, Dictionary <string, string> data = null, HttpContentTypeEnum contentType = HttpContentTypeEnum.ApplicationJson, int timeout = 100)
        {
            var resutlStr = await SendPostAsync(url, data, contentType, timeout);

            var model = resutlStr.MJsonToObject <T>();

            return(model);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Envio de HttpWebRequest
        /// </summary>
        /// <param name="dataToSend"></param>
        /// <param name="httpVerbEnum"></param>
        /// <param name="httpContentTypeEnum"></param>
        /// <param name="serviceEndpoint"></param>
        /// <param name="headerData"></param>
        /// <param name="allowInvalidCertificate"></param>
        /// <param name="ignoreResponse"></param>
        /// <returns></returns>
        private HttpResponse SendHttpWebRequest(string dataToSend, HttpVerbEnum httpVerbEnum, HttpContentTypeEnum httpContentTypeEnum, string serviceEndpoint, NameValueCollection headerData, bool allowInvalidCertificate = false)
        {
            if (string.IsNullOrWhiteSpace(serviceEndpoint))
            {
                throw new ArgumentException("serviceEndpoint");
            }

            // Cria um objeto webRequest para referenciando a Url do serviço informado
            Uri serviceUri = new Uri(serviceEndpoint);

            HttpWebRequest httpWebRequest = WebRequest.Create(serviceUri) as HttpWebRequest;

            httpWebRequest.Method      = httpVerbEnum.ToString().ToUpper();
            httpWebRequest.ContentType = httpContentTypeEnum == HttpContentTypeEnum.Json ? "application/json" : "text/xml";
            httpWebRequest.Accept      = httpContentTypeEnum == HttpContentTypeEnum.Json ? "application/json" : "text/xml";

            if (headerData != null && headerData.AllKeys.Contains("User-Agent") == true)
            {
                httpWebRequest.UserAgent = headerData["User-Agent"];
                headerData.Remove("User-Agent");
            }

            // Verifica se certificados inválidos devem ser aceitos.
            if (allowInvalidCertificate == true)
            {
                ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
            }

            // Verifica se deverão ser enviados dados/chaves de cabeçalho
            if (headerData != null && headerData.Count > 0)
            {
                // Insere cada chave enviado no cabeçalho da requisição
                foreach (string key in headerData.Keys)
                {
                    httpWebRequest.Headers.Add(key, headerData[key].ToString());
                }
            }

            if (string.IsNullOrWhiteSpace(dataToSend) == false)
            {
                // Cria um array de bytes dos dados que serão postados
                byte[] byteData = UTF8Encoding.UTF8.GetBytes(dataToSend);

                // Configura o tamanho dos dados que serão enviados
                httpWebRequest.ContentLength = byteData.Length;

                // Escreve os dados na stream do WebRequest
                using (Stream stream = httpWebRequest.GetRequestStream()) {
                    stream.Write(byteData, 0, byteData.Length);
                }
            }

            string         rawResponse = string.Empty;
            HttpStatusCode statusCode  = HttpStatusCode.OK;

            try {
                // Dispara a requisição e recebe o resultado da mesma
                using (HttpWebResponse response = httpWebRequest.GetResponse() as HttpWebResponse) {
                    // Recupera a stream com a resposta da solicitação
                    StreamReader streamReader = new StreamReader(response.GetResponseStream());
                    rawResponse = streamReader.ReadToEnd();
                    statusCode  = response.StatusCode;
                }
            }
            catch (WebException ex) {
                HttpWebResponse response = (HttpWebResponse)ex.Response;
                StreamReader    test     = new StreamReader(response.GetResponseStream());
                rawResponse = test.ReadToEnd();
                statusCode  = response.StatusCode;
            }

            return(new HttpResponse(rawResponse, statusCode));
        }
 public GatewayServiceClient(Guid merchantKey, PlatformEnvironment environment, HttpContentTypeEnum httpContentType) : this(merchantKey, environment, httpContentType, null)
 {
 }
 public CreditCardResource(Guid merchantKey, PlatformEnvironment platformEnvironment, HttpContentTypeEnum httpContentType) : base(merchantKey, platformEnvironment, httpContentType, "/CreditCard")
 {
 }
Ejemplo n.º 28
0
 public SaleResource(Guid merchantKey, PlatformEnvironment platformEnvironment, HttpContentTypeEnum httpContentType, Uri hostUri) : base(merchantKey, platformEnvironment, httpContentType, "/Sale", hostUri)
 {
 }
Ejemplo n.º 29
0
        /// <summary>
        /// Cria uma requisição http e retorna um objeto do tipo especificado em TResponse.
        /// </summary>
        /// <typeparam name="TResponse"></typeparam>
        /// <param name="httpVerbEnum"></param>
        /// <param name="serviceEndpoint"></param>
        /// <param name="headerData"></param>
        /// <param name="allowInvalidCertificate"></param>
        /// <param name="ignoreResponse"></param>
        /// <returns></returns>
        private HttpResponse <TResponse> SendHttpWebRequest <TResponse>(HttpVerbEnum httpVerbEnum, HttpContentTypeEnum httpContentType, string serviceEndpoint, NameValueCollection headerData = null)
        {
            // Se o header é nulo, instancia um novo.
            headerData = headerData ?? new NameValueCollection();

            // Envia o request.
            HttpResponse httpResponse = this.SendHttpWebRequest("", httpVerbEnum, httpContentType, serviceEndpoint, headerData);

            // Deserializa a resposta.
            TResponse responseObject = this.DeserializeObject <TResponse>(httpResponse.RawResponse, httpContentType);

            HttpResponse <TResponse> response = new HttpResponse <TResponse>(responseObject, httpResponse.RawResponse, httpResponse.HttpStatusCode);

            return(response);
        }
Ejemplo n.º 30
0
 protected BaseResource(Guid merchantKey, PlatformEnvironment platformEnvironment, HttpContentTypeEnum httpContentType, string resourceName)
     : this(merchantKey, platformEnvironment, httpContentType, resourceName, null)
 {
 }