示例#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();
            }
        }
示例#2
0
文件: Test.cs 项目: QKom/OnTimeGCApi
        public void LoginWithValidCredentials()
        {
            Client client = new Client(ApplicationId, ApplicationVersion, ApiVersion, Domain, ApiPath);
            LoginResult result = client.Login(LoginUser, LoginPass);

            Assert.AreEqual(true, result.IsAuthorized, "successful");
        }
示例#3
0
文件: Test.cs 项目: QKom/OnTimeGCApi
        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.");
        }
示例#4
0
文件: Test.cs 项目: QKom/OnTimeGCApi
        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.");
        }
示例#5
0
文件: Test.cs 项目: QKom/OnTimeGCApi
        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.");
        }
示例#6
0
文件: Test.cs 项目: QKom/OnTimeGCApi
        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.");
        }
示例#7
0
文件: Test.cs 项目: QKom/OnTimeGCApi
        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.");
        }
示例#8
0
文件: Test.cs 项目: QKom/OnTimeGCApi
        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.");
        }
示例#9
0
文件: Test.cs 项目: QKom/OnTimeGCApi
        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.");
        }
示例#10
0
文件: Test.cs 项目: QKom/OnTimeGCApi
        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.");
        }