Example #1
0
        /// <summary>
        /// Makes an async web request
        /// </summary>
        /// <param name="method">HTTP Method (i.e., GET, POST, DEL, PATCH)</param>
        /// <param name="endpoint">String value endpoint path</param>
        /// <param name="queries">String value of queries</param>
        /// <returns></returns>
        internal async Task <HttpResponseMessage> RequestAsync(
            EHostAPIType hostType,
            HttpMethod method,
            string endpoint,
            string queries  = null,
            string jsonBody = null
            )
        {
            UriBuilder uri = new UriBuilder()
            {
                Scheme = Uri.UriSchemeHttps,
                Host   = SelectHost(hostType),
                Path   = string.Format("/{0}/{1}", FXVersion, endpoint),
                Query  = queries ?? null
            };

            HttpRequestMessage req = new HttpRequestMessage()
            {
                Method     = method,
                RequestUri = new Uri(uri.Uri.AbsoluteUri),
                Content    = jsonBody != null ? new StringContent(jsonBody, Encoding.UTF8, "application/json") : null
            };

            return(await Client.SendAsync(req, HttpCompletionOption.ResponseHeadersRead));
        }
Example #2
0
        private string SelectHost(EHostAPIType hostAPI)
        {
            switch (hostAPI)
            {
            case EHostAPIType.REST:
                return(FXPracticeHost);

            case EHostAPIType.STREAM:
                return(FXStreamPracticeHost);

            default:
                return(FXPracticeHost);
            }
        }