diff --git a/src/ZendeskApi.Build/ZendeskApi.Commons.props b/src/ZendeskApi.Build/ZendeskApi.Commons.props
index 6ef28625..3c42d06f 100644
--- a/src/ZendeskApi.Build/ZendeskApi.Commons.props
+++ b/src/ZendeskApi.Build/ZendeskApi.Commons.props
@@ -23,7 +23,7 @@
7
0
- 1
+ 4
$(Major).$(Minor).$(Revision)
diff --git a/src/ZendeskApi.Client/IZendeskClient.cs b/src/ZendeskApi.Client/IZendeskClient.cs
index a4e52278..88507495 100644
--- a/src/ZendeskApi.Client/IZendeskClient.cs
+++ b/src/ZendeskApi.Client/IZendeskClient.cs
@@ -27,5 +27,6 @@ public interface IZendeskClient
IServiceStatusResource ServiceStatus { get; }
IHelpCenterResource HelpCenter { get; }
ILocaleResource Locales { get; }
+ ITagsResource Tags { get; }
}
}
\ No newline at end of file
diff --git a/src/ZendeskApi.Client/Models/Tag.cs b/src/ZendeskApi.Client/Models/Tag.cs
new file mode 100644
index 00000000..69026a4e
--- /dev/null
+++ b/src/ZendeskApi.Client/Models/Tag.cs
@@ -0,0 +1,12 @@
+using Newtonsoft.Json;
+namespace ZendeskApi.Client.Models
+{
+ public class Tag
+ {
+ [JsonProperty("name")]
+ public string Name { get; set; }
+
+ [JsonProperty("count")]
+ public int Count { get; set; }
+ }
+}
diff --git a/src/ZendeskApi.Client/Resources/Interfaces/ITagsResource.cs b/src/ZendeskApi.Client/Resources/Interfaces/ITagsResource.cs
new file mode 100644
index 00000000..494a3465
--- /dev/null
+++ b/src/ZendeskApi.Client/Resources/Interfaces/ITagsResource.cs
@@ -0,0 +1,21 @@
+using System.Threading;
+using System.Threading.Tasks;
+using ZendeskApi.Client.Models;
+using ZendeskApi.Client.Responses;
+
+namespace ZendeskApi.Client.Resources.Interfaces
+{
+ public interface ITagsResource
+ {
+ #region List
+ ///
+ /// Lists all tags. This request is paginated.
+ ///
+ Task> GetAllAsync(
+ CursorPager cursor,
+ CancellationToken cancellationToken = default(CancellationToken));
+
+ #endregion
+ }
+}
+
diff --git a/src/ZendeskApi.Client/Resources/TagsResource.cs b/src/ZendeskApi.Client/Resources/TagsResource.cs
new file mode 100644
index 00000000..a12c17b8
--- /dev/null
+++ b/src/ZendeskApi.Client/Resources/TagsResource.cs
@@ -0,0 +1,28 @@
+using System.Threading;
+using System.Threading.Tasks;
+using Microsoft.Extensions.Logging;
+using ZendeskApi.Client.Models;
+using ZendeskApi.Client.Resources.Interfaces;
+using ZendeskApi.Client.Responses;
+
+namespace ZendeskApi.Client.Resources
+{
+ public class TagsResource : AbstractBaseResource, ITagsResource
+ {
+ private static string ResourceUri = "/api/v2/tags";
+ public TagsResource(IZendeskApiClient apiClient, ILogger logger) : base(apiClient, logger, "tags")
+ {
+ }
+
+ public async Task> GetAllAsync(CursorPager cursor, CancellationToken cancellationToken = default)
+ {
+ return await GetAsync(
+ ResourceUri,
+ "list-tags",
+ "ListAsync",
+ cursor,
+ cancellationToken: cancellationToken);
+ }
+ }
+}
+
diff --git a/src/ZendeskApi.Client/Responses/Tag/TagResponse.cs b/src/ZendeskApi.Client/Responses/Tag/TagResponse.cs
new file mode 100644
index 00000000..c1f8a0c9
--- /dev/null
+++ b/src/ZendeskApi.Client/Responses/Tag/TagResponse.cs
@@ -0,0 +1,15 @@
+using System.Collections.Generic;
+using Newtonsoft.Json;
+using ZendeskApi.Client.Models;
+
+namespace ZendeskApi.Client.Responses
+{
+ [JsonObject]
+ public class TagResponse : CursorPaginationResponse
+ {
+ [JsonProperty("tags")]
+ public IEnumerable Tags { get; set; }
+
+ protected override IEnumerable Enumerable => Tags;
+ }
+}
\ No newline at end of file
diff --git a/src/ZendeskApi.Client/ZendeskClient.cs b/src/ZendeskApi.Client/ZendeskClient.cs
index 1e6a31ee..477ec6e2 100644
--- a/src/ZendeskApi.Client/ZendeskClient.cs
+++ b/src/ZendeskApi.Client/ZendeskClient.cs
@@ -86,5 +86,8 @@ public ZendeskClient(IZendeskApiClient apiClient, ILogger logger = null)
private Lazy LocalesLazy =>
new Lazy(() => new LocaleResource(_apiClient, _logger));
public ILocaleResource Locales => LocalesLazy.Value;
+
+ private Lazy TagsLazy => new Lazy(() => new TagsResource(_apiClient, _logger));
+ public ITagsResource Tags => TagsLazy.Value;
}
}
diff --git a/test/ZendeskApi.Client.IntegrationTests/Resources/TagsResourceTests.cs b/test/ZendeskApi.Client.IntegrationTests/Resources/TagsResourceTests.cs
new file mode 100644
index 00000000..4d653aa8
--- /dev/null
+++ b/test/ZendeskApi.Client.IntegrationTests/Resources/TagsResourceTests.cs
@@ -0,0 +1,44 @@
+using System.Linq;
+using System.Threading.Tasks;
+using Xunit;
+using ZendeskApi.Client.IntegrationTests.Factories;
+using ZendeskApi.Client.Models;
+
+namespace ZendeskApi.Client.IntegrationTests.Resources
+{
+ public class TagsResourceTest : IClassFixture
+ {
+ private readonly ZendeskClientFactory _clientFactory;
+
+ public TagsResourceTest(
+ ZendeskClientFactory clientFactory)
+ {
+ _clientFactory = clientFactory;
+ }
+
+
+ [Fact]
+ public async Task GetAllAsync_WhenCalledWithCursorPagination_ShouldBePaginatable()
+ {
+ var client = _clientFactory.GetClient();
+
+ var cursorPager = new CursorPager { Size = 5 };
+ var tagsPageOne = await client
+ .Tags.GetAllAsync(cursorPager);
+
+ Assert.NotNull(tagsPageOne);
+ Assert.Equal(5, tagsPageOne.Count());
+ Assert.True(tagsPageOne.Meta.HasMore);
+
+ cursorPager.AfterCursor = tagsPageOne.Meta.AfterCursor;
+
+ var tagsPageTwo = await client.Tags.GetAllAsync(cursorPager);
+ Assert.NotNull(tagsPageTwo);
+ Assert.Equal(5, tagsPageTwo.Count());
+
+ var tagIdsPageOne = tagsPageOne.Select(tag => tag.Name).ToList();
+ var tagIdsPageTwo = tagsPageTwo.Select(tag => tag.Name).ToList();
+ Assert.NotEqual(tagIdsPageOne, tagIdsPageTwo);
+ }
+ }
+}
\ No newline at end of file