/// <summary> /// Get Uri for post operations /// </summary> /// <param name="cgi">CGI path handling the request</param> /// <param name="api">API name handling the request</param> /// <param name="version">Version of the api</param> /// <param name="method">Method of the API</param> /// <returns>The Uri object where the request has to be sent</returns> private Uri GetPostApiUrl(string cgi, string api, int version, string method) { var url = new QueryStringManager(cgi); url.AddParameters(new[] { new QueryStringParameter("_sid", Sid), }); return(new Uri(new Uri(_client.BaseAddress), url.ToString())); }
public void QueryStringManagerArrayTest() { var manager = new QueryStringManager("http://test.com"); manager.AddParameter(new QueryStringParameter("arrayParam", new string[] { "testString1", "testString2" })); var result = manager.ToString(); Assert.AreEqual("http://test.com?arrayParam=testString1,testString2", result, "The QueryStringManager object does not processed the string array correctly"); }
/// <summary> /// Get Uri for post operations /// </summary> /// <param name="connection"></param> /// <param name="cgi">CGI path handling the request</param> /// <param name="api">API name handling the request</param> /// <param name="version">Version of the api</param> /// <param name="method">Method of the API</param> /// <returns>The Uri object where the request has to be sent</returns> private static Uri PostApiUrl(this ISynologyConnection connection, string cgi, string api, int version, string method) { var url = new QueryStringManager(cgi); url.AddParameters(new[] { new QueryStringParameter("_sid", connection.GetSid()), }); var res = url.ToString(); connection.Logger.LogDebug($"Created API Url for POST: {res}"); return(new Uri(connection.Client.BaseAddress, res)); }
/// <summary> /// Get Uri for post operations /// </summary> /// <param name="cgi">CGI path handling the request</param> /// <param name="api">API name handling the request</param> /// <param name="version">Version of the api</param> /// <param name="method">Method of the API</param> /// <returns>The Uri object where the request has to be sent</returns> private Uri PostApiUrl(string cgi, string api, int version, string method) { var url = new QueryStringManager(cgi); url.AddParameters(new[] { new QueryStringParameter("_sid", Sid), }); var res = url.ToString(); Logger.LogDebug($"Created API Url for POST: {res}"); return(new Uri(_client.BaseAddress, res)); }
private string GetApiUrl(string cgi, string api, int version, string method, QueryStringParameter[] additionalParams = null) { var url = new QueryStringManager(cgi); additionalParams = additionalParams ?? new QueryStringParameter[] { }; url.AddParameters(additionalParams.Concat(new[] { new QueryStringParameter("_sid", Sid), new QueryStringParameter("api", api), new QueryStringParameter("version", version), new QueryStringParameter("method", method) })); return(url.ToString()); }
private string GetApiUrl(string cgi, string api, int version, string method, QueryStringParameter[] additionalParams = null) { var url = new QueryStringManager(cgi); additionalParams = additionalParams ?? new QueryStringParameter[] { }; url.AddParameters(additionalParams.Concat(new[] { new QueryStringParameter("_sid", Sid), new QueryStringParameter("api", api), new QueryStringParameter("version", version), new QueryStringParameter("method", method) }).Where(t => t.MinVersion <= version)); var res = url.ToString(); Logger.LogDebug($"Created API Url for GET: {res}"); return(res); }