Пример #1
0
        public void fetchSummary()
        {
            string[] classNames =
            {
                "Private::Searchable",
                "Private::Crm::Person",
                "Private::Crm::Organisation",
                "Private::Crm::Case"
            };

            Dictionary <string, object> classMetaData = new Dictionary <string, object> ();

            classMetaData.Add("class_names[]", classNames);
            classMetaData.Add("_select_columns[]", columns);

            try {
                WorkbooksApiResponse response = workbooks.assertGet("metadata/types", classMetaData, null);

                workbooks.log("fetchSummary Total: ", new Object[] { response.getTotal() });
                //      if (response.getTotal() != null && response.getTotal() > 0) {
                //        workbooks.log("fetchSummary First: ", new Object[] {response.getFirstData()});
                //      }
            } catch (Exception e) {
                Console.WriteLine("Error while getting the metadata: " + e.Message);
                Console.WriteLine(e.StackTrace);
                login.testExit(workbooks, 1);
            }
        }
Пример #2
0
    private void getOrganisations()
    {
        String[] columns = { "id",
                             "lock_version",
                             "name",
                             "object_ref",
                             "main_location[town]",
                             "updated_at",
                             "updated_by_user[person_name]" };
        Dictionary <string, object> filter_limit_select = new Dictionary <string, object> ();

        filter_limit_select.Add("_start", "0");                                   // Starting from the 'zeroth' record
        filter_limit_select.Add("_limit", "100");                                 //   fetch up to 100 records
        filter_limit_select.Add("_sort", "id");                                   // Sort by 'id'
        filter_limit_select.Add("_dir", "ASC");                                   //   in ascending order
        filter_limit_select.Add("_ff[]", "main_location[county_province_state]"); // Filter by this column
        filter_limit_select.Add("_ft[]", "ct");                                   //   containing
        filter_limit_select.Add("_fc[]", "Berkshire");                            //   'Berkshire'
        filter_limit_select.Add("_select_columns[]", columns);                    // An array, of columns to select
        try {
            WorkbooksApiResponse response = workbooks.assertGet("crm/organisations", filter_limit_select, null);
            workbooks.log("Total organisations: ", new Object[] { response.getTotal() });
            workbooks.log("First Organisation: ", new object[] { response.print(response.getFirstData()) });
        } catch (Exception e) {
            Console.WriteLine(e.StackTrace);
        }
    }
Пример #3
0
        /*
         * Attempt to fetch an item which does not exist
         */
        public void getNonExistenceAPIData()
        {
            Dictionary <string, object> filter3 = new Dictionary <string, object> ();

            //Merge the limit_select and then add array of arrays
            filter3.Add("_sort", "id");
            filter3.Add("_dir", "ASC");
            filter3.Add("_ff[]", "key");
            filter3.Add("_ft[]", "eq");
            filter3.Add("_fc[]", "api_data_example: no such record exists");

            try {
                WorkbooksApiResponse response = workbooks.assertGet("automation/api_data", filter3, null);

                if (response.getTotal() != 0)
                {
                    workbooks.log("Bad response for non-existent item");
                    login.testExit(workbooks, 1);
                }
            } catch (Exception e) {
                workbooks.log("Error while getting the apiData:", new Object[] { e });
                Console.WriteLine(e.StackTrace);
                login.testExit(workbooks, 1);
            }
        }
Пример #4
0
        /*
         * Fetch four of them back, all available fields
         */
        public void getAPIData()
        {
            Dictionary <string, object> filter3 = new Dictionary <string, object> ();

            //Merge the limit_select and then add array of arrays
            filter3.Add("_sort", "id");
            filter3.Add("_dir", "ASC");
            filter3.Add("_ff[]", new String[] { "key", "key", "key", "key" });
            filter3.Add("_ft[]", new String[] { "eq", "eq", "eq", "eq" });
            filter3.Add("_fc[]", new String[] { "api_data_example: the answer",
                                                "api_data_example: null",
                                                "api_data_example: ten thousand characters",
                                                "api_data_example: multibyte characters" });
            filter3.Add("_fm", "or");

            try {
                WorkbooksApiResponse response = workbooks.assertGet("automation/api_data", filter3, null);

                workbooks.log("getAPIData Total fetched", new Object[] { response.getTotal() });
                workbooks.log("getAPIData First Data", new Object[] { response.getFirstData() });
            } catch (Exception e) {
                workbooks.log("Error while getting the apiData:", new Object[] { e });
                Console.WriteLine(e.StackTrace);
                login.testExit(workbooks, 1);
            }
        }
Пример #5
0
        /// <summary>
        /// Gets the people based on the filters given
        /// </summary>
        public void getPeople()
        {
            Dictionary <string, object> filter_limit_select = new Dictionary <string, object> ();

            filter_limit_select.Add("_start", "0");
            filter_limit_select.Add("_limit", "3");
            filter_limit_select.Add("_sort", "id");
            filter_limit_select.Add("_dir", "ASC");
            filter_limit_select.Add("_ff[]", "name");
            filter_limit_select.Add("_ft[]", "bg");
            filter_limit_select.Add("_fc[]", "Alex");
            filter_limit_select.Add("_select_columns[]", columns);
            try {
                WorkbooksApiResponse response = workbooks.get("crm/people", filter_limit_select, null);
                object[]             allData  = response.getData();
                if (allData != null)
                {
                    Console.WriteLine("Response Total: " + response.getTotal());

                    for (int i = 0; i < allData.Length; i++)
                    {
                        Dictionary <string, object> data = (Dictionary <string, object>)allData[i];
                        Console.WriteLine("Person name: " + data["name"] + " Object Ref: " + data["object_ref"]);
                    }
                }
            } catch (Exception wbe) {
                Console.WriteLine("Error while getting the people record: " + wbe.Message);
                Console.WriteLine("Stacktrace: " + wbe);
                testLoginHelper.testExit(workbooks, 1);
            }
        }
Пример #6
0
        // First filter structure: specify arrays for Fields ('_ff[]'), comparaTors ('_ft[]'), Contents ('_fc[]').
        // Note that 'ct' (contains) is MUCH slower than equals. 'not_blank' requires Contents to compare with, but this is ignored.

        public WorkbooksApiResponse  getOrganisationsViaFilter()
        {
            Dictionary <string, object> filter3 = new Dictionary <string, object> ();

            //Merge the limit_select and then add array of arrays
            foreach (string limitKey in limit_select.Keys)
            {
                filter3.Add(limitKey, limit_select [limitKey]);
            }
            filter3.Add("_ff[]", new String[] { "main_location[county_province_state]", "main_location[county_province_state]", "main_location[street_address]" });
            filter3.Add("_ft[]", new String[] { "eq", "ct", "not_blank" });
            filter3.Add("_fc[]", new String[] { "Berkshire", "Yorkshire", "" });

            filter3.Add("_fm", "(1 OR 2) AND 3");                // How to combine the above clauses, without this: 'AND'.
            try {
                WorkbooksApiResponse response3 = workbooks.assertGet("crm/organisations", filter3, null);

                //workbooks.log("getOrganisationsViaFilter First ", new Object[] {response3.getFirstData()});
                Console.WriteLine("Total: " + response3.getTotal());
                object[] allData = response3.getData();
                for (int i = 0; i < allData.Length; i++)
                {
                    Dictionary <string, object> data = (Dictionary <string, object>)allData[i];
                    Console.WriteLine(i + ") " + data["name"] + " - " + data["main_location[county_province_state]"]);
                }
                return(response3);
            } catch (Exception wbe) {
                Console.WriteLine("Error while getting the Organisations record: " + wbe);
                Console.WriteLine(wbe.StackTrace);
                login.testExit(workbooks, 1);
            }
            return(null);
        }
Пример #7
0
        public void fetchAll()
        {
            Dictionary <string, object> classMetaData = new Dictionary <string, object> ();

            try {
                WorkbooksApiResponse response = workbooks.assertGet("metadata/types", classMetaData, null);

                workbooks.log("fetchAll Total: ", new Object[] { response.getTotal() });
                //      if (response.getTotal() > 0) {
                //        workbooks.log("fetchAll First: ", new Object[] {response.getFirstData()});
                //      }
            } catch (Exception e) {
                Console.WriteLine("Error while getting the metadata: " + e.Message);
                Console.WriteLine((e.StackTrace));
                login.testExit(workbooks, 1);
            }
        }
Пример #8
0
        /*
         * Fetch a single item using the alternate filter syntax
         */
        public void getSingleAPIData()
        {
            Dictionary <string, object> filter3 = new Dictionary <string, object> ();

            filter3.Add("_filter_json", "[['key', 'eq', 'api_data_example: poppins']]");

            try {
                WorkbooksApiResponse response = workbooks.assertGet("automation/api_data", filter3, null);

                workbooks.log("getAPIData Total fetched", new Object[] { response.getTotal() });
                workbooks.log("getAPIData First Data", new Object[] { response.getFirstData() });
            } catch (Exception e) {
                workbooks.log("Error while getting the apiData:", new Object[] { e });
                Console.WriteLine(e.StackTrace);
                login.testExit(workbooks, 1);
            }
        }
Пример #9
0
        public void fetchSomeMoreSummary()
        {
            string[] classNames =
            {
                "Private::Crm::Case"
            };

            string[] addColumns = { "id",
                                    "lock_version",
                                    "class_name",
                                    "base_class_name",
                                    "human_class_name",
                                    "human_class_name_plural",
                                    "human_class_description",
                                    "instances_described_by",
                                    "icon",
                                    "help_url",
                                    "controller_path",
                                    "fields",
                                    "associations" };


            Dictionary <string, object> classMetaData = new Dictionary <string, object> ();

            classMetaData.Add("class_names[]", classNames);
            classMetaData.Add("_select_columns[]", addColumns);

            try {
                WorkbooksApiResponse response = workbooks.assertGet("metadata/types", classMetaData, null);

                workbooks.log("fetchSomeMoreSummary Total: ", new Object[] { response.getTotal() });
                //      if (response.getTotal() != null && response.getTotal() > 0) {
                //        workbooks.log("fetchSomeMoreSummary First: ", new Object[] {response.getFirstData()});
                //      }
            } catch (Exception e) {
                Console.WriteLine("Error while getting the metadata: " + e.Message);
                Console.WriteLine((e.StackTrace));
                login.testExit(workbooks, 1);
            }
        }
Пример #10
0
        // The equivalent using a second filter structure: a JSON-formatted string  array of arrays containg 'field, comparator, contents'
        public WorkbooksApiResponse getOrganisationsViaFilterJson()
        {
            Dictionary <string, object> filter3 = new Dictionary <string, object> ();

            /*
             * Syntax to create array of arrays is
             * 1) [[a, b, c], [x,y,z], [1,2,3]]; Note the two square brackets
             * 2) new String[][] {new string[]{a,b,c}, new string[] {x,y,z},new string[] {1,2,3}} see the above method for this syntax
             */
            //Merge the limit_select and then add array of arrays
            foreach (string limitKey in limit_select.Keys)
            {
                filter3.Add(limitKey, limit_select [limitKey]);
            }
            filter3.Add("_filter_json", "[" +
                        "['main_location[county_province_state]', 'eq', 'Berkshire']," +
                        "['main_location[county_province_state]', 'ct', 'Yorkshire']," +
                        "['main_location[street_address]', 'not_blank', '']" +
                        "]");
            filter3.Add("_fm", "(1 OR 2) AND 3");

            try{
                WorkbooksApiResponse response3 = workbooks.assertGet("crm/organisations", filter3, null);

                //workbooks.log("getOrganisationsViaFilterJson First: ", new Object[] {response3.getFirstData()});
                Console.WriteLine("Total: " + response3.getTotal());
                object[] allData = response3.getData();
                for (int i = 0; i < allData.Length; i++)
                {
                    Dictionary <string, object> data = (Dictionary <string, object>)allData[i];
                    Console.WriteLine(i + ") " + data["name"] + " - " + data["main_location[county_province_state]"]);
                }
                return(response3);
            } catch (Exception wbe) {
                Console.WriteLine("Error while getting the organisations record: " + wbe.Message);
                Console.WriteLine(wbe.StackTrace);
                login.testExit(workbooks, 1);
            }
            return(null);
        }
Пример #11
0
        // The equivalent using a third filter structure: an array of filters, each containg 'field, comparator, contents'.

        public WorkbooksApiResponse  getOrganisationsViaFilterArray()
        {
            Dictionary <string, object> filter3 = new Dictionary <string, object> ();

            /*			 Merge the limit_select and then add array of arrays
             * Syntax to create array of arrays is
             * 1) [[a, b, c], [x,y,z], [1,2,3]]; Note the two square brackets . See below method for example
             * 2) new String[][] {new string[]{a,b,c}, new string[] {x,y,z},new string[] {1,2,3}}
             */
            //Merge the limit_select and then add array of arrays
            foreach (string limitKey in limit_select.Keys)
            {
                filter3.Add(limitKey, limit_select [limitKey]);
            }
            filter3.Add("_filters[]", new String[][] {
                new string[] { "main_location[county_province_state]", "eq", "Berkshire" },
                new string[] { "main_location[county_province_state]", "ct", "Yorkshire" },
                new string[] { "main_location[street_address]", "not_blank", "" }
            });
            filter3.Add("_fm", "(1 OR 2) AND 3");                // How to combine the above clauses, without this: 'AND'.
            try {
                WorkbooksApiResponse response3 = workbooks.assertGet("crm/organisations", filter3, null);
                Console.WriteLine("Total: " + response3.getTotal());
                //workbooks.log("getOrganisationsViaFilterArray First: ", new Object[] {response3.getFirstData()});

                object[] allData = response3.getData();
                for (int i = 0; i < allData.Length; i++)
                {
                    Dictionary <string, object> data = (Dictionary <string, object>)allData[i];
                    Console.WriteLine(i + ") " + data["name"] + " - " + data["main_location[county_province_state]"]);
                }
                return(response3);
            } catch (Exception wbe) {
                Console.WriteLine("Error while getting the organisations record: " + wbe.Message);
                Console.WriteLine(wbe.StackTrace);
                login.testExit(workbooks, 1);
            }
            return(null);
        }