示例#1
0
 /// <summary>
 /// This end-point is for bulk importing tickets. It will allow you to 
 /// move data from legacy systems into Zendesk. We do not run triggers 
 /// or the likes during bulk imports like these.
 /// </summary>
 public IndividualTicketResponse Import(TicketImport ticket)
 {
     var body = new {ticket};
     return GenericPost<IndividualTicketResponse>(
         String.Format("imports/{0}.json", _tickets),
         body);
 }
示例#2
0
        public void CanImportTicket()
        {
            var ticket = new TicketImport()
            {
                Subject = "my printer is on fire",
                Comments = new List<TicketImportComment> { new TicketImportComment { AuthorId = Settings.UserId, Value = "HELP comment created in Import 1", Public = false, CreatedAt = DateTime.UtcNow.AddDays(-2) }, new TicketImportComment { AuthorId = Settings.UserId, Value = "HELP comment created in Import 2", Public = false, CreatedAt = DateTime.UtcNow.AddDays(-3) } },
                Priority = TicketPriorities.Urgent,
                CreatedAt = DateTime.Now.AddDays(-5),
                UpdatedAt = DateTime.Now.AddDays(-4),
                SolvedAt = DateTime.Now.AddDays(-3),
                Status = TicketStatus.Solved,
                AssigneeId = Settings.UserId,
                Description = "test description"
            };

            var res = api.Tickets.ImportTicket(ticket).Ticket;

            Assert.NotNull(res);
            Assert.True(res.Id.HasValue);
            Assert.Greater(res.Id.Value, 0);
            Assert.Less(res.CreatedAt.Value.LocalDateTime, DateTime.Now.AddDays(-4));
            Assert.Greater(res.UpdatedAt.Value.LocalDateTime, res.CreatedAt.Value.LocalDateTime);
            Assert.AreEqual(res.Status, TicketStatus.Solved);
            Assert.AreEqual(res.Description, "test description");

            var resComments = api.Tickets.GetTicketComments(res.Id.Value);
            Assert.NotNull(resComments);
            Assert.AreEqual(resComments.Count, 3);

            api.Tickets.DeleteAsync(res.Id.Value);
            //Assert.Greater(res.SolvedAt.Value.LocalDateTime, res.UpdatedAt.Value.LocalDateTime);
        }
示例#3
0
        public void CanBulkImportTicket()
        {
            List<TicketImport> test = new List<TicketImport>();

            for (int x = 0; x < 2; x++)
            {
                var ticket = new TicketImport()
                {
                    Subject = "my printer is on fire",
                    Comments = new List<TicketImportComment> { new TicketImportComment { AuthorId = Settings.UserId, Value = "HELP comment created in Import 1", CreatedAt = DateTime.UtcNow.AddDays(-2), Public= false }, new TicketImportComment { AuthorId = Settings.UserId, Value = "HELP comment created in Import 2", CreatedAt = DateTime.UtcNow.AddDays(-3), Public = false } },
                    Priority = TicketPriorities.Urgent,
                    CreatedAt = DateTime.Now.AddDays(-5),
                    UpdatedAt = DateTime.Now.AddDays(-4),
                    SolvedAt = DateTime.Now.AddDays(-3),
                    Status = TicketStatus.Solved,
                    AssigneeId = Settings.UserId,
                    Description = "test description"
                };
                test.Add(ticket);
            }

            var res = api.Tickets.BulkImportTickets(test);

            Assert.AreEqual(res.JobStatus.Status, "queued");

            var job = api.JobStatuses.GetJobStatus(res.JobStatus.Id);
            Assert.AreEqual(job.JobStatus.Id, res.JobStatus.Id);
            

            int count = 0;
            while (job.JobStatus.Status.ToLower() != "completed" && count < 10)
            {
                Thread.Sleep(1000);
                job = api.JobStatuses.GetJobStatus(res.JobStatus.Id);
                count++;
            }

            Assert.AreEqual(job.JobStatus.Status.ToLower(), "completed");

            foreach (var r in job.JobStatus.Results)
            {
                var ticket = api.Tickets.GetTicket(r.Id).Ticket;
                Assert.AreEqual(ticket.Description, "test description");
                var resComments = api.Tickets.GetTicketComments(r.Id);
                Assert.NotNull(resComments);
                Assert.AreEqual(resComments.Count, 3);
                foreach (var c in resComments.Comments)
                {
                    Assert.True(c.CreatedAt.HasValue);
                    Assert.Less(c.CreatedAt.Value.LocalDateTime, DateTime.Now.AddDays(-1));
                }

                api.Tickets.DeleteAsync(r.Id);
            }
        }
示例#4
0
 /// <summary>
 /// In addition to setting normal ticket properties, you can set the following time stamps on the tickets: solved_at, updated_at, and created_at.
 /// </summary>
 /// <param name="ticket"></param>
 /// <returns></returns>
 public async Task<IndividualTicketResponse> ImportTicketAsync(TicketImport ticket)
 {
     var body = new { ticket };
     return await GenericPostAsync<IndividualTicketResponse>(_imports + "/" + _tickets + ".json", body);
 }
示例#5
0
 /// <summary>
 /// In addition to setting normal ticket properties, you can set the following time stamps on the tickets: solved_at, updated_at, and created_at.
 /// </summary>
 /// <param name="ticket"></param>
 /// <returns></returns>
 public IndividualTicketResponse ImportTicket(TicketImport ticket)
 {
     var body = new { ticket };
     return GenericPost<IndividualTicketResponse>(_imports + "/" + _tickets + ".json", body);
 }
示例#6
0
        public void CanImportTicket()
        {
            const string createdAt = "2000-01-01T12:34:56Z";
            const string solvedAt = "2000-01-01T12:40:00Z";

            var submitter = User("*****@*****.**");
            var solver = User("*****@*****.**");

            var ticket = new TicketImport
            {
                Subject = "my printer is on fire",
                Description = "HELP and other descriptive stuff",
                Priority = TicketPriorities.Urgent,
                CreatedAt = createdAt,
                UpdatedAt = solvedAt,
                SolvedAt = solvedAt,
                Comments = new List<CommentImport>
                {
                    new CommentImport()
                    {
                        AuthorId = submitter.Id.Value,
                        CreatedAt = createdAt,
                        Public = false,
                        Value = "HELP"
                    },
                    new CommentImport()
                    {
                        AuthorId = solver.Id.Value,
                        CreatedAt = solvedAt,
                        Public = false,
                        Value = "Extinguished!"
                    },
                },
            };

            var res = api.Tickets.Import(ticket).Ticket;

            Assert.NotNull(res);
            Assert.Greater(res.Id, 0);
            Assert.AreEqual(createdAt, res.CreatedAt);
            Assert.AreEqual(solvedAt, res.UpdatedAt);

            var audits = api.Tickets.GetAudits(res.Id.Value);

            // 1st is ticket creation; 2nd is "HELP"; 3rd is "Extinguished!"
            Assert.AreEqual(3, audits.Count);
            AssertIsCommentAudit("HELP", submitter.Id, audits.Audits[1]);
            AssertIsCommentAudit("Extinguished!", solver.Id, audits.Audits[2]);
        }