コード例 #1
0
ファイル: RequestTests.cs プロジェクト: serber/ZendeskApi_v2
        public void CanCreateRequestWithEmailCCs()
        {
            var emailCCs = new List <EmailCC>
            {
                new EmailCC {
                    UserEmail = "*****@*****.**"
                },
                new EmailCC {
                    UserEmail = "*****@*****.**"
                }
            };

            var req = new Request
            {
                Subject = "end user request test",
                Type    = RequestType.incident,
                Comment = new Comment
                {
                    Body = "end user test", HtmlBody = "end user test with </br> new line", Public = true
                },
                Requester = new Requester
                {
                    Name = "Test Name"
                },
                Tags = new List <string> {
                    "tag1", "tag2"
                },
                EmailCCs = emailCCs
            };

            var res = _api.Requests.CreateRequest(req);

            try
            {
                Assert.IsNotNull(res);
                Assert.IsNotNull(res.Request);
                Assert.IsTrue(res.Request.Id.HasValue);
                Assert.True(res.Request.Id.Value > 0);

                IndividualUserResponse user = _api.Users.GetUser(res.Request.RequesterId.Value);
                Assert.AreEqual("Test Name", user.User.Name);

                IndividualTicketResponse ticket = _api.Tickets.GetTicket(res.Request.Id.Value);
                CollectionAssert.AreEquivalent(new[] { "tag1", "tag2" }, ticket.Ticket.Tags);

                IList <long>      collaboratorsIds = ticket.Ticket.CollaboratorIds;
                GroupUserResponse collaborators    = _api.Users.GetMultipleUsers(collaboratorsIds.AsEnumerable());
                CollectionAssert.AreEquivalent(emailCCs.Select(e => e.UserEmail), collaborators.Users.Select(u => u.Email));
            }
            finally
            {
                Assert.True(_api.Tickets.Delete(res.Request.Id.Value));
            }
        }
コード例 #2
0
        public ICustomActivityResult Execute()
        {
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
                                                   | SecurityProtocolType.Tls11
                                                   | SecurityProtocolType.Tls12
                                                   | SecurityProtocolType.Ssl3;
            var  api              = new ZendeskApi(Domain, Username, ApiToken, "");
            var  users            = new List <User>();
            long totalPage        = 1;
            GroupUserResponse res = null;

            for (int currentPage = 1; currentPage <= 1000; currentPage++)
            {
                if (UserType == "admin")
                {
                    res = api.Users.GetAllAdmins(100, currentPage);
                }
                else if (UserType == "agent")
                {
                    res = api.Users.GetAllAgents(100, currentPage);
                }
                else if (UserType == "enduser")
                {
                    res = api.Users.GetAllEndUsers(100, currentPage);
                }
                else
                {
                    res = api.Users.GetAllUsers(100, currentPage);
                }
                totalPage = res.TotalPages;
                users.AddRange(res.Users);
                if (currentPage == totalPage)
                {
                    break;
                }
            }
            var dt = ItemsToDatatable(users);

            return(this.GenerateActivityResult(dt));
        }