/***************************************************/
        /****           Public Methods                  ****/
        /***************************************************/
        public static string ToRequestBody(this PremiumSearchParameters searchParameters)
        {
            string body = "{";

            if (searchParameters.FromDate != "")
            {
                body += "\"fromDate\":\"" + searchParameters.FromDate + "\",";
            }
            if (searchParameters.ToDate != "")
            {
                body += "\"toDate\":\"" + searchParameters.ToDate + "\",";
            }
            if (searchParameters.Tag != "")
            {
                body += "\"tag\":\"" + searchParameters.Tag + "\",";
            }
            if (searchParameters.Next != "")
            {
                body += "\"next\":\"" + searchParameters.Next + "\",";
            }
            body += "\"query\":\"" + searchParameters.Query + "\",";
            body += "\"maxResults\":" + searchParameters.MaxResults;
            body += "}";
            return(body);
        }
Beispiel #2
0
        /***************************************************/
        private static string SearchPremium(Application application, string endpoint, PremiumSearchParameters searchParameters)
        {
            System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
            RestClient  client  = new RestClient(endpoint);
            RestRequest request = new RestRequest(Method.POST);

            request.RequestFormat = DataFormat.Json;
            request.AddParameter("application/json", searchParameters.ToRequestBody(), ParameterType.RequestBody);
            request.AddParameter("Authorization", "Bearer " + application.BearerToken, ParameterType.HttpHeader);
            IRestResponse response = client.Execute(request);

            return(response.ToResults("results"));
        }
Beispiel #3
0
 /***************************************************/
 /****           Public Methods                  ****/
 /***************************************************/
 public static TweetResults SearchTweets(Application application, string endpoint, PremiumSearchParameters searchParameters)
 {
     return(new TweetResults()
     {
         Results = serialiser.Convert.FromJson(SearchPremium(application, endpoint, searchParameters)) as CustomObject
     });
 }