Ejemplo n.º 1
0
        private string Request(ObjRequest request, string method)
        {
            string sJson    = JsonConvert.SerializeObject(request);
            string payload  = System.Convert.ToBase64String(Encoding.UTF8.GetBytes(sJson));
            string signatue = GetHexHashSignature(payload);
            string url      = ApiProperties.BaseBitfinexUrl + request.request;

            HttpWebRequest hwrRequest = (HttpWebRequest)WebRequest.Create(url);

            hwrRequest.Headers.Add(ApiProperties.ApiBfxApiKey, APIKey);
            hwrRequest.Headers.Add(ApiProperties.ApiBfxPayload, payload);
            hwrRequest.Headers.Add(ApiProperties.ApiBfxSignature, signatue);
            hwrRequest.Method = method;

            string response = null;

            try
            {
                HttpWebResponse hwrResponse = (HttpWebResponse)hwrRequest.GetResponse();
                StreamReader    stream      = new StreamReader(hwrResponse.GetResponseStream());
                response = stream.ReadToEnd();
                stream.Close();
            }
            catch (WebException ex)
            {
                ex.ToOutput();
                StreamReader stream = new StreamReader(ex.Response.GetResponseStream());
                response = stream.ReadToEnd();
                stream.Close();
            }

            return(response);
        }
Ejemplo n.º 2
0
        private string RestRequest(ObjRequest request)
        {
            var client   = this.GetRestClient(request);
            var response = this.GetRestResponse(client, request);

            return(response.Content);
        }
Ejemplo n.º 3
0
        private RestClient GetRestClient(ObjRequest request)
        {
            RestClient client = new RestClient();
            string     url    = ApiProperties.BaseBitfinexUrl + request.request;

            client.BaseUrl = new Uri(url);

            return(client);
        }