From ce4a04981a0449b3f591400ebee7ed10c764ce5b Mon Sep 17 00:00:00 2001 From: ClaudineL <50966943+ClaudineL@users.noreply.github.com> Date: Tue, 12 May 2020 14:56:43 -0400 Subject: [PATCH] Added or_tags to UserSegment.cs (#476) * 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 --- .../Models/UserSegments/UserSegment.cs | 3 +++ .../HelpCenter/UserSegmentTests.cs | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/ZendeskApi_v2/Models/UserSegments/UserSegment.cs b/src/ZendeskApi_v2/Models/UserSegments/UserSegment.cs index 7956d6d3..2ddd5a88 100644 --- a/src/ZendeskApi_v2/Models/UserSegments/UserSegment.cs +++ b/src/ZendeskApi_v2/Models/UserSegments/UserSegment.cs @@ -31,6 +31,9 @@ public class UserSegment [JsonProperty("tags")] public IList Tags { get; set; } + [JsonProperty("or_tags")] + public IList OrTags { get; set; } + [JsonProperty("created_at")] public string CreatedAt { get; set; } diff --git a/test/ZendeskApi_v2.Test/HelpCenter/UserSegmentTests.cs b/test/ZendeskApi_v2.Test/HelpCenter/UserSegmentTests.cs index 18c2b3f0..f7af5700 100644 --- a/test/ZendeskApi_v2.Test/HelpCenter/UserSegmentTests.cs +++ b/test/ZendeskApi_v2.Test/HelpCenter/UserSegmentTests.cs @@ -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 { @@ -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() {