Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new instance of a Glossary API client.
        /// </summary>
        public GlossaryAPIClient()
        {
            string apiUrl = WebAPISection.GetAPIUrl();

            HttpClient client = new HttpClient();

            //NOTE: the base URL MUST have a trailing slash
            client.BaseAddress = new Uri(apiUrl);

            this._client = client;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets an instance of a BestBetsAPI client
        /// </summary>
        /// <returns></returns>
        public static BestBetsAPIClient GetClientInstance()
        {
            string baseApiPath = WebAPISection.GetAPIUrl();
            string appPath     = ConfigurationManager.AppSettings["BestBetsAPIAppPath"];
            string versionPath = ConfigurationManager.AppSettings["BestBetsAPIVersionPath"];

            if (string.IsNullOrWhiteSpace(appPath))
            {
                throw new ConfigurationErrorsException("error: BestBetsAPIAppPath cannot be null or empty");
            }

            if (string.IsNullOrWhiteSpace(versionPath))
            {
                throw new ConfigurationErrorsException("error: BestBetsAPIVersionPath cannot be null or empty");
            }

            HttpClient client = new HttpClient();

            //NOTE: the base URL MUST have a trailing slash
            client.BaseAddress = new Uri(String.Format("{0}/{1}/{2}/", baseApiPath, appPath, versionPath));

            return(new BestBetsAPIClient(client));
        }