Query() public method

Call any Keen.IO API function with the specified parameters. Refer to Keen API documentation for details of request parameters and return type. Return type may be cast as dynamic.
public Query ( string queryName, string>.Dictionary parms ) : Newtonsoft.Json.Linq.JObject
queryName string Query name, e.g., KeenConstants.QueryCount
parms string>.Dictionary Parameters for query, API keys are not required here.
return Newtonsoft.Json.Linq.JObject
Exemplo n.º 1
0
        static void Main (string[] args)
        {
            // Loading Keen.IO Keys and Misc. from Config File
            _keenIOProjectID = ConfigurationManager.AppSettings["keenIOProjectID"];
            _keenIOMasterKey = ConfigurationManager.AppSettings["keenIOMasterKey"];
            _keenIOWriteKey  = ConfigurationManager.AppSettings["keenIOWriteKey"];
            _keenIOReadKey   = ConfigurationManager.AppSettings["keenIOReadKey"];
            _bucketName      = ConfigurationManager.AppSettings["keenIOBucketName"];
            
            // Creating Keen.IO Variables - Yes, i am setting my read key as the master key, so that you can read the bucket I have created with data
            var projectSettings = new ProjectSettingsProvider (_keenIOProjectID,masterKey:_keenIOReadKey);
            var keenClient      = new KeenClient (projectSettings);


            /*********************************************************************
             *          EXECUTING SIMPLE ANALYTICS QUERIES ON KEEN.IO 
             **********************************************************************/

            // Query 1 - Average App Price grouped by Category
            Dictionary<String,String> parameters = new Dictionary<String,String>();
            parameters.Add ("event_collection", "PlayStore2014");
            parameters.Add ("target_property", "Price");
            parameters.Add ("group_by", "Category");

            JObject keenResponse = keenClient.Query (KeenConstants.QueryAverage, parameters);

            PrintQueryTitle ("Query 1 - Average App Price grouped by Category");
            Console.WriteLine (keenResponse.ToSafeString ());
            PrintSeparator ();

            // Query 2 - Most Expensive app for sale of each category
            keenResponse = keenClient.Query (KeenConstants.QueryMaximum, parameters);

            PrintQueryTitle ("Query 2 - Most Expensive app for sale of each category");
            Console.WriteLine (keenResponse.ToSafeString ());
            PrintSeparator ();
            
            // Query 3 - Most Expensive App for sale of all (without group by)
            parameters.Remove ("group_by");
            keenResponse = keenClient.Query (KeenConstants.QueryMaximum, parameters);

            PrintQueryTitle ("Query 3 - Most Expensive App for sale of all (without group by)");
            Console.WriteLine (keenResponse.ToSafeString ());
            PrintSeparator ();

            Console.ReadKey ();

        }
Exemplo n.º 2
0
        public void ReadKeyOnly_Success()
        {
            var settings = new ProjectSettingsProvider(SettingsEnv.ProjectId, readKey: SettingsEnv.ReadKey); 
            var client = new KeenClient(settings);

            if (!UseMocks)
            {
                // Server is required for this test
                // Also, test depends on existance of collection "AddEventTest"
                Assert.DoesNotThrow(() => client.Query(QueryType.Count(), "AddEventTest", ""));
            }
        }