Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new fields to ticket comments #275

Closed
wants to merge 8 commits into from
52 changes: 52 additions & 0 deletions src/Tests/TicketTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -404,13 +404,65 @@ public void CanCreateUpdateAndDeleteTicket()
Assert.True(api.Tickets.Delete(res.Id.Value));
}

[Test]
public void CanCreateUpdateAndDeleteHTMLTicket()
{
var ticket = new Ticket()
{
Subject = "my printer is on fire",
Comment = new Comment() { HtmlBody = "HELP</br>HELP On a New line." },
Priority = TicketPriorities.Urgent
};

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

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

Assert.NotNull(res);
Assert.Greater(res.Id, 0);

Assert.AreEqual(res.CreatedAt, res.UpdatedAt);
Assert.LessOrEqual(res.CreatedAt - DateTimeOffset.UtcNow, TimeSpan.FromMinutes(1.0));

res.Status = TicketStatus.Solved;
res.AssigneeId = Settings.UserId;

res.CollaboratorIds.Add(Settings.CollaboratorId);
var htmlBody = "HELP</br>HELP On a New line.";

res.CustomFields[0].Value = "updated";

var updateResponse = api.Tickets.UpdateTicket(res, new Comment() { HtmlBody = htmlBody, Public = true, Uploads = new List<string>() });

Assert.NotNull(updateResponse);
//Assert.AreEqual(updateResponse.Audit.Events.First().Body, body);
Assert.Greater(updateResponse.Ticket.CollaboratorIds.Count, 0);
Assert.GreaterOrEqual(updateResponse.Ticket.UpdatedAt, updateResponse.Ticket.CreatedAt);

Assert.True(api.Tickets.Delete(res.Id.Value));
}

[Test]
public void CanGetTicketComments()
{
var comments = api.Tickets.GetTicketComments(2);
Assert.IsNotEmpty(comments.Comments[1].Body);
}

[Test]
public void CanGetTicketHTMLComments()
{
var comments = api.Tickets.GetTicketComments(2);
Assert.IsNotEmpty(comments.Comments[1].HtmlBody);
}

[Test]
public void CanGetTicketCommentsWithSideLoading()
{
Expand Down
4 changes: 2 additions & 2 deletions src/Tests/VoiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void GetAllAgentAvailability()

var agent = res.AgentActivity.FirstOrDefault();
Assert.NotNull(agent);
Assert.AreEqual(2110053086, agent.AgentId);
Assert.AreEqual(281513402, agent.AgentId);
}

[Test]
Expand All @@ -74,7 +74,7 @@ public void GetAllAgentAvailabilityAsync()

var agent = res.Result.AgentActivity.FirstOrDefault();
Assert.NotNull(agent);
Assert.AreEqual(2110053086, agent.AgentId);
Assert.AreEqual(281513402, agent.AgentId);
}

[Test]
Expand Down
23 changes: 15 additions & 8 deletions src/ZendeskApi_v2/Models/Tickets/Comment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,26 @@ namespace ZendeskApi_v2.Models.Tickets
public class Comment
{
[JsonProperty("id")]
public long? Id { get; set; }
public long? Id { get; }

[JsonProperty("public")]
public bool Public { get; set; }
[JsonProperty("type")]
public string Type { get; }

[JsonProperty("body")]
public string Body { get; set; }

[JsonProperty("html_body")]
public string HtmlBody { get; set; }

[JsonProperty("plain_body")]
public string PlainBody { get; }

[JsonProperty("public")]
public bool Public { get; set; }

[JsonProperty("author_id")]
public long? AuthorId { get; set; }

/// <summary>
/// Used for uploading attachments only
/// When creating and updating tickets you may attach files by passing in an array of the tokens received from uploading the files.
Expand All @@ -29,11 +41,6 @@ public class Comment
/// <summary>
/// Used only for getting ticket comments
/// </summary>
[JsonProperty("author_id")]
public long? AuthorId { get; set; }

[JsonProperty("html_body")]
public string HtmlBody { get; private set; }

[JsonProperty("attachments")]
public IList<Attachment> Attachments { get; private set; }
Expand Down