Example #1
0
        static void Main(string[] args)
        {
            Client client = new Client("ApiExplorer", "5", 5, "https://demo.ontimesuite.com", "/ontime/ontimegcclient.nsf", "/servlet/ontimegc");
            LoginResult result = client.Login("ch", "demo");
            string userId = "U";

            if (result.IsAuthorized)
            {
                VersionResult versionResult = client.Version();
                UsersAllResult usersAllResult = client.UsersAll();
                UsersInfoResult usersInfoResult = client.UsersInfo(onTimeIds: new List<string>() { userId });
                CalendarsResult calendarsResult = client.Calendars(DateTime.Now.AddDays(-2), DateTime.Now.AddDays(2), onTimeIds: new List<string>() { userId });

                DateTime baseValue = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day + 1, 12, 0, 0, DateTimeKind.Utc);
                AppointmentCreateResult appointmentCreateResult = client.AppointmentCreate(EventType.Appointment, userId, baseValue, baseValue.AddMinutes(30), "TestSubject1");
                AppointmentChangeResult appointmentChangeResult = client.AppointmentChange(userId, appointmentCreateResult.AppointmentCreate.NewUnID, baseValue, baseValue.AddHours(1), subject: "TestSubject2");
                AppointmentRemoveResult appointmentRemoveResult = client.AppointmentRemove(userId, appointmentCreateResult.AppointmentCreate.NewUnID);

                MailContactsListResult mailContactsListResult = client.MailContactsList(userId, new List<string>() { "Foo" });
                MailContactsCreateResult mailContactsCreateResult = client.MailContactCreate(userId, "Herr Hans Test", "*****@*****.**", title: "Herr", additionalFields: new Dictionary<string, string>() { { "Foo", "Bar" } });
                MailContactsChangeResult mailContactsChangeResult = client.MailContactsChange(userId, mailContactsCreateResult.MailContactsCreate.Contact.UnID, additionalFields: new Dictionary<string, string>() { { "Foo", "FooBar" } });
                MailContactsReadResult mailContactsReadResult = client.MailContactsRead(userId, mailContactsCreateResult.MailContactsCreate.Contact.UnID, new List<string>() { "Foo" });
                MailContactsRemoveResult mailContactsRemoveResult = client.MailContactsRemove(userId, mailContactsCreateResult.MailContactsCreate.Contact.UnID);

                LogoutResult logoutResult = client.Logout();
            }
        }
Example #2
0
        public void LoginWithValidCredentials()
        {
            Client client = new Client(ApplicationId, ApplicationVersion, ApiVersion, Domain, ApiPath);
            LoginResult result = client.Login(LoginUser, LoginPass);

            Assert.AreEqual(true, result.IsAuthorized, "successful");
        }
Example #3
0
        public void Calendars()
        {
            Client client = new Client(ApplicationId, ApplicationVersion, ApiVersion, Domain, ApiPath);
            LoginResult result = client.Login(LoginUser, LoginPass);
            if (result.IsAuthorized)
            {
                CalendarsResult calendarsResult = client.Calendars(DateTime.Now.AddMonths(-1), DateTime.Now.AddMonths(1), onTimeIds: new List<string>() { UserId, "10" });
                Assert.AreEqual(2, calendarsResult.Calendars.IDs.Count);

                return;
            }

            Assert.Fail("Login failed.");
        }
Example #4
0
        public void LoginWithWrongCredentials()
        {
            Client client = new Client(ApplicationId, ApplicationVersion, ApiVersion, Domain, ApiPath);
            try
            {
                client.Login(LoginUser, "demo1");
            }
            catch (Exception ex)
            {
                StringAssert.Contains("Invalid credentials.", ex.Message);
                return;
            }

            Assert.Fail("No exception was thrown.");
        }
Example #5
0
        public void AppointmentCreateChangeDelete()
        {
            Client client = new Client(ApplicationId, ApplicationVersion, ApiVersion, Domain, ApiPath);
            LoginResult result = client.Login(LoginUser, LoginPass);
            if (result.IsAuthorized)
            {
                DateTime baseValue = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day + 1, 12, 0, 0, DateTimeKind.Utc);
                AppointmentCreateResult appointmentCreateResult = client.AppointmentCreate(EventType.Appointment, UserId, baseValue, baseValue.AddMinutes(30), "TestSubject1");
                Assert.AreEqual("OK", appointmentCreateResult.AppointmentCreate.Status);

                AppointmentChangeResult appointmentChangeResult = client.AppointmentChange(UserId, appointmentCreateResult.AppointmentCreate.NewUnID, baseValue, baseValue.AddHours(1), subject: "TestSubject2");
                Assert.AreEqual("OK", appointmentChangeResult.AppointmentChange.Status);

                AppointmentRemoveResult appointmentRemoveResult = client.AppointmentRemove(UserId, appointmentCreateResult.AppointmentCreate.NewUnID);
                Assert.AreEqual("OK", appointmentRemoveResult.AppointmentRemove.Status);

                return;
            }

            Assert.Fail("Login failed.");
        }
Example #6
0
        public void Logout()
        {
            Client client = new Client(ApplicationId, ApplicationVersion, ApiVersion, Domain, ApiPath);
            LoginResult result = client.Login(LoginUser, LoginPass);
            if (result.IsAuthorized)
            {
                LogoutResult logoutResult = client.Logout();
                Assert.AreEqual(Username, logoutResult.Logout.Name);
                return;
            }

            Assert.Fail("Login failed.");
        }
Example #7
0
        public void UsersInfo()
        {
            Client client = new Client(ApplicationId, ApplicationVersion, ApiVersion, Domain, ApiPath);
            LoginResult result = client.Login(LoginUser, LoginPass);
            if (result.IsAuthorized)
            {
                UsersInfoResult usersInfoResult = client.UsersInfo(onTimeIds: new List<string>() { UserId });
                Assert.AreEqual(1, usersInfoResult.UsersInfo.IDs.Count);
                Assert.AreEqual(EmailAddress, usersInfoResult.UsersInfo.IDs[0].Email);

                return;
            }

            Assert.Fail("Login failed.");
        }
Example #8
0
        public void UsersAll()
        {
            Client client = new Client(ApplicationId, ApplicationVersion, ApiVersion, Domain, ApiPath);
            LoginResult result = client.Login(LoginUser, LoginPass);
            if (result.IsAuthorized)
            {
                UsersAllResult usersAllResult = client.UsersAll();
                Assert.AreNotEqual(null, usersAllResult.UsersAll.Users);

                return;
            }

            Assert.Fail("Login failed.");
        }
Example #9
0
        public void MailContactsListResult()
        {
            Client client = new Client(ApplicationId, ApplicationVersion, ApiVersion, Domain, ApiPath, ServletPath);
            LoginResult result = client.Login(LoginUser, LoginPass);
            if (result.IsAuthorized)
            {
                MailContactsListResult mailContactsListResult = client.MailContactsList(UserId);
                Assert.AreNotEqual(null, mailContactsListResult.MailContactsList.Contacts);

                return;
            }

            Assert.Fail("Login failed.");
        }
Example #10
0
        public void MailContactCreateChangeReadDelete()
        {
            Client client = new Client(ApplicationId, ApplicationVersion, ApiVersion, Domain, ApiPath, ServletPath);
            LoginResult result = client.Login(LoginUser, LoginPass);
            if (result.IsAuthorized)
            {
                MailContactsCreateResult mailContactsCreateResult = client.MailContactCreate(UserId, "Herr Hans Test", "*****@*****.**", title: "Herr", additionalFields: new Dictionary<string, string>() { { "Foo", "Bar" } });
                Assert.AreEqual("OK", mailContactsCreateResult.Status);

                MailContactsChangeResult mailContactsChangeResult = client.MailContactsChange(UserId, mailContactsCreateResult.MailContactsCreate.Contact.UnID, additionalFields: new Dictionary<string, string>() { { "Foo", "FooBar" } });
                Assert.AreEqual("OK", mailContactsChangeResult.Status);

                MailContactsReadResult mailContactsReadResult = client.MailContactsRead(UserId, mailContactsCreateResult.MailContactsCreate.Contact.UnID, new List<string>() { "Foo" });
                Assert.AreEqual("*****@*****.**", mailContactsReadResult.MailContactsRead.Contact.Email);

                MailContactsRemoveResult mailContactsRemoveResult = client.MailContactsRemove(UserId, mailContactsCreateResult.MailContactsCreate.Contact.UnID);
                Assert.AreEqual("OK", mailContactsRemoveResult.Status);

                return;
            }

            Assert.Fail("Login failed.");
        }