public string ToQueryString() { var queryParams = GetByIdOrName(RoomId, string.Empty); queryParams.Add("since", Since.ToString(QueryHelper.DATE_FORMAT)); if (Offset.HasValue) { queryParams.Add("offset", Offset.Value.ToString()); } if (Count.HasValue) { queryParams.Add("count", Count.Value.ToString()); } return(QueryHelper.DicToQuerystring(queryParams)); }
public override string ToString() { return(String.Format("{0}: {1}-{2}, {3} records.", Name, Since.ToString("yyyyMMdd"), Until.ToString("yyyyMMdd"), Count)); }
/// <summary> /// appends parameters for Search request /// </summary> /// <param name="parameters">list of parameters from expression tree</param> /// <param name="url">base url</param> /// <returns>base url + parameters</returns> private string BuildSearchUrlParameters(Dictionary <string, string> parameters, string url) { var urlParams = new List <string>(); if (parameters.ContainsKey("GeoCode")) { GeoCode = parameters["GeoCode"]; urlParams.Add("geocode=" + HttpUtility.UrlEncode(parameters["GeoCode"])); } if (parameters.ContainsKey("SearchLanguage")) { SearchLanguage = parameters["SearchLanguage"]; urlParams.Add("lang=" + parameters["SearchLanguage"]); } if (parameters.ContainsKey("Locale")) { Locale = parameters["Locale"]; urlParams.Add("locale=" + parameters["Locale"]); } if (parameters.ContainsKey("Page")) { Page = int.Parse(parameters["Page"]); urlParams.Add("page=" + parameters["Page"]); } if (parameters.ContainsKey("PageSize")) { PageSize = int.Parse(parameters["PageSize"]); urlParams.Add("rpp=" + parameters["PageSize"]); } if (parameters.ContainsKey("Query")) { Query = parameters["Query"]; if (Query.Length > 140) { throw new ArgumentException("Query length must be 140 characters or less.", "Query"); } urlParams.Add("q=" + HttpUtility.UrlEncode(parameters["Query"])); } if (parameters.ContainsKey("ShowUser")) { ShowUser = bool.Parse(parameters["ShowUser"]); if (ShowUser) { urlParams.Add("show_user="******"ShowUser"]); } } if (parameters.ContainsKey("Since")) { Since = DateTime.Parse(parameters["Since"]); urlParams.Add("since=" + Since.ToString("yyyy-MM-dd")); } if (parameters.ContainsKey("Until")) { Until = DateTime.Parse(parameters["Until"]); urlParams.Add("until=" + Until.ToString("yyyy-MM-dd")); } if (parameters.ContainsKey("SinceID")) { SinceID = ulong.Parse(parameters["SinceID"]); urlParams.Add("since_id=" + parameters["SinceID"]); } if (parameters.ContainsKey("MaxID")) { MaxID = ulong.Parse(parameters["MaxID"]); urlParams.Add("max_id=" + parameters["MaxID"]); } if (parameters.ContainsKey("ResultType")) { ResultType = RequestProcessorHelper.ParseQueryEnumType <ResultType>(parameters["ResultType"]); urlParams.Add("result_type=" + ResultType.ToString()); } if (parameters.ContainsKey("WordPhrase")) { WordPhrase = parameters["WordPhrase"]; urlParams.Add("exact=" + HttpUtility.UrlEncode(parameters["WordPhrase"])); } if (parameters.ContainsKey("WordAnd")) { WordAnd = parameters["WordAnd"]; urlParams.Add("ands=" + HttpUtility.UrlEncode(parameters["WordAnd"])); } if (parameters.ContainsKey("WordOr")) { WordOr = parameters["WordOr"]; urlParams.Add("ors=" + HttpUtility.UrlEncode(parameters["WordOr"])); } if (parameters.ContainsKey("WordNot")) { WordNot = parameters["WordNot"]; urlParams.Add("nots=" + HttpUtility.UrlEncode(parameters["WordNot"])); } if (parameters.ContainsKey("Hashtag")) { Hashtag = parameters["Hashtag"]; urlParams.Add("tag=" + HttpUtility.UrlEncode(parameters["Hashtag"])); } if (parameters.ContainsKey("PersonFrom")) { PersonFrom = parameters["PersonFrom"]; urlParams.Add("from=" + HttpUtility.UrlEncode(parameters["PersonFrom"])); } if (parameters.ContainsKey("PersonTo")) { PersonTo = parameters["PersonTo"]; urlParams.Add("to=" + HttpUtility.UrlEncode(parameters["PersonTo"])); } if (parameters.ContainsKey("PersonReference")) { PersonReference = parameters["PersonReference"]; urlParams.Add("ref=" + HttpUtility.UrlEncode(parameters["PersonReference"])); } if (parameters.ContainsKey("Attitude")) { Attitude = RequestProcessorHelper.ParseQueryEnumType <Attitude>(parameters["Attitude"]); if ((Attitude & Attitude.Positive) == Attitude.Positive) { urlParams.Add("tude%5B%5D=%3A%29"); } if ((Attitude & Attitude.Negative) == Attitude.Negative) { urlParams.Add("tude%5B%5D=%3A%28"); } if ((Attitude & Attitude.Question) == Attitude.Question) { urlParams.Add("tude%5B%5D=%3F"); } } if (parameters.ContainsKey("WithLinks")) { WithLinks = bool.Parse(parameters["WithLinks"]); if (WithLinks) { urlParams.Add("filter%5B%5D=links"); } } if (parameters.ContainsKey("WithRetweets")) { WithRetweets = bool.Parse(parameters["WithRetweets"]); if (WithRetweets) { urlParams.Add("include%5B%5D=retweets"); } } if (urlParams.Count > 0) { url += "?" + string.Join("&", urlParams.ToArray()); } return(url); }
public override string ToString() { return(String.Format("{0}-{1}: {2} records.", Since.ToString("yyyy"), Until.ToString("yyyy"), Count)); }