private void Initialize(string baseUrl, bool useSsl, string apiKey) { if (string.IsNullOrWhiteSpace(baseUrl)) { throw new ArgumentException("baseUrl"); } if (string.IsNullOrWhiteSpace(apiKey)) { throw new ArgumentException("apiKey"); } ApiKey = apiKey; // Cleanup the provided url so that we don't get any issues when we are configuring the client if (baseUrl.StartsWith("http://", StringComparison.OrdinalIgnoreCase)) { baseUrl = baseUrl.Substring("http://".Length); } else if (baseUrl.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) { baseUrl = baseUrl.Substring("https://".Length); } string httpScheme = useSsl ? "https" : "http"; _client = new RestClient(new Uri(string.Format("{0}://{1}/{2}/", httpScheme, baseUrl, ApiVersion)), _serializer, WebProxy); _client.AddDefaultQueryString("api_key", apiKey); }
private void Initialize(string baseUrl, bool useSsl, string apiKey) { if (string.IsNullOrWhiteSpace(baseUrl)) throw new ArgumentException("baseUrl"); if (string.IsNullOrWhiteSpace(apiKey)) throw new ArgumentException("apiKey"); ApiKey = apiKey; // Cleanup the provided url so that we don't get any issues when we are configuring the client if (baseUrl.StartsWith("http://", StringComparison.InvariantCultureIgnoreCase)) baseUrl = baseUrl.Substring("http://".Length); else if (baseUrl.StartsWith("https://", StringComparison.InvariantCultureIgnoreCase)) baseUrl = baseUrl.Substring("https://".Length); string httpScheme = useSsl ? "https" : "http"; _client = new RestClient(new Uri(string.Format("{0}://{1}/{2}/", httpScheme, baseUrl, ApiVersion))); _client.AddDefaultQueryString("api_key", apiKey); }