Skip to content

Commit

Permalink
add requester and tags properties to request (#468)
Browse files Browse the repository at this point in the history
  • Loading branch information
cypressious authored Mar 30, 2020
1 parent d65381c commit 69a3bab
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 44 deletions.
6 changes: 6 additions & 0 deletions src/ZendeskApi_v2/Models/Requests/Request.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public class Request
[JsonProperty("requester_id")]
public long? RequesterId { get; set; }

[JsonProperty("requester")]
public Requester Requester { get; set; }

[JsonProperty("assignee_id")]
public long AssigneeId { get; set; }

Expand Down Expand Up @@ -108,5 +111,8 @@ public class Request
/// </summary>
[JsonProperty("comment")]
public Comment Comment { get; set; }

[JsonProperty("tags")]
public IList<string> Tags { get; set; }
}
}
110 changes: 66 additions & 44 deletions test/ZendeskApi_v2.Test/RequestTests.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
using System;
using System.Collections.Generic;
using NUnit.Framework;
using System.Linq;
using ZendeskApi_v2;
using ZendeskApi_v2.Models.Requests;
using ZendeskApi_v2.Models.Tickets;
using ZendeskApi_v2.Models.Users;

namespace Tests
{
Expand Down Expand Up @@ -146,49 +149,68 @@ public void CanGetAllSolvedRequestsSorted()
});
}

//[Test]
//[Ignore("")]
//public void CanCreateAndUpdateRequests()
//{
// 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}
// };

// var res = _api.Requests.CreateRequest(req);
// Assert.IsNotNull(res);
// Assert.IsNotNull(res.Request);
// Assert.IsTrue(res.Request.Id.HasValue);
// Assert.That(res.Request.Type == RequestType.incident);
// Assert.True(res.Request.Id.Value > 0);

// var res1 = _api.Requests.GetRequestById(res.Request.Id.Value);
// Assert.AreEqual(res1.Request.Id, res.Request.Id);

// res1.Request.Subject = "new subject";
// res1.Request.Comment = new Comment
// {
// Body = "something more to say",
// Public = true
// };

// var res2 = _api.Requests.UpdateRequest(res1.Request);
// var res3 = _api.Requests.GetRequestCommentsById(res.Request.Id.Value);

// Assert.AreEqual(res3.Comments.Last().Body.Replace("\n", ""), "something more to say");

// var res4 = _api.Requests.GetSpecificRequestComment(res.Request.Id.Value, res3.Comments.Last().Id.Value);

// res1.Request.RequesterId = 56766413L;
// var res5 = _api.Requests.UpdateRequest(res1.Request);
// var res6 = _api.Requests.GetRequestById(res.Request.Id.Value);

// Assert.AreEqual(res5.Request.RequesterId, res6.Request.RequesterId);
// Assert.AreEqual(res4.Comment.Id, res3.Comments.Last().Id);

// Assert.True(_api.Tickets.Delete(res1.Request.Id.Value));
//}
[Test]
// [Ignore("")]
public void CanCreateAndUpdateRequests()
{
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"}
};

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

try
{
Assert.IsNotNull(res);
Assert.IsNotNull(res.Request);
Assert.IsTrue(res.Request.Id.HasValue);
Assert.That(res.Request.Type == RequestType.incident);
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);

var res1 = _api.Requests.GetRequestById(res.Request.Id.Value);
Assert.AreEqual(res1.Request.Id, res.Request.Id);

res1.Request.Subject = "new subject";
res1.Request.Comment = new Comment
{
Body = "something more to say",
Public = true
};

var res2 = _api.Requests.UpdateRequest(res1.Request);
var res3 = _api.Requests.GetRequestCommentsById(res.Request.Id.Value);

Assert.AreEqual(res3.Comments.Last().Body.Replace("\n", ""), "something more to say");

var res4 = _api.Requests.GetSpecificRequestComment(res.Request.Id.Value, res3.Comments.Last().Id.Value);

res1.Request.RequesterId = 56766413L;
var res5 = _api.Requests.UpdateRequest(res1.Request);
var res6 = _api.Requests.GetRequestById(res.Request.Id.Value);

Assert.AreEqual(res5.Request.RequesterId, res6.Request.RequesterId);
Assert.AreEqual(res4.Comment.Id, res3.Comments.Last().Id);
}
finally
{
Assert.True(_api.Tickets.Delete(res.Request.Id.Value));
}
}
}
}

0 comments on commit 69a3bab

Please sign in to comment.