From 88df80a9719ee3d50dbdad7b3b9d070b37802609 Mon Sep 17 00:00:00 2001 From: jcrawfor74 Date: Thu, 30 Nov 2023 09:35:48 +1100 Subject: [PATCH] Add Custom Header (#587) * Add Custom Header * Formatting fix * Format Fix #2 * Add Delay to unit test in attempt to fix test * Change Custom headers to Dictionary --- src/ZendeskApi_v2/Core.cs | 28 +++++++- .../Extensions/StringExtensions.cs | 6 +- src/ZendeskApi_v2/HelpCenterApi.cs | 26 +++---- .../Requests/AccountsAndActivity.cs | 17 ++--- src/ZendeskApi_v2/Requests/Attachments.cs | 4 +- src/ZendeskApi_v2/Requests/Automations.cs | 4 +- src/ZendeskApi_v2/Requests/Brands.cs | 8 +-- .../Requests/CustomAgentRoles.cs | 9 +-- src/ZendeskApi_v2/Requests/Groups.cs | 5 +- .../Requests/HelpCenter/ArticleAttachments.cs | 5 +- .../Requests/HelpCenter/Articles.cs | 4 +- .../Requests/HelpCenter/Categories.cs | 6 +- .../Requests/HelpCenter/Comments.cs | 5 +- .../Requests/HelpCenter/Posts.cs | 5 +- .../Requests/HelpCenter/Sections.cs | 5 +- .../Requests/HelpCenter/Topics.cs | 5 +- .../Requests/HelpCenter/Translations.cs | 4 +- .../Requests/HelpCenter/UserSegments.cs | 4 +- .../Requests/HelpCenter/Votes.cs | 6 +- src/ZendeskApi_v2/Requests/JobStatuses.cs | 9 +-- src/ZendeskApi_v2/Requests/Locales.cs | 9 +-- src/ZendeskApi_v2/Requests/Macros.cs | 9 +-- src/ZendeskApi_v2/Requests/Organizations.cs | 4 +- src/ZendeskApi_v2/Requests/Requests.cs | 8 ++- .../Requests/SatisfactionRatings.cs | 9 +-- src/ZendeskApi_v2/Requests/Schedules.cs | 6 +- src/ZendeskApi_v2/Requests/Search.cs | 7 +- .../Requests/SharingAgreements.cs | 9 +-- src/ZendeskApi_v2/Requests/Tags.cs | 8 +-- src/ZendeskApi_v2/Requests/Targets.cs | 4 +- src/ZendeskApi_v2/Requests/Tickets.cs | 4 +- src/ZendeskApi_v2/Requests/Triggers.cs | 8 +-- src/ZendeskApi_v2/Requests/Users.cs | 4 +- src/ZendeskApi_v2/Requests/Views.cs | 4 +- src/ZendeskApi_v2/Requests/Voice.cs | 5 +- src/ZendeskApi_v2/ZendeskApi.cs | 71 ++++++++++++------- tests/ZendeskApi_v2.Tests/RequestTests.cs | 4 ++ tests/ZendeskApi_v2.Tests/TicketTests.cs | 2 +- 38 files changed, 207 insertions(+), 133 deletions(-) diff --git a/src/ZendeskApi_v2/Core.cs b/src/ZendeskApi_v2/Core.cs index 3605c2aa..93baeec9 100644 --- a/src/ZendeskApi_v2/Core.cs +++ b/src/ZendeskApi_v2/Core.cs @@ -46,6 +46,8 @@ public class Core : ICore protected string Password; protected string ZendeskUrl; protected string ApiToken; + protected Dictionary CustomHeaders; + private readonly JsonSerializerSettings jsonSettings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, @@ -63,7 +65,7 @@ public class Core : ICore /// /// public Core(string zendeskApiUrl, string p_OAuthToken) : - this(zendeskApiUrl, null, null, null, p_OAuthToken) + this(zendeskApiUrl, null, null, null, p_OAuthToken, null) { } @@ -73,7 +75,7 @@ public Core(string zendeskApiUrl, string p_OAuthToken) : /// /// public Core(string zendeskApiUrl, string user, string password, string apiToken) : - this(zendeskApiUrl, user, password, apiToken, null) + this(zendeskApiUrl, user, password, apiToken, null, null) { } @@ -84,7 +86,8 @@ public Core(string zendeskApiUrl, string user, string password, string apiToken) /// /// LEAVE BLANK IF USING TOKEN /// Optional Param which is used if specified instead of the password - public Core(string zendeskApiUrl, string user, string password, string apiToken, string p_OAuthToken) + /// Optional Dictionary of custom headers that adds these headers to the request + public Core(string zendeskApiUrl, string user, string password, string apiToken, string p_OAuthToken, Dictionary customHeaders) { User = user; Password = password; @@ -96,6 +99,7 @@ public Core(string zendeskApiUrl, string user, string password, string apiToken, ZendeskUrl = zendeskApiUrl; ApiToken = apiToken; OAuthToken = p_OAuthToken; + CustomHeaders = customHeaders; } #if SYNC @@ -134,6 +138,7 @@ public RequestResult RunRequest(string resource, string requestMethod, object bo req.Headers["Authorization"] = GetPasswordOrTokenAuthHeader(); req.PreAuthenticate = true; + AddCustomHeaders(req); req.Method = requestMethod; //GET POST PUT DELETE req.Accept = "application/json, application/xml, text/json, text/x-json, text/javascript, text/xml"; @@ -386,6 +391,7 @@ public async Task RunRequestAsync(string resource, string request req.Headers["Authorization"] = GetPasswordOrTokenAuthHeader(); req.Method = requestMethod; //GET POST PUT DELETE req.Accept = "application/json, application/xml, text/json, text/x-json, text/javascript, text/xml"; + AddCustomHeaders(req); byte[] data = null; @@ -620,5 +626,21 @@ private WebException GetWebException(string resource, object body, WebException return wException; } + + /// + /// If the CustomHeaders Dictionary contains records then add them to the headers + /// of the passed in request + /// + /// + private void AddCustomHeaders(HttpWebRequest request) + { + if (CustomHeaders != null) + { + foreach (var key in CustomHeaders.Keys) + { + request.Headers.Add(key, CustomHeaders[key]); + } + } + } } } diff --git a/src/ZendeskApi_v2/Extensions/StringExtensions.cs b/src/ZendeskApi_v2/Extensions/StringExtensions.cs index 8f66029b..cd8f503b 100644 --- a/src/ZendeskApi_v2/Extensions/StringExtensions.cs +++ b/src/ZendeskApi_v2/Extensions/StringExtensions.cs @@ -1,4 +1,6 @@ -namespace ZendeskApi_v2.Extensions +using ZendeskApi_v2.Models.Shared; + +namespace ZendeskApi_v2.Extensions { internal static class StringExtensions { @@ -22,5 +24,7 @@ internal static bool IsNullOrWhiteSpace(this string value) return true; } + + internal static bool IsNotNullOrWhiteSpace(this string value) => !IsNullOrWhiteSpace(value); } } diff --git a/src/ZendeskApi_v2/HelpCenterApi.cs b/src/ZendeskApi_v2/HelpCenterApi.cs index d37c3932..e7e68651 100644 --- a/src/ZendeskApi_v2/HelpCenterApi.cs +++ b/src/ZendeskApi_v2/HelpCenterApi.cs @@ -1,4 +1,5 @@ -using ZendeskApi_v2.Requests.HelpCenter; +using System.Collections.Generic; +using ZendeskApi_v2.Requests.HelpCenter; namespace ZendeskApi_v2.HelpCenter { @@ -25,19 +26,20 @@ public HelpCenterApi( string password, string apiToken, string locale, - string p_OAuthToken) + string p_OAuthToken, + Dictionary customHeaders) { - Categories = new Categories(yourZendeskUrl, user, password, apiToken, locale, p_OAuthToken); - Sections = new Sections(yourZendeskUrl, user, password, apiToken, locale, p_OAuthToken); - Articles = new Articles(yourZendeskUrl, user, password, apiToken, locale, p_OAuthToken); - Translations = new Translations(yourZendeskUrl, user, password, apiToken, p_OAuthToken); - Votes = new Votes(yourZendeskUrl, user, password, apiToken, p_OAuthToken); - Comments = new Comments(yourZendeskUrl, user, password, apiToken, p_OAuthToken); - UserSegments = new UserSegments(yourZendeskUrl, user, password, apiToken, p_OAuthToken); - Topics = new Topics(yourZendeskUrl, user, password, apiToken, p_OAuthToken); - Posts = new Posts(yourZendeskUrl, user, password, apiToken, p_OAuthToken); + Categories = new Categories(yourZendeskUrl, user, password, apiToken, locale, p_OAuthToken, customHeaders); + Sections = new Sections(yourZendeskUrl, user, password, apiToken, locale, p_OAuthToken, customHeaders); + Articles = new Articles(yourZendeskUrl, user, password, apiToken, locale, p_OAuthToken, customHeaders); + Translations = new Translations(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders); + Votes = new Votes(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders); + Comments = new Comments(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders); + UserSegments = new UserSegments(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders); + Topics = new Topics(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders); + Posts = new Posts(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders); Locale = locale; - ArticleAttachments = new ArticleAttachments(yourZendeskUrl, user, password, apiToken, locale, p_OAuthToken); + ArticleAttachments = new ArticleAttachments(yourZendeskUrl, user, password, apiToken, locale, p_OAuthToken, customHeaders); } public ICategories Categories { get; } diff --git a/src/ZendeskApi_v2/Requests/AccountsAndActivity.cs b/src/ZendeskApi_v2/Requests/AccountsAndActivity.cs index 27ce5131..a025ddeb 100644 --- a/src/ZendeskApi_v2/Requests/AccountsAndActivity.cs +++ b/src/ZendeskApi_v2/Requests/AccountsAndActivity.cs @@ -1,4 +1,5 @@ -#if ASYNC +#if ASYNC +using System.Collections.Generic; using System.Threading.Tasks; #endif using ZendeskApi_v2.Models.AccountsAndActivities; @@ -15,16 +16,16 @@ public interface IAccountsAndActivity : ICore #if ASYNC Task GetSettingsAsync(); - Task GetActivitiesAync(); - Task GetActivityByIdAync(long activityId); + Task GetActivitiesAsync(); + Task GetActivityByIdAsync(long activityId); #endif } public class AccountsAndActivity : Core, IAccountsAndActivity { - public AccountsAndActivity(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken) - : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken) + public AccountsAndActivity(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken, Dictionary customHeaders) + : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders) { } #if SYNC @@ -49,15 +50,15 @@ public async Task GetSettingsAsync() { return await GenericGetAsync("account/settings.json"); } - public async Task GetActivitiesAync() + public async Task GetActivitiesAsync() { return await GenericGetAsync("activities.json"); } - public async Task GetActivityByIdAync(long activityId) + public async Task GetActivityByIdAsync(long activityId) { return await GenericGetAsync($"activities/{activityId}.json"); } #endif } -} \ No newline at end of file +} diff --git a/src/ZendeskApi_v2/Requests/Attachments.cs b/src/ZendeskApi_v2/Requests/Attachments.cs index ba14fc7d..b6deae6f 100644 --- a/src/ZendeskApi_v2/Requests/Attachments.cs +++ b/src/ZendeskApi_v2/Requests/Attachments.cs @@ -45,8 +45,8 @@ public interface IAttachments : ICore public class Attachments : Core, IAttachments { - public Attachments(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken) - : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken) + public Attachments(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken, Dictionary customHeaders) + : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders) { } #if SYNC diff --git a/src/ZendeskApi_v2/Requests/Automations.cs b/src/ZendeskApi_v2/Requests/Automations.cs index 6c4a3568..777c0ade 100644 --- a/src/ZendeskApi_v2/Requests/Automations.cs +++ b/src/ZendeskApi_v2/Requests/Automations.cs @@ -35,8 +35,8 @@ public interface IAutomations : ICore public class Automations : Core, IAutomations { - public Automations(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken) - : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken) + public Automations(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken, Dictionary customHeaders) + : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders) { } diff --git a/src/ZendeskApi_v2/Requests/Brands.cs b/src/ZendeskApi_v2/Requests/Brands.cs index f9f20af3..7af1ad5b 100644 --- a/src/ZendeskApi_v2/Requests/Brands.cs +++ b/src/ZendeskApi_v2/Requests/Brands.cs @@ -1,4 +1,4 @@ -#if ASYNC +#if ASYNC using System.Threading.Tasks; #endif using System.Collections.Generic; @@ -28,8 +28,8 @@ public interface IBrands : ICore public class Brands : Core, IBrands { - public Brands(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken) - : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken) + public Brands(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken, Dictionary customHeaders) + : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders) { } @@ -91,4 +91,4 @@ public async Task DeleteBrandAsync(long id) } #endif } -} \ No newline at end of file +} diff --git a/src/ZendeskApi_v2/Requests/CustomAgentRoles.cs b/src/ZendeskApi_v2/Requests/CustomAgentRoles.cs index d49d4043..674659e6 100644 --- a/src/ZendeskApi_v2/Requests/CustomAgentRoles.cs +++ b/src/ZendeskApi_v2/Requests/CustomAgentRoles.cs @@ -1,4 +1,5 @@ -#if ASYNC +#if ASYNC +using System.Collections.Generic; using System.Threading.Tasks; #endif using ZendeskApi_v2.Models.CustomRoles; @@ -18,8 +19,8 @@ public interface ICustomAgentRoles : ICore public class CustomAgentRoles : Core, ICustomAgentRoles { - public CustomAgentRoles(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken) - : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken) + public CustomAgentRoles(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken, Dictionary customHeaders) + : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders) { } @@ -37,4 +38,4 @@ public async Task GetCustomRolesAsync() } #endif } -} \ No newline at end of file +} diff --git a/src/ZendeskApi_v2/Requests/Groups.cs b/src/ZendeskApi_v2/Requests/Groups.cs index 1b362af2..19752d43 100644 --- a/src/ZendeskApi_v2/Requests/Groups.cs +++ b/src/ZendeskApi_v2/Requests/Groups.cs @@ -1,4 +1,5 @@ #if ASYNC +using System.Collections.Generic; using System.Threading.Tasks; #endif using ZendeskApi_v2.Models.Groups; @@ -68,8 +69,8 @@ public interface IGroups : ICore public class Groups : Core, IGroups { - public Groups(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken) - : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken) + public Groups(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken, Dictionary customHeaders) + : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders) { } diff --git a/src/ZendeskApi_v2/Requests/HelpCenter/ArticleAttachments.cs b/src/ZendeskApi_v2/Requests/HelpCenter/ArticleAttachments.cs index 4d666779..2606ad91 100644 --- a/src/ZendeskApi_v2/Requests/HelpCenter/ArticleAttachments.cs +++ b/src/ZendeskApi_v2/Requests/HelpCenter/ArticleAttachments.cs @@ -38,8 +38,9 @@ public ArticleAttachments( string password, string apiToken, string locale, - string p_OAuthToken) - : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken) + string p_OAuthToken, + Dictionary customHeaders) + : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders) { _locale = locale; } diff --git a/src/ZendeskApi_v2/Requests/HelpCenter/Articles.cs b/src/ZendeskApi_v2/Requests/HelpCenter/Articles.cs index 8b8fcb2d..e8657152 100644 --- a/src/ZendeskApi_v2/Requests/HelpCenter/Articles.cs +++ b/src/ZendeskApi_v2/Requests/HelpCenter/Articles.cs @@ -93,8 +93,8 @@ public class Articles : Core, IArticles { private readonly string urlPrefix = "help_center"; - public Articles(string yourZendeskUrl, string user, string password, string apiToken, string locale, string p_OAuthToken) - : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken) + public Articles(string yourZendeskUrl, string user, string password, string apiToken, string locale, string p_OAuthToken, Dictionary customHeaders) + : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders) { if (!locale.IsNullOrWhiteSpace()) { diff --git a/src/ZendeskApi_v2/Requests/HelpCenter/Categories.cs b/src/ZendeskApi_v2/Requests/HelpCenter/Categories.cs index 2eff06a8..edc0ddad 100644 --- a/src/ZendeskApi_v2/Requests/HelpCenter/Categories.cs +++ b/src/ZendeskApi_v2/Requests/HelpCenter/Categories.cs @@ -1,5 +1,7 @@  using ZendeskApi_v2.Models.HelpCenter.Categories; +using System.Collections.Generic; + #if ASYNC using System.Threading.Tasks; #endif @@ -36,8 +38,8 @@ public class Categories : Core, ICategories ? "help_center/categories" : $"help_center/{Locale}/categories"; - public Categories(string yourZendeskUrl, string user, string password, string apiToken, string locale, string p_OAuthToken) - : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken) + public Categories(string yourZendeskUrl, string user, string password, string apiToken, string locale, string p_OAuthToken, Dictionary customHeaders) + : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders) { Locale = locale; } diff --git a/src/ZendeskApi_v2/Requests/HelpCenter/Comments.cs b/src/ZendeskApi_v2/Requests/HelpCenter/Comments.cs index e096661c..f94847ba 100644 --- a/src/ZendeskApi_v2/Requests/HelpCenter/Comments.cs +++ b/src/ZendeskApi_v2/Requests/HelpCenter/Comments.cs @@ -1,4 +1,5 @@ #if ASYNC +using System.Collections.Generic; using System.Threading.Tasks; #endif using ZendeskApi_v2.Models.HelpCenter.Comments; @@ -40,8 +41,8 @@ public interface IComments : ICore /// public class Comments : Core, IComments { - public Comments(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken) - : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken) + public Comments(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken, Dictionary customHeaders) + : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders) { } diff --git a/src/ZendeskApi_v2/Requests/HelpCenter/Posts.cs b/src/ZendeskApi_v2/Requests/HelpCenter/Posts.cs index f6bf2247..ac4e4d2c 100644 --- a/src/ZendeskApi_v2/Requests/HelpCenter/Posts.cs +++ b/src/ZendeskApi_v2/Requests/HelpCenter/Posts.cs @@ -1,4 +1,5 @@ #if ASYNC +using System.Collections.Generic; using System.Threading.Tasks; #endif using ZendeskApi_v2.Models.HelpCenter.Post; @@ -38,8 +39,8 @@ public interface IPosts : ICore public class Posts : Core, IPosts { - public Posts(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken) - : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken) + public Posts(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken, Dictionary customHeaders) + : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders) { } #if SYNC diff --git a/src/ZendeskApi_v2/Requests/HelpCenter/Sections.cs b/src/ZendeskApi_v2/Requests/HelpCenter/Sections.cs index 57d6c03f..23f700f5 100644 --- a/src/ZendeskApi_v2/Requests/HelpCenter/Sections.cs +++ b/src/ZendeskApi_v2/Requests/HelpCenter/Sections.cs @@ -1,4 +1,5 @@ #if ASYNC +using System.Collections.Generic; using System.Threading.Tasks; using ZendeskApi_v2.Models.HelpCenter.Subscriptions; #endif @@ -42,8 +43,8 @@ public class Sections : Core, ISections private readonly string _locale; private readonly string _generalSectionsPath; - public Sections(string yourZendeskUrl, string user, string password, string apiToken, string locale, string p_OAuthToken) - : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken) + public Sections(string yourZendeskUrl, string user, string password, string apiToken, string locale, string p_OAuthToken, Dictionary customHeaders) + : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders) { _locale = locale; _generalSectionsPath = string.IsNullOrWhiteSpace(_locale) ? "help_center/sections" : $"help_center/{_locale}/sections"; diff --git a/src/ZendeskApi_v2/Requests/HelpCenter/Topics.cs b/src/ZendeskApi_v2/Requests/HelpCenter/Topics.cs index fbce8db5..5d0d0c4f 100644 --- a/src/ZendeskApi_v2/Requests/HelpCenter/Topics.cs +++ b/src/ZendeskApi_v2/Requests/HelpCenter/Topics.cs @@ -1,4 +1,5 @@ #if ASYNC +using System.Collections.Generic; using System.Threading.Tasks; using ZendeskApi_v2.Models.HelpCenter.Subscriptions; #endif @@ -36,8 +37,8 @@ public interface ITopics : ICore public class Topics : Core, ITopics { - public Topics(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken) - : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken) + public Topics(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken, Dictionary customHeaders) + : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders) { } #if SYNC diff --git a/src/ZendeskApi_v2/Requests/HelpCenter/Translations.cs b/src/ZendeskApi_v2/Requests/HelpCenter/Translations.cs index 2b0d65b9..651e93f9 100644 --- a/src/ZendeskApi_v2/Requests/HelpCenter/Translations.cs +++ b/src/ZendeskApi_v2/Requests/HelpCenter/Translations.cs @@ -66,8 +66,8 @@ public interface ITranslations : ICore public class Translations : Core, ITranslations { - public Translations( string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken ) - : base( yourZendeskUrl, user, password, apiToken, p_OAuthToken ) + public Translations( string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken, Dictionary customHeaders) + : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders) { } diff --git a/src/ZendeskApi_v2/Requests/HelpCenter/UserSegments.cs b/src/ZendeskApi_v2/Requests/HelpCenter/UserSegments.cs index 6f090348..a50ec60e 100644 --- a/src/ZendeskApi_v2/Requests/HelpCenter/UserSegments.cs +++ b/src/ZendeskApi_v2/Requests/HelpCenter/UserSegments.cs @@ -56,8 +56,8 @@ public interface IUserSegments : ICore public class UserSegments : Core, IUserSegments { - public UserSegments(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken) - : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken) + public UserSegments(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken, Dictionary customHeaders) + : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders) { } diff --git a/src/ZendeskApi_v2/Requests/HelpCenter/Votes.cs b/src/ZendeskApi_v2/Requests/HelpCenter/Votes.cs index 9bded155..cace3cce 100644 --- a/src/ZendeskApi_v2/Requests/HelpCenter/Votes.cs +++ b/src/ZendeskApi_v2/Requests/HelpCenter/Votes.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; + #if ASYNC using System.Threading.Tasks; #endif @@ -21,8 +23,8 @@ public interface IVotes : ICore public class Votes : Core, IVotes { - public Votes(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken) - : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken) + public Votes(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken, Dictionary customHeaders) + : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders) { } diff --git a/src/ZendeskApi_v2/Requests/JobStatuses.cs b/src/ZendeskApi_v2/Requests/JobStatuses.cs index 80354e52..8a169e9c 100644 --- a/src/ZendeskApi_v2/Requests/JobStatuses.cs +++ b/src/ZendeskApi_v2/Requests/JobStatuses.cs @@ -1,4 +1,5 @@ -#if ASYNC +#if ASYNC +using System.Collections.Generic; using System.Threading.Tasks; #endif using ZendeskApi_v2.Models.Shared; @@ -19,8 +20,8 @@ public interface IJobStatuses : ICore public class JobStatuses : Core, IJobStatuses { - public JobStatuses(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken) - : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken) + public JobStatuses(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken, Dictionary customHeaders) + : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders) { } @@ -38,4 +39,4 @@ public async Task GetJobStatusAsync(string id) } #endif } -} \ No newline at end of file +} diff --git a/src/ZendeskApi_v2/Requests/Locales.cs b/src/ZendeskApi_v2/Requests/Locales.cs index 338b59c8..36a5149d 100644 --- a/src/ZendeskApi_v2/Requests/Locales.cs +++ b/src/ZendeskApi_v2/Requests/Locales.cs @@ -1,4 +1,5 @@ -#if ASYNC +#if ASYNC +using System.Collections.Generic; using System.Threading.Tasks; #endif using ZendeskApi_v2.Models.Locales; @@ -63,8 +64,8 @@ public interface ILocales : ICore public class Locales : Core, ILocales { - public Locales(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken) - : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken) + public Locales(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken, Dictionary customHeaders) + : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders) { } @@ -144,4 +145,4 @@ public async Task GetCurrentLocaleAsync(bool translati } #endif } -} \ No newline at end of file +} diff --git a/src/ZendeskApi_v2/Requests/Macros.cs b/src/ZendeskApi_v2/Requests/Macros.cs index 25e5a5cc..1e898d31 100644 --- a/src/ZendeskApi_v2/Requests/Macros.cs +++ b/src/ZendeskApi_v2/Requests/Macros.cs @@ -1,4 +1,5 @@ -#if ASYNC +#if ASYNC +using System.Collections.Generic; using System.Threading.Tasks; #endif using ZendeskApi_v2.Models.Macros; @@ -80,8 +81,8 @@ public interface IMacros : ICore public class Macros : Core, IMacros { - public Macros(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken) - : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken) + public Macros(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken, Dictionary customHeaders) + : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders) { } @@ -211,4 +212,4 @@ public async Task ApplyMacroToTicketAsync(long ticketId, lon } #endif } -} \ No newline at end of file +} diff --git a/src/ZendeskApi_v2/Requests/Organizations.cs b/src/ZendeskApi_v2/Requests/Organizations.cs index c4a4ab01..8f32a718 100644 --- a/src/ZendeskApi_v2/Requests/Organizations.cs +++ b/src/ZendeskApi_v2/Requests/Organizations.cs @@ -111,8 +111,8 @@ public class Organizations : Core, IOrganizations { private const string _incremental_export = "incremental/organizations.json?start_time="; - public Organizations(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken) - : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken) + public Organizations(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken, Dictionary customHeaders) + : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders) { } diff --git a/src/ZendeskApi_v2/Requests/Requests.cs b/src/ZendeskApi_v2/Requests/Requests.cs index f34dcd11..af730b20 100644 --- a/src/ZendeskApi_v2/Requests/Requests.cs +++ b/src/ZendeskApi_v2/Requests/Requests.cs @@ -1,4 +1,6 @@ -using System; +using System; +using System.Collections.Generic; + #if ASYNC using System.Threading.Tasks; #endif @@ -111,8 +113,8 @@ public interface IRequests : ICore public class Requests : Core, IRequests { - public Requests(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken) - : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken) + public Requests(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken, Dictionary customHeaders) + : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders) { } diff --git a/src/ZendeskApi_v2/Requests/SatisfactionRatings.cs b/src/ZendeskApi_v2/Requests/SatisfactionRatings.cs index 4726e2f9..81be1996 100644 --- a/src/ZendeskApi_v2/Requests/SatisfactionRatings.cs +++ b/src/ZendeskApi_v2/Requests/SatisfactionRatings.cs @@ -1,4 +1,5 @@ -#if ASYNC +#if ASYNC +using System.Collections.Generic; using System.Threading.Tasks; #endif using ZendeskApi_v2.Models.Satisfaction; @@ -42,8 +43,8 @@ public interface ISatisfactionRatings : ICore public class SatisfactionRatings : Core, ISatisfactionRatings { - public SatisfactionRatings(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken) - : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken) + public SatisfactionRatings(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken, Dictionary customHeaders) + : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders) { } @@ -97,4 +98,4 @@ public async Task GetSatisfactionRatingByIdAsync } #endif } -} \ No newline at end of file +} diff --git a/src/ZendeskApi_v2/Requests/Schedules.cs b/src/ZendeskApi_v2/Requests/Schedules.cs index e7d276ce..23df3427 100644 --- a/src/ZendeskApi_v2/Requests/Schedules.cs +++ b/src/ZendeskApi_v2/Requests/Schedules.cs @@ -39,8 +39,8 @@ public interface ISchedules : ICore } public class Schedules : Core, ISchedules { - public Schedules(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken) - : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken) + public Schedules(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken, Dictionary customHeaders) + : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders) { } @@ -166,4 +166,4 @@ public async Task DeleteHolidayAsync(long scheduleId, long holidayId) } #endif } -} \ No newline at end of file +} diff --git a/src/ZendeskApi_v2/Requests/Search.cs b/src/ZendeskApi_v2/Requests/Search.cs index 79734b37..7e0d73fb 100644 --- a/src/ZendeskApi_v2/Requests/Search.cs +++ b/src/ZendeskApi_v2/Requests/Search.cs @@ -1,4 +1,4 @@ - + using System; using System.Linq; using ZendeskApi_v2.Models; @@ -10,6 +10,7 @@ using ZendeskApi_v2.Models.Search; using ZendeskApi_v2.Models.Tickets; using ZendeskApi_v2.Models.Users; +using System.Collections.Generic; namespace ZendeskApi_v2.Requests { @@ -106,8 +107,8 @@ public interface ISearch : ICore /// public class Search : Core, ISearch { - public Search(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken) - : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken) + public Search(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken, Dictionary customHeaders) + : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders) { } diff --git a/src/ZendeskApi_v2/Requests/SharingAgreements.cs b/src/ZendeskApi_v2/Requests/SharingAgreements.cs index 731372ce..bbeb024b 100644 --- a/src/ZendeskApi_v2/Requests/SharingAgreements.cs +++ b/src/ZendeskApi_v2/Requests/SharingAgreements.cs @@ -1,4 +1,5 @@ -#if ASYNC +#if ASYNC +using System.Collections.Generic; using System.Threading.Tasks; #endif using ZendeskApi_v2.Models.SharingAgreements; @@ -19,8 +20,8 @@ public interface ISharingAgreements : ICore public class SharingAgreements : Core, ISharingAgreements { - public SharingAgreements(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken) - : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken) + public SharingAgreements(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken, Dictionary customHeaders) + : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders) { } @@ -38,4 +39,4 @@ public async Task GetSharingAgreementsAsync() } #endif } -} \ No newline at end of file +} diff --git a/src/ZendeskApi_v2/Requests/Tags.cs b/src/ZendeskApi_v2/Requests/Tags.cs index dec15ace..58d63794 100644 --- a/src/ZendeskApi_v2/Requests/Tags.cs +++ b/src/ZendeskApi_v2/Requests/Tags.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; #if ASYNC using System.Threading.Tasks; #endif @@ -33,8 +33,8 @@ public interface ITags : ICore public class Tags : Core, ITags { - public Tags(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken) - : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken) + public Tags(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken, Dictionary customHeaders) + : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders) { } @@ -72,4 +72,4 @@ public async Task AutocompleteTagsAsync(string name) } #endif } -} \ No newline at end of file +} diff --git a/src/ZendeskApi_v2/Requests/Targets.cs b/src/ZendeskApi_v2/Requests/Targets.cs index 8d970379..1debcf03 100644 --- a/src/ZendeskApi_v2/Requests/Targets.cs +++ b/src/ZendeskApi_v2/Requests/Targets.cs @@ -26,8 +26,8 @@ public interface ITargets : ICore } public class Targets : Core, ITargets { - public Targets(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken) - : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken) + public Targets(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken, Dictionary customHeaders) + : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders) { } diff --git a/src/ZendeskApi_v2/Requests/Tickets.cs b/src/ZendeskApi_v2/Requests/Tickets.cs index 1e21af56..6050d7a3 100644 --- a/src/ZendeskApi_v2/Requests/Tickets.cs +++ b/src/ZendeskApi_v2/Requests/Tickets.cs @@ -291,8 +291,8 @@ public class Tickets : Core, ITickets private const string _ticket_metrics = "ticket_metrics"; private const string _incremental_export = "incremental/tickets.json?start_time="; - public Tickets(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken) - : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken) + public Tickets(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken, Dictionary customHeaders) + : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders) { } diff --git a/src/ZendeskApi_v2/Requests/Triggers.cs b/src/ZendeskApi_v2/Requests/Triggers.cs index bd64a6ce..a717d4f9 100644 --- a/src/ZendeskApi_v2/Requests/Triggers.cs +++ b/src/ZendeskApi_v2/Requests/Triggers.cs @@ -1,4 +1,4 @@ -#if ASYNC +#if ASYNC using System.Threading.Tasks; #endif using System.Collections.Generic; @@ -31,8 +31,8 @@ public interface ITriggers : ICore public class Triggers : Core, ITriggers { - public Triggers(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken) - : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken) + public Triggers(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken, Dictionary customHeaders) + : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders) { } @@ -116,4 +116,4 @@ public async Task ReorderTriggersAsync(IEnumerable trigger_ids) } #endif } -} \ No newline at end of file +} diff --git a/src/ZendeskApi_v2/Requests/Users.cs b/src/ZendeskApi_v2/Requests/Users.cs index a953d05f..a5c2c88d 100644 --- a/src/ZendeskApi_v2/Requests/Users.cs +++ b/src/ZendeskApi_v2/Requests/Users.cs @@ -214,8 +214,8 @@ public class Users : Core, IUsers { private const string _incremental_export = "incremental/users.json?start_time="; - public Users(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken) - : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken) + public Users(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken, Dictionary customHeaders) + : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders) { } diff --git a/src/ZendeskApi_v2/Requests/Views.cs b/src/ZendeskApi_v2/Requests/Views.cs index 4595b0f9..48fc02ce 100644 --- a/src/ZendeskApi_v2/Requests/Views.cs +++ b/src/ZendeskApi_v2/Requests/Views.cs @@ -38,8 +38,8 @@ public interface IViews : ICore public class Views : Core, IViews { - public Views(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken) - : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken) + public Views(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken, Dictionary customHeaders) + : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders) { } diff --git a/src/ZendeskApi_v2/Requests/Voice.cs b/src/ZendeskApi_v2/Requests/Voice.cs index 84a92f6d..29eb5577 100644 --- a/src/ZendeskApi_v2/Requests/Voice.cs +++ b/src/ZendeskApi_v2/Requests/Voice.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Net; #if ASYNC using System.Threading.Tasks; @@ -37,8 +38,8 @@ class Voice : Core, IVoice private const string currentQueueActivity = "channels/voice/stats/current_queue_activity"; private const string accountOverview = "channels/voice/stats/account_overview"; - public Voice(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken) - : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken) + public Voice(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken, Dictionary customHeaders) + : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken, customHeaders) { } diff --git a/src/ZendeskApi_v2/ZendeskApi.cs b/src/ZendeskApi_v2/ZendeskApi.cs index 1ebf8136..3c07a735 100644 --- a/src/ZendeskApi_v2/ZendeskApi.cs +++ b/src/ZendeskApi_v2/ZendeskApi.cs @@ -2,6 +2,7 @@ using ZendeskApi_v2.Requests; using System.Net; using ZendeskApi_v2.HelpCenter; +using System.Collections.Generic; #if Net35 using System.Web; @@ -118,37 +119,57 @@ public ZendeskApi(string yourZendeskUrl, string password, string apiToken, string locale, - string p_OAuthToken) + string p_OAuthToken) : this(yourZendeskUrl,user,password, apiToken,locale, p_OAuthToken, null) + { + } + + /// + /// Constructor that takes 7 params. + /// + /// Will be formatted to "https://yoursite.zendesk.com/api/v2" + /// Email address of the user + /// LEAVE BLANK IF USING TOKEN + /// Used if specified instead of the password + /// Locale to use for Help Center requests. Defaults to "en-us" if no value is provided. + /// Authentication token + /// The name of the custom header + /// The value to store in the header + public ZendeskApi(string yourZendeskUrl, + string user, + string password, + string apiToken, + string locale, + string p_OAuthToken, + Dictionary customHeaders) { var formattedUrl = GetFormattedZendeskUrl(yourZendeskUrl).AbsoluteUri; - Tickets = new Tickets(formattedUrl, user, password, apiToken, p_OAuthToken); - Attachments = new Attachments(formattedUrl, user, password, apiToken, p_OAuthToken); - Brands = new Brands(formattedUrl, user, password, apiToken, p_OAuthToken); - Views = new Views(formattedUrl, user, password, apiToken, p_OAuthToken); - Users = new Users(formattedUrl, user, password, apiToken, p_OAuthToken); - Requests = new Requests.Requests(formattedUrl, user, password, apiToken, p_OAuthToken); - Groups = new Groups(formattedUrl, user, password, apiToken, p_OAuthToken); - CustomAgentRoles = new CustomAgentRoles(formattedUrl, user, password, apiToken, p_OAuthToken); - Organizations = new Organizations(formattedUrl, user, password, apiToken, p_OAuthToken); - Search = new Search(formattedUrl, user, password, apiToken, p_OAuthToken); - Tags = new Tags(formattedUrl, user, password, apiToken, p_OAuthToken); - AccountsAndActivity = new AccountsAndActivity(formattedUrl, user, password, apiToken, p_OAuthToken); - JobStatuses = new JobStatuses(formattedUrl, user, password, apiToken, p_OAuthToken); - Locales = new Locales(formattedUrl, user, password, apiToken, p_OAuthToken); - Macros = new Macros(formattedUrl, user, password, apiToken, p_OAuthToken); - SatisfactionRatings = new SatisfactionRatings(formattedUrl, user, password, apiToken, p_OAuthToken); - SharingAgreements = new SharingAgreements(formattedUrl, user, password, apiToken, p_OAuthToken); - Triggers = new Triggers(formattedUrl, user, password, apiToken, p_OAuthToken); - HelpCenter = new HelpCenterApi(formattedUrl, user, password, apiToken, locale, p_OAuthToken); - Voice = new Voice(formattedUrl, user, password, apiToken, p_OAuthToken); - Schedules = new Schedules(formattedUrl, user, password, apiToken, p_OAuthToken); - Targets = new Targets(formattedUrl, user, password, apiToken, p_OAuthToken); - Automations = new Automations(formattedUrl, user, password, apiToken, p_OAuthToken); + Tickets = new Tickets(formattedUrl, user, password, apiToken, p_OAuthToken, customHeaders); + Attachments = new Attachments(formattedUrl, user, password, apiToken, p_OAuthToken, customHeaders); + Brands = new Brands(formattedUrl, user, password, apiToken, p_OAuthToken, customHeaders); + Views = new Views(formattedUrl, user, password, apiToken, p_OAuthToken, customHeaders); + Users = new Users(formattedUrl, user, password, apiToken, p_OAuthToken, customHeaders); + Requests = new Requests.Requests(formattedUrl, user, password, apiToken, p_OAuthToken, customHeaders); + Groups = new Groups(formattedUrl, user, password, apiToken, p_OAuthToken, customHeaders); + CustomAgentRoles = new CustomAgentRoles(formattedUrl, user, password, apiToken, p_OAuthToken, customHeaders); + Organizations = new Organizations(formattedUrl, user, password, apiToken, p_OAuthToken, customHeaders); + Search = new Search(formattedUrl, user, password, apiToken, p_OAuthToken, customHeaders); + Tags = new Tags(formattedUrl, user, password, apiToken, p_OAuthToken, customHeaders); + AccountsAndActivity = new AccountsAndActivity(formattedUrl, user, password, apiToken, p_OAuthToken, customHeaders); + JobStatuses = new JobStatuses(formattedUrl, user, password, apiToken, p_OAuthToken, customHeaders); + Locales = new Locales(formattedUrl, user, password, apiToken, p_OAuthToken, customHeaders); + Macros = new Macros(formattedUrl, user, password, apiToken, p_OAuthToken, customHeaders); + SatisfactionRatings = new SatisfactionRatings(formattedUrl, user, password, apiToken, p_OAuthToken, customHeaders); + SharingAgreements = new SharingAgreements(formattedUrl, user, password, apiToken, p_OAuthToken, customHeaders); + Triggers = new Triggers(formattedUrl, user, password, apiToken, p_OAuthToken, customHeaders); + HelpCenter = new HelpCenterApi(formattedUrl, user, password, apiToken, locale, p_OAuthToken, customHeaders); + Voice = new Voice(formattedUrl, user, password, apiToken, p_OAuthToken, customHeaders); + Schedules = new Schedules(formattedUrl, user, password, apiToken, p_OAuthToken, customHeaders); + Targets = new Targets(formattedUrl, user, password, apiToken, p_OAuthToken, customHeaders); + Automations = new Automations(formattedUrl, user, password, apiToken, p_OAuthToken, customHeaders); ZendeskUrl = formattedUrl; } - #if SYNC /// diff --git a/tests/ZendeskApi_v2.Tests/RequestTests.cs b/tests/ZendeskApi_v2.Tests/RequestTests.cs index b0e5da5c..f7e74931 100644 --- a/tests/ZendeskApi_v2.Tests/RequestTests.cs +++ b/tests/ZendeskApi_v2.Tests/RequestTests.cs @@ -1,6 +1,7 @@ using NUnit.Framework; using System.Collections.Generic; using System.Linq; +using System.Threading; using ZendeskApi_v2.Models.Requests; using ZendeskApi_v2.Models.Tickets; using ZendeskApi_v2.Tests.Base; @@ -159,6 +160,7 @@ public void CanCreateAndUpdateRequests() }; var res = Api.Requests.CreateRequest(req); + Thread.Sleep(500); // delay after create or update try { @@ -186,6 +188,8 @@ public void CanCreateAndUpdateRequests() Public = true }; _ = Api.Requests.UpdateRequest(res1.Request); + Thread.Sleep(500); // delay after create or update + var res3 = Api.Requests.GetRequestCommentsById(res.Request.Id.Value); var comment = res3.Comments.OrderBy(c => c.CreatedAt).Last(); diff --git a/tests/ZendeskApi_v2.Tests/TicketTests.cs b/tests/ZendeskApi_v2.Tests/TicketTests.cs index 8c6bebd0..85093c72 100644 --- a/tests/ZendeskApi_v2.Tests/TicketTests.cs +++ b/tests/ZendeskApi_v2.Tests/TicketTests.cs @@ -1506,7 +1506,7 @@ public async Task ViaChannel_Set_To_API_Issue_254() Assert.That(newTicket.Via.Channel, Is.EqualTo("api")); var comment = new Comment { Body = secondCommentBody, Public = true }; - + await Task.Delay(1000); var resp2 = await Api.Tickets.UpdateTicketAsync(newTicket, comment); await Task.Delay(2000); var resp3 = await Api.Tickets.GetTicketCommentsAsync(newTicket.Id.Value);