Exemple #1
0
        public void createAPIData()
        {
            Dictionary <string, object> testValues = new Dictionary <string, object> ();

            testValues.Add("the answer", 42);
            testValues.Add("poppins", "Supercalifragilisticexpealidocious");
            testValues.Add("null", null);
            testValues.Add("ten thousand characters", repeat("123456789", 1000));
            testValues.Add("multibyte_characters", " 'д е ё ж з и й к л  字 字");

            Dictionary <string, object> apiData = null;

            List <Dictionary <string, object> > apiDataList = new List <Dictionary <string, object> >();

            foreach (string key in testValues.Keys)
            {
                apiData = new Dictionary <string, object> ();
                apiData.Add("key", "api_data_example: " + key);
                apiData.Add("value", testValues[key]);

                apiDataList.Add(apiData);
            }

            WorkbooksApiResponse response;

            try {
                response = workbooks.assertCreate("automation/api_data", apiDataList, null, null);
                List <Dictionary <string, object> > idVersionObjects = workbooks.idVersions(response);

                workbooks.log("createAPIData: First Object- ", new Object[] { response.getFirstAffectedObject() });

                apiData.Clear();
                apiDataList.Clear();

                // Update two API Data entries
                apiData.Add("id", ((Dictionary <string, object>)idVersionObjects[0])["id"]);
                apiData.Add("lock_version", ((Dictionary <string, object>)idVersionObjects[0])["lock_version"]);
                apiData.Add("value", 17);
                apiDataList.Add(apiData);

                Dictionary <string, object> apiData1 = new Dictionary <string, object> ();
                apiData1.Add("id", ((Dictionary <string, object>)idVersionObjects[2])["id"]);
                apiData1.Add("lock_version", ((Dictionary <string, object>)idVersionObjects[2])["lock_version"]);
                apiData1.Add("value", "null points");
                apiDataList.Add(apiData1);

                response = workbooks.assertUpdate("automation/api_data", apiDataList, null, null);

                workbooks.log("Updated API Data: First Object- ", new Object[] { response.getFirstAffectedObject() });
            } catch (Exception e) {
                workbooks.log("Exception while creating apidata", new Object[] { e }, "error");
                Console.WriteLine(e.StackTrace);
                login.testExit(workbooks, 1);
            }
        }
        /// <summary>
        /// Alternatively, choose a template and a Case then use it to create a Draft email about the Case.
        /// </summary>
        public static void sendDraftTemplatedEmail()
        {
            List <Dictionary <string, object> > templatedEmailList = new List <Dictionary <string, object> >();

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

            templatedEmail.Add("render_with_template_name", "Autotest Template");
            templatedEmail.Add("render_with_resource_type", "Private::Crm::Case");
            templatedEmail.Add("render_with_resource_id", 2);
            templatedEmail.Add("from_address", "*****@*****.**");
            templatedEmail.Add("to_addresses", "[email protected], [email protected]");
            templatedEmail.Add("cc_addresses", "[email protected], [email protected]");
            templatedEmail.Add("bcc_addresses", "*****@*****.**");
            templatedEmail.Add("status", "DRAFT");

            templatedEmailList.Add(templatedEmail);
            try {
                WorkbooksApiResponse response = workbooks.assertCreate("email/emails", templatedEmailList, null, null);

                List <Dictionary <string, object> > idVersionObjects = workbooks.idVersions(response);

                /*
                 * Now change the status to send it
                 */
                Dictionary <string, object> updateEmail = new Dictionary <string, object> ();
                updateEmail.Add("id", ((Dictionary <string, object>)idVersionObjects[0])["id"]);
                updateEmail.Add("lock_version", ((Dictionary <string, object>)idVersionObjects[0])["lock_version"]);
                updateEmail.Add("status", "SEND");

                List <Dictionary <string, object> > updateEmailList = new List <Dictionary <string, object> >();
                updateEmailList.Add(updateEmail);
                response = workbooks.assertUpdate("email/emails", updateEmailList, null, null);
                workbooks.log("sendDraftTemplatedEmail() : Email is sent successfully");
            } catch (Exception e) {
                workbooks.log("Error while sending templated Email " + e.Message);
                workbooks.log(e.StackTrace);
                login.testExit(workbooks, 1);
            }
        }
Exemple #3
0
    private void createOrganisations(bool doUpdate, bool doDelete, bool doBatch)
    {
        List <Dictionary <string, object> > objectIdLockVersion = null;

        try{
            //*************Multiple Organisations
            Dictionary <string, object>         org2 = new Dictionary <string, object>();
            Dictionary <string, object>         org3 = new Dictionary <string, object>();
            Dictionary <string, object>         org4 = new Dictionary <string, object>();
            List <Dictionary <string, object> > multipleOrganisations = new List <Dictionary <string, object> >();

            org2.Add("name", "Freedom & Light Ltd");
            org2.Add("created_through_reference", "12345");
            org2.Add("industry", "Media & Entertainment");
            org2.Add("main_location[country]", "United Kingdom");
            org2.Add("main_location[county_province_state]", "Berkshire");
            org2.Add("main_location[fax]", "0234 567890");
            org2.Add("main_location[postcode]", "RG99 9RG");
            org2.Add("main_location[street_address]", "100 Main Street");
            org2.Add("main_location[telephone]", "0123 456789");
            org2.Add("main_location[town]", "Beading");
            org2.Add("no_phone_soliciting", true);
            org2.Add("no_post_soliciting", true);
            org2.Add("organisation_annual_revenue", "10000000");
            org2.Add("organisation_category", "Marketing Agency");
            org2.Add("organisation_company_number", "12345678");
            org2.Add("organisation_num_employees", 250);
            org2.Add("organisation_vat_number", "GB123456");
            org2.Add("website", "www.freedomandlight.com");

            org3.Add("name", "Freedom Power Tools Limited");
            org3.Add("created_through_reference", "12346");

            org4.Add("name", "Freedom o\" the Seas Recruitment");
            org4.Add("created_through_reference", "12347");

            multipleOrganisations.Add(org2);
            multipleOrganisations.Add(org3);
            multipleOrganisations.Add(org4);

            WorkbooksApiResponse response = workbooks.assertCreate("crm/organisations", multipleOrganisations, null, null);

            workbooks.log("createOrganisations Multiple: ", new Object[] { response.print(response.getFirstAffectedObject()) });
            objectIdLockVersion = workbooks.idVersions(response);

            // **************** UPDATE THE CREATED ORGANISATION RECORDS
            if (doUpdate)
            {
                // Clear the hashmaps to populate with the details to update
                multipleOrganisations.Clear();
                org2.Clear();
                org3.Clear();
                org4.Clear();

                org2.Add("id", ((Dictionary <string, object>)objectIdLockVersion[0])["id"]);
                org2.Add("lock_version", ((Dictionary <string, object>)objectIdLockVersion[0])["lock_version"]);
                org2.Add("name", "Freedom & Light Unlimited");
                org2.Add("main_location[postcode]", "RG66 6RG");
                org2.Add("main_location[street_address]", "199 High Street");

                org3.Add("id", ((Dictionary <string, object>)objectIdLockVersion[1])["id"]);
                org3.Add("lock_version", ((Dictionary <string, object>)objectIdLockVersion[1])["lock_version"]);
                org3.Add("name", "Freedom Power");

                org4.Add("id", ((Dictionary <string, object>)objectIdLockVersion[2])["id"]);
                org4.Add("lock_version", ((Dictionary <string, object>)objectIdLockVersion[2])["lock_version"]);
                org4.Add("name", "Sea Recruitment");

                multipleOrganisations.Add(org2);
                multipleOrganisations.Add(org3);
                multipleOrganisations.Add(org4);

                response = workbooks.assertUpdate("crm/organisations", multipleOrganisations, null, null);
                workbooks.log("Updated organisations ", new Object[] { response.print(response.getFirstAffectedObject()) });
            }
            objectIdLockVersion = workbooks.idVersions(response);

            if (doBatch)
            {
                //************** BATCH ALL
                Dictionary <string, object>         createAction        = new Dictionary <string, object> ();
                Dictionary <string, object>         updateAction        = new Dictionary <string, object> ();
                Dictionary <string, object>         deleteAction        = new Dictionary <string, object> ();
                Dictionary <string, object>         deleteAnotherAction = new Dictionary <string, object> ();
                List <Dictionary <string, object> > batchActions        = new List <Dictionary <string, object> >();


                createAction.Add("method", "CREATE");
                createAction.Add("name", "Abercrombie Pies");
                createAction.Add("industry", "Food");
                createAction.Add("main_location[country]", "United Kingdom");
                createAction.Add("main_location[county_province_state]", "Berkshire");
                createAction.Add("main_location[town]", "Beading");

                updateAction.Add("method", "UPDATE");
                updateAction.Add("id", ((Dictionary <string, object>)objectIdLockVersion[0])["id"]);
                updateAction.Add("lock_version", ((Dictionary <string, object>)objectIdLockVersion[0])["lock_version"]);
                updateAction.Add("name", "Lights \'R Us");
                updateAction.Add("main_location[postcode]", null);

                deleteAction.Add("method", "DELETE");
                deleteAction.Add("id", ((Dictionary <string, object>)objectIdLockVersion[1])["id"]);
                deleteAction.Add("lock_version", ((Dictionary <string, object>)objectIdLockVersion[1])["lock_version"]);

                deleteAnotherAction.Add("id", ((Dictionary <string, object>)objectIdLockVersion[2])["id"]);
                deleteAnotherAction.Add("lock_version", ((Dictionary <string, object>)objectIdLockVersion[2])["lock_version"]);
                deleteAnotherAction.Add("method", "DELETE");

                batchActions.Add(createAction);
                batchActions.Add(updateAction);
                batchActions.Add(deleteAction);
                batchActions.Add(deleteAnotherAction);

                response = workbooks.assertBatch("crm/organisations", batchActions, null, null, null);
                workbooks.log("Batch Actions: ", new Object[] { response.print(response.getFirstAffectedObject()) });
            }
            objectIdLockVersion = workbooks.idVersions(response);

            //************** CREATE A SINGLE ORGANISATION
            List <Dictionary <string, object> > singleOrganisation = new List <Dictionary <string, object> >();
            Dictionary <string, object>         org1 = new Dictionary <string, object>();

            org1.Add("name", "Birkbeck Burgers");
            org1.Add("industry", "Food");
            org1.Add("main_location[country]", "United Kingdom");
            org1.Add("main_location[county_province_state]", "Oxfordshire");
            org1.Add("main_location[town]", "Oxford");

            singleOrganisation.Add(org1);
            response = workbooks.assertCreate("crm/organisations", singleOrganisation, null, null);
            workbooks.log("createOrganisations Single: ", new Object[] { response.getFirstAffectedObject() });
            List <Dictionary <string, object> > createdObjectIdLockVersion = workbooks.idVersions(response);

            createdObjectIdLockVersion.Add((Dictionary <string, object>)objectIdLockVersion[0]);
            createdObjectIdLockVersion.Add((Dictionary <string, object>)objectIdLockVersion[1]);
            //***************** DELETE THE REMAIIG ORGANISATIONS CREATED IN THIS CLASS
            if (doDelete)
            {
                workbooks.assertDelete("crm/organisations", createdObjectIdLockVersion, null, null);
                workbooks.log("Delete Organisations ");
            }
        } catch (Exception e) {
            Console.WriteLine(e.StackTrace);
        }
    }
Exemple #4
0
        /// <summary>
        /// Create two people, tagging with their identifiers in the external system. Up to 100 can be done in one batch.
        /// </summary>
        /// <param name="doUpdate">If set to <c>true</c> do update on the created people record.</param>
        /// <param name="doDelete">If set to <c>true</c> do delete on the created people record.</param>
        private void createTwoPeople(bool doUpdate, bool doDelete)
        {
            List <Dictionary <string, object> > twoPeople = new List <Dictionary <string, object> >();

            Dictionary <string, object>         person1             = new Dictionary <string, object>();
            List <Dictionary <string, object> > objectIdLockVersion = null;

            person1.Add("name", "Csharp Rich Richards");
            person1.Add("created_through_reference", "101");
            person1.Add("main_location[country]", "UK");
            person1.Add("main_location[county_province_state]", "Berkshire");
            person1.Add("main_location[fax]", "01234 54646");
            person1.Add("main_location[postcode]", "RG6 1AZ");
            person1.Add("main_location[street_address]", "100 Civvy Street");
            person1.Add("main_location[telephone]", "011897656");
            person1.Add("main_location[town]", "Reading");
            person1.Add("no_email_soliciting", false);
            person1.Add("no_phone_soliciting", true);
            person1.Add("no_post_soliciting", true);
            person1.Add("person_first_name", "Richard");
            person1.Add("person_middle_name", "");
            person1.Add("person_last_name", "Richards");
            person1.Add("person_personal_title", "Mr.");
            person1.Add("website", "www.richards.me.uk");

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

            //String[][] person2 = ...
            person2.Add("name", "Csharp Stevie Stephens");
            person2.Add("created_through_reference", "102");
            person2.Add("main_location[country]", "UK");
            person2.Add("main_location[county_province_state]", "Berkshire");
            person2.Add("main_location[fax]", "01234 54646");
            person2.Add("main_location[postcode]", "RG6 1AZ");
            person2.Add("main_location[street_address]", "102 Castle Street");
            person2.Add("main_location[telephone]", "011897656");
            person2.Add("main_location[town]", "Reading");
            person2.Add("no_email_soliciting", false);
            person2.Add("no_phone_soliciting", true);
            person2.Add("no_post_soliciting", true);
            person2.Add("person_first_name", "Steve");
            person2.Add("person_middle_name", "");
            person2.Add("person_last_name", "Stephens");
            person2.Add("person_personal_title", "Mr.");
            person2.Add("website", "www.steve.me.uk");


            twoPeople.Add(person1);
            twoPeople.Add(person2);
            try {
                WorkbooksApiResponse response = workbooks.assertCreate("crm/people", twoPeople, null, null);

                object[] allData = response.getAffectedObjects();

                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"]);
                }

                // **************** UPDATE THE TWO CREATED PEOPLE RECORDS
                if (doUpdate)
                {
                    objectIdLockVersion = workbooks.idVersions(response);

                    // Clear the hashmaps to populate with the details to update
                    twoPeople.Clear();
                    person1.Clear();
                    person2.Clear();

                    person1.Add("id", ((Dictionary <string, object>)objectIdLockVersion[0])["id"]);
                    person1.Add("lock_version", ((Dictionary <string, object>)objectIdLockVersion[0])["lock_version"]);
                    person1.Add("main_location[email]", "*****@*****.**");

                    person2.Add("id", ((Dictionary <string, object>)objectIdLockVersion[1])["id"]);
                    person2.Add("lock_version", ((Dictionary <string, object>)objectIdLockVersion[1])["lock_version"]);
                    person2.Add("main_location[email]", "*****@*****.**");

                    twoPeople.Add(person1);
                    twoPeople.Add(person2);

                    workbooks.assertUpdate("crm/people", twoPeople, null, null);
                    Console.WriteLine("Updated people. ");
                    //workbooks.log("update_two_people", new Object[] {responseUpdate.getFirstAffectedObjects()});
                }
                //***************** DELETE THE TWO CREATED PEOPLE
                if (doDelete)
                {
                    objectIdLockVersion = workbooks.idVersions(response);

                    WorkbooksApiResponse responseDelete = workbooks.assertDelete("crm/people", objectIdLockVersion, null, null);

                    workbooks.log("delete_two_people", new Object[] { responseDelete.getFirstAffectedObject() });
                }
            } catch (Exception wbe) {
                Console.WriteLine("Error while creating the people record: " + wbe.Message);
                Console.WriteLine(wbe.StackTrace);
                testLoginHelper.testExit(workbooks, 1);
            }
        }