diff --git a/src/ZendeskApi_v2/Requests/Tickets.cs b/src/ZendeskApi_v2/Requests/Tickets.cs index adaff8de..1e21af56 100644 --- a/src/ZendeskApi_v2/Requests/Tickets.cs +++ b/src/ZendeskApi_v2/Requests/Tickets.cs @@ -96,6 +96,8 @@ public interface ITickets : ICore bool DeleteMultiple(IEnumerable ids); + bool DeleteTicketPermanently(long id); + GroupUserResponse GetCollaborators(long id); GroupTicketResponse GetIncidents(long id); @@ -205,6 +207,8 @@ public interface ITickets : ICore Task DeleteMultipleAsync(IEnumerable ids); + Task DeleteTicketPermanentlyAsync(long id); + Task GetCollaboratorsAsync(long id); Task GetIncidentsAsync(long id); @@ -278,6 +282,7 @@ public interface ITickets : ICore public class Tickets : Core, ITickets { private const string _tickets = "tickets"; + private const string _deletedTickets = "deleted_tickets"; private const string _imports = "imports"; private const string _create_many = "create_many"; private const string _ticket_forms = "ticket_forms"; @@ -478,6 +483,16 @@ public bool DeleteMultiple(IEnumerable ids) return GenericDelete($"{_tickets}/destroy_many.json?ids={ids.ToCsv()}"); } + /// + /// Permanently deletes a soft-deleted ticket + /// + /// Id of ticket to be permanently deleted. + /// Boolean response + public bool DeleteTicketPermanently(long id) + { + return GenericDelete($"{_deletedTickets}/{id}.json"); + } + /// /// Merges the source tickets in the "ids" list into the target ticket with comments as defined. /// @@ -848,6 +863,16 @@ public async Task DeleteMultipleAsync(IEnumerable ids) return await GenericDeleteAsync($"{_tickets}/destroy_many.json?ids={ids.ToCsv()}"); } + /// + /// Permanently deletes a soft-deleted ticket + /// + /// Id of ticket to be permanently deleted. + /// Boolean response + public async Task DeleteTicketPermanentlyAsync(long id) + { + return await GenericDeleteAsync($"{_deletedTickets}/{id}.json"); + } + public async Task GetCollaboratorsAsync(long id) { return await GenericGetAsync($"{_tickets}/{id}/collaborators.json"); diff --git a/tests/ZendeskApi_v2.Tests/TicketTests.cs b/tests/ZendeskApi_v2.Tests/TicketTests.cs index 7e4741b2..8c6bebd0 100644 --- a/tests/ZendeskApi_v2.Tests/TicketTests.cs +++ b/tests/ZendeskApi_v2.Tests/TicketTests.cs @@ -403,6 +403,36 @@ public void CanCreateUpdateAndDeleteTicket() }); } + [Test] + public void CanPermanentlyDeleteTicket() + { + var ticket = new Ticket + { + Subject = "my printer is on fire", + Comment = new Comment() { Body = "HELP" }, + Priority = TicketPriorities.Urgent, + CustomFields = new List() + { + new CustomField() + { + Id = Settings.CustomFieldId, + Value = "testing" + } + } + }; + + var res = Api.Tickets.CreateTicket(ticket).Ticket; + + Assert.That(res, Is.Not.Null); + Assert.Multiple(() => + { + Assert.That(res.Id, Is.GreaterThan(0)); + Assert.That(res.UpdatedAt, Is.EqualTo(res.CreatedAt)); + Assert.That(Api.Tickets.Delete(res.Id.Value), Is.True); + Assert.That(Api.Tickets.DeleteTicketPermanently(res.Id.Value), Is.True); + }); + } + [Test] public void CanCreateUpdateAndDeleteHTMLTicket() { @@ -1767,4 +1797,27 @@ public async Task CanGetIncrementalTicketExportNextPageAsync() Assert.That(res.Tickets, Is.Not.Empty); } + + [Test] + public async Task CanPermanentlyDeleteTicketAsync() + { + var ticket = new Ticket + { + Subject = "my printer is on fire", + Comment = new Comment() { Body = "HELP" }, + Priority = TicketPriorities.Urgent, + }; + + var res = await Api.Tickets.CreateTicketAsync(ticket); + var deleteRes = await Api.Tickets.DeleteAsync(res.Ticket.Id.Value); + var deleteAsyncRes = await Api.Tickets.DeleteTicketPermanentlyAsync(res.Ticket.Id.Value); + + Assert.Multiple(() => + { + Assert.That(res, Is.Not.Null); + Assert.That(res.Ticket, Is.Not.Null); + Assert.That(deleteRes, Is.True); + Assert.That(deleteAsyncRes, Is.True); + }); + } } \ No newline at end of file