Esempio n. 1
0
        /// <summary>
        /// UpdateTicket a ticket or add comments to it. Keep in mind that somethings like the description can't be updated.
        /// </summary>
        /// <param name="ticket"></param>
        /// <param name="comment"></param>
        /// <returns></returns>
        public IndividualTicketResponse UpdateTicket(Ticket ticket, Comment comment=null)
        {
            if (comment != null)
                ticket.Comment = comment;
            var body = new { ticket };

            return GenericPut<IndividualTicketResponse>(string.Format("{0}/{1}.json", _tickets, ticket.Id), body);    
        }
Esempio n. 2
0
 public IndividualRequestResponse UpdateRequest(Request request, Comment comment=null)
 {
     if (comment != null)
         request.Comment = comment;
     var body = new { request };
     
     return GenericPut<IndividualRequestResponse>(string.Format("requests/{0}.json", request.Id.Value), body);
 }
Esempio n. 3
0
 public IndividualRequestResponse UpdateRequest(long id, Comment comment)
 {
     var body = new { request = new { comment} };
     return GenericPut<IndividualRequestResponse>(string.Format("requests/{0}.json", id), body);
 }
Esempio n. 4
0
 public async Task<IndividualRequestResponse> UpdateRequestAsync(long id, Comment comment)
 {
     var body = new { request = new { comment} };
     return await GenericPutAsync<IndividualRequestResponse>(string.Format("requests/{0}.json", id), body);
 }
Esempio n. 5
0
        /// <summary>
        /// UpdateTicket a ticket or add comments to it. Keep in mind that somethings like the description can't be updated.
        /// </summary>
        /// <param name="ticket"></param>
        /// <param name="comment"></param>
        /// <returns></returns>
        public async Task<IndividualTicketResponse> UpdateTicketAsync(Ticket ticket, Comment comment=null)
        {
            if (comment != null)
                ticket.Comment = comment;
            var body = new { ticket };

            return await GenericPutAsync<IndividualTicketResponse>(string.Format("{0}/{1}.json", _tickets, ticket.Id), body);    
        }
Esempio n. 6
0
        public IndividualRequestResponse UpdateRequest(Request request, Comment comment=null)
        {
            if (!request.Id.HasValue) { throw new ArgumentException("request must have Id set."); }

            if (comment != null)
            {
                request.Comment = comment;
            }

            var body = new { request };
            
            return GenericPut<IndividualRequestResponse>(string.Format("requests/{0}.json", request.Id.Value), body);
        }
Esempio n. 7
0
        public IndividualRequestResponse UpdateRequest(long id, Comment comment)
        {
            var request = new Request
            {
                Id = id,
                Comment = comment
            };

            return UpdateRequest(request);
        }
Esempio n. 8
0
        private static void UpdateTickets(ZendeskApi api)
        {
            Console.WriteLine("Search created tickets");

            var responseTickets = api.Tickets.GetAllTickets();

            var pageUrl = responseTickets.NextPage;

            var pageUrlParts = pageUrl.Split('=');

            pageUrl = pageUrlParts[0] + "=" + (Int32.Parse(pageUrlParts[1]) - 1);

            while (!String.IsNullOrEmpty(pageUrl))
            {
                Console.WriteLine("Scaning page: {0}", pageUrl);

                responseTickets = api.Tickets.GetByPageUrl<GroupTicketResponse>(pageUrl);

                var tickets = responseTickets.Tickets.Where(row => row.Subject.StartsWith(SubjectStart));

                foreach (var ticket in tickets)
                {
                    var comment = new Comment
                    {
                        AuthorId = CurrentUser.Id,
                        Body = String.Format("Updated from: {0:yyyy.MM.dd HH:mm:ss.fffff}",DateTime.Now),
                    };

                    ticket.Priority =
                        ticket.Priority == TicketPriorities.Urgent
                            ? TicketPriorities.Low
                            : TicketPriorities.Urgent;

                    var response = api.Tickets.UpdateTicket(ticket, comment);

                    var updatedTicket = response.Ticket;

                    Console.WriteLine("Updated: {0}\t{1}\t{2}\t{3}", updatedTicket.Id, updatedTicket.Status, updatedTicket.Recipient, updatedTicket.Subject);
                }

                pageUrl = responseTickets.NextPage;
            }
        }
Esempio n. 9
0
        public async Task ViaChannel_Set_To_API_Isseue_254()
        {
            // see https://github.com/mozts2005/ZendeskApi_v2/issues/254

            var ticket = new Ticket()
            {
                Subject = "my printer is on fire",
                Comment = new Comment() { Body = "HELP" },
                Priority = TicketPriorities.Urgent
            };

            ticket.CustomFields = new List<CustomField>()
                {
                    new CustomField()
                        {
                            Id = Settings.CustomFieldId,
                            Value = "testing"
                        }
                };

            var resp = await api.Tickets.CreateTicketAsync(ticket);
            var newTicket = resp.Ticket;

            Assert.That(newTicket.Via.Channel, Is.EqualTo("api"));

            var comment = new Comment { Body = "New comment", Public = true };

            var resp2 = await api.Tickets.UpdateTicketAsync(newTicket, comment);
            var resp3 = await api.Tickets.GetTicketCommentsAsync(newTicket.Id.Value);

            Assert.That(resp3.Comments.Any(c => c.Via?.Channel != "api"), Is.False);

            // clean up
            await api.Tickets.DeleteAsync(newTicket.Id.Value);
        }