private static JudoPayApi Create(Credentials credentials, string baseUrl)
        {
            var apiVersion = ConfigurationManager.AppSettings["ApiVersion"];

            var httpClient = new HttpClientWrapper(new AuthorizationHandler(credentials,
                                                                            DotNetLoggerFactory.Create(typeof(AuthorizationHandler))),
                                                   new VersioningHandler(Apiversionheader, apiVersion));
            var connection = new Connection(httpClient,
                                            DotNetLoggerFactory.Create,
                                            baseUrl);
            var client = new Client(connection);

            return(new JudoPayApi(DotNetLoggerFactory.Create, client));
        }
        /// <summary>
        /// Factory method for the benefit of platform tests that need to have finer grained control of the API version
        /// </summary>
        /// <param name="credentials">The api token and secret to use</param>
        /// <param name="baseUrl">Base URL for the host</param>
        /// <param name="apiVersion">The api version to use</param>
        /// <param name="userAgent">User-Agent details to set in the header for each request</param>
        /// <returns>Initialized instance of the Judopay api client</returns>
        internal static JudoPayApi Create(Credentials credentials, string baseUrl, string apiVersion, ProductInfoHeaderValue userAgent)
        {
            var userAgentCollection = new List <ProductInfoHeaderValue>();

            userAgentCollection.Add(new ProductInfoHeaderValue("DotNetCLR", Environment.Version.ToString()));
            userAgentCollection.Add(new ProductInfoHeaderValue(Environment.OSVersion.Platform.ToString(), Environment.OSVersion.Version.ToString()));
            if (userAgent != null)
            {
                userAgentCollection.Add(userAgent);
            }
            var httpClient = new HttpClientWrapper(
                userAgentCollection,
                new AuthorizationHandler(credentials, DotNetLoggerFactory.Create(typeof(AuthorizationHandler))),
                new VersioningHandler(apiVersion));

            var connection = new Connection(httpClient, DotNetLoggerFactory.Create, baseUrl);
            var client     = new Client(connection);

            return(new JudoPayApi(DotNetLoggerFactory.Create, client));
        }