Exemple #1
0
        private HttpRequestBuilder BuildRequest(string mode, SabnzbdSettings settings)
        {
            var baseUrl = string.Format(@"{0}://{1}:{2}/api",
                                        settings.UseSsl ? "https" : "http",
                                        settings.Host,
                                        settings.Port);

            var requestBuilder = new HttpRequestBuilder(baseUrl)
                                 .Accept(HttpAccept.Json)
                                 .AddQueryParam("mode", mode);

            requestBuilder.LogResponseContent = true;

            if (settings.ApiKey.IsNotNullOrWhiteSpace())
            {
                requestBuilder.AddSuffixQueryParam("apikey", settings.ApiKey);
            }
            else
            {
                requestBuilder.AddSuffixQueryParam("ma_username", settings.Username);
                requestBuilder.AddSuffixQueryParam("ma_password", settings.Password);
            }
            requestBuilder.AddSuffixQueryParam("output", "json");

            return(requestBuilder);
        }