Skip to content

Commit

Permalink
Added or_tags to UserSegment.cs (#476)
Browse files Browse the repository at this point in the history
* Added or_tags to UserSegment.cs

This supports the criterion where a user or organization has to match ANY of the tags in the list found in the or_tags property of the user segment response

* Added unit test to check that or_tags are correctly retrieved in user segment response
  • Loading branch information
ClaudineL authored May 12, 2020
1 parent bf26104 commit ce4a049
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/ZendeskApi_v2/Models/UserSegments/UserSegment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public class UserSegment
[JsonProperty("tags")]
public IList<string> Tags { get; set; }

[JsonProperty("or_tags")]
public IList<string> OrTags { get; set; }

[JsonProperty("created_at")]
public string CreatedAt { get; set; }

Expand Down
17 changes: 13 additions & 4 deletions test/ZendeskApi_v2.Test/HelpCenter/UserSegmentTests.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using System.Threading.Tasks;
using Newtonsoft.Json;
using System.Linq;
using System.Threading.Tasks;
using NUnit.Framework;
using ZendeskApi_v2;
using ZendeskApi_v2.Models.HelpCenter.Topics;
using ZendeskApi_v2.Models.Sections;
using ZendeskApi_v2.Models.UserSegments;
using ZendeskApi_v2.Requests.HelpCenter;

namespace Tests.HelpCenter
{
Expand Down Expand Up @@ -104,6 +102,17 @@ public void CanGetUserSegmentsByUserId()
Assert.That(res.UserSegments.Count, Is.GreaterThan(0));
}

[Test]
public void CanRetrieveUserSegmentOrTags()
{
var res = api.HelpCenter.UserSegments.GetUserSegments().UserSegments;
var segment = res.First(seg => seg.Name == "Agents and managers (or_tags: tag1, tag2)");

Assert.That(segment.OrTags.Count == 2);
Assert.That(segment.OrTags.Contains("tag1"));
Assert.That(segment.OrTags.Contains("tag2"));
}

[Test]
public async Task CanGetUserSegmentsAsync()
{
Expand Down

0 comments on commit ce4a049

Please sign in to comment.