diff --git a/src/ZendeskApi_v2/Models/Categories/Category.cs b/src/ZendeskApi_v2/Models/Categories/Category.cs deleted file mode 100644 index 6bd62c2d..00000000 --- a/src/ZendeskApi_v2/Models/Categories/Category.cs +++ /dev/null @@ -1,35 +0,0 @@ -// JSON C# Class Generator -// http://at-my-window.blogspot.com/?page=json-class-generator - -using System; -using System.Collections.Generic; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; - -namespace ZendeskApi_v2.Models.Categories -{ - - public class Category - { - [JsonProperty("id")] - public long? Id { get; set; } - - [JsonProperty("name")] - public string Name { get; set; } - - [JsonProperty("description")] - public string Description { get; set; } - - [JsonProperty("position")] - public int Position { get; set; } - - [JsonProperty("created_at")] - [JsonConverter(typeof(IsoDateTimeConverter))] - public DateTimeOffset? CreatedAt { get; set; } - - [JsonProperty("updated_at")] - [JsonConverter(typeof(IsoDateTimeConverter))] - public DateTimeOffset? UpdatedAt { get; set; } - } -} diff --git a/src/ZendeskApi_v2/Models/Categories/GroupCategoryResponse.cs b/src/ZendeskApi_v2/Models/Categories/GroupCategoryResponse.cs deleted file mode 100644 index 1232f2c0..00000000 --- a/src/ZendeskApi_v2/Models/Categories/GroupCategoryResponse.cs +++ /dev/null @@ -1,18 +0,0 @@ -// JSON C# Class Generator -// http://at-my-window.blogspot.com/?page=json-class-generator - -using System; -using System.Collections.Generic; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace ZendeskApi_v2.Models.Categories -{ - - public class GroupCategoryResponse : GroupResponseBase - { - - [JsonProperty("categories")] - public IList Categories { get; set; } - } -} diff --git a/src/ZendeskApi_v2/Models/Categories/IndividualCategoryResponse.cs b/src/ZendeskApi_v2/Models/Categories/IndividualCategoryResponse.cs deleted file mode 100644 index cc14c8e3..00000000 --- a/src/ZendeskApi_v2/Models/Categories/IndividualCategoryResponse.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Newtonsoft.Json; - -namespace ZendeskApi_v2.Models.Categories -{ - public class IndividualCategoryResponse - { - - [JsonProperty("category")] - public Category Category { get; set; } - } -} \ No newline at end of file diff --git a/src/ZendeskApi_v2/Models/Forums/Forum.cs b/src/ZendeskApi_v2/Models/Forums/Forum.cs deleted file mode 100644 index dc9684b0..00000000 --- a/src/ZendeskApi_v2/Models/Forums/Forum.cs +++ /dev/null @@ -1,54 +0,0 @@ -// JSON C# Class Generator -// http://at-my-window.blogspot.com/?page=json-class-generator - -using System; -using System.Collections.Generic; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; - -namespace ZendeskApi_v2.Models.Forums -{ - - public class Forum - { - - [JsonProperty("id")] - public long? Id { get; set; } - - [JsonProperty("name")] - public string Name { get; set; } - - [JsonProperty("description:")] - public string Description { get; set; } - - [JsonProperty("category_id")] - public long? CategoryId { get; set; } - - [JsonProperty("organization_id")] - public long? OrganizationId { get; set; } - - [JsonProperty("locale_id")] - public long? LocaleId { get; set; } - - [JsonProperty("locked")] - public bool Locked { get; set; } - - [JsonProperty("position")] - public long Position { get; set; } - - [JsonProperty("forum_type")] - public string ForumType { get; set; } - - [JsonProperty("access")] - public string Access { get; set; } - - [JsonProperty("created_at")] - [JsonConverter(typeof(IsoDateTimeConverter))] - public DateTimeOffset? CreatedAt { get; set; } - - [JsonProperty("updated_at")] - [JsonConverter(typeof(IsoDateTimeConverter))] - public DateTimeOffset? UpdatedAt { get; set; } - } -} diff --git a/src/ZendeskApi_v2/Models/Forums/ForumSubscription.cs b/src/ZendeskApi_v2/Models/Forums/ForumSubscription.cs deleted file mode 100644 index c44a9ff9..00000000 --- a/src/ZendeskApi_v2/Models/Forums/ForumSubscription.cs +++ /dev/null @@ -1,29 +0,0 @@ -// JSON C# Class Generator -// http://at-my-window.blogspot.com/?page=json-class-generator - -using System; -using System.Collections.Generic; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; - -namespace ZendeskApi_v2.Models.Forums -{ - - public class ForumSubscription - { - - [JsonProperty("id")] - public long? Id { get; set; } - - [JsonProperty("forum_id")] - public long? ForumId { get; set; } - - [JsonProperty("user_id")] - public long? UserId { get; set; } - - [JsonProperty("created_at")] - [JsonConverter(typeof(IsoDateTimeConverter))] - public DateTimeOffset? CreatedAt { get; set; } - } -} diff --git a/src/ZendeskApi_v2/Models/Forums/GroupForumResponse.cs b/src/ZendeskApi_v2/Models/Forums/GroupForumResponse.cs deleted file mode 100644 index 6e5ccfb1..00000000 --- a/src/ZendeskApi_v2/Models/Forums/GroupForumResponse.cs +++ /dev/null @@ -1,17 +0,0 @@ -// JSON C# Class Generator -// http://at-my-window.blogspot.com/?page=json-class-generator - -using System; -using System.Collections.Generic; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace ZendeskApi_v2.Models.Forums -{ - - public class GroupForumResponse : GroupResponseBase - { - [JsonProperty("forums")] - public IList Forums { get; set; } - } -} diff --git a/src/ZendeskApi_v2/Models/Forums/GroupForumSubcriptionResponse.cs b/src/ZendeskApi_v2/Models/Forums/GroupForumSubcriptionResponse.cs deleted file mode 100644 index 9128a2d2..00000000 --- a/src/ZendeskApi_v2/Models/Forums/GroupForumSubcriptionResponse.cs +++ /dev/null @@ -1,18 +0,0 @@ -// JSON C# Class Generator -// http://at-my-window.blogspot.com/?page=json-class-generator - -using System; -using System.Collections.Generic; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace ZendeskApi_v2.Models.Forums -{ - - public class GroupForumSubcriptionResponse : GroupResponseBase - { - - [JsonProperty("forum_subscriptions")] - public IList ForumSubscriptions { get; set; } - } -} diff --git a/src/ZendeskApi_v2/Models/Forums/IndividualForumResponse.cs b/src/ZendeskApi_v2/Models/Forums/IndividualForumResponse.cs deleted file mode 100644 index 81c08374..00000000 --- a/src/ZendeskApi_v2/Models/Forums/IndividualForumResponse.cs +++ /dev/null @@ -1,10 +0,0 @@ -using Newtonsoft.Json; - -namespace ZendeskApi_v2.Models.Forums -{ - public class IndividualForumResponse - { - [JsonProperty("forum")] - public Forum Forum { get; set; } - } -} \ No newline at end of file diff --git a/src/ZendeskApi_v2/Models/Forums/IndividualForumSubcriptionResponse.cs b/src/ZendeskApi_v2/Models/Forums/IndividualForumSubcriptionResponse.cs deleted file mode 100644 index f6f6add2..00000000 --- a/src/ZendeskApi_v2/Models/Forums/IndividualForumSubcriptionResponse.cs +++ /dev/null @@ -1,10 +0,0 @@ -using Newtonsoft.Json; - -namespace ZendeskApi_v2.Models.Forums -{ - public class IndividualForumSubcriptionResponse - { - [JsonProperty("forum_subscription")] - public ForumSubscription ForumSubscription { get; set; } - } -} \ No newline at end of file diff --git a/src/ZendeskApi_v2/Models/Sections/IndividualSectionResponse.cs b/src/ZendeskApi_v2/Models/Sections/IndividualSectionResponse.cs index b68d47aa..1998ea5a 100644 --- a/src/ZendeskApi_v2/Models/Sections/IndividualSectionResponse.cs +++ b/src/ZendeskApi_v2/Models/Sections/IndividualSectionResponse.cs @@ -1,12 +1,10 @@ using Newtonsoft.Json; -using ZendeskApi_v2.Models.Categories; namespace ZendeskApi_v2.Models.Sections { public class IndividualSectionResponse { - [JsonProperty("section")] public Section Section { get; set; } } -} \ No newline at end of file +} diff --git a/src/ZendeskApi_v2/Models/Topics/GroupTopicCommentResponse.cs b/src/ZendeskApi_v2/Models/Topics/GroupTopicCommentResponse.cs deleted file mode 100644 index 6a8c5d99..00000000 --- a/src/ZendeskApi_v2/Models/Topics/GroupTopicCommentResponse.cs +++ /dev/null @@ -1,18 +0,0 @@ -// JSON C# Class Generator -// http://at-my-window.blogspot.com/?page=json-class-generator - -using System; -using System.Collections.Generic; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace ZendeskApi_v2.Models.Topics -{ - - public class GroupTopicCommentResponse : GroupResponseBase - { - - [JsonProperty("topic_comments")] - public IList TopicComments { get; set; } - } -} diff --git a/src/ZendeskApi_v2/Models/Topics/GroupTopicResponse.cs b/src/ZendeskApi_v2/Models/Topics/GroupTopicResponse.cs deleted file mode 100644 index e583cd42..00000000 --- a/src/ZendeskApi_v2/Models/Topics/GroupTopicResponse.cs +++ /dev/null @@ -1,18 +0,0 @@ -// JSON C# Class Generator -// http://at-my-window.blogspot.com/?page=json-class-generator - -using System; -using System.Collections.Generic; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace ZendeskApi_v2.Models.Topics -{ - - public class GroupTopicResponse : GroupResponseBase - { - - [JsonProperty("topics")] - public IList Topics { get; set; } - } -} diff --git a/src/ZendeskApi_v2/Models/Topics/GroupTopicSubscriptionResponse.cs b/src/ZendeskApi_v2/Models/Topics/GroupTopicSubscriptionResponse.cs deleted file mode 100644 index 22de5a2b..00000000 --- a/src/ZendeskApi_v2/Models/Topics/GroupTopicSubscriptionResponse.cs +++ /dev/null @@ -1,17 +0,0 @@ -// JSON C# Class Generator -// http://at-my-window.blogspot.com/?page=json-class-generator - -using System; -using System.Collections.Generic; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace ZendeskApi_v2.Models.Topics -{ - - public class GroupTopicSubscriptionResponse : GroupResponseBase - { - [JsonProperty("topic_subscriptions")] - public IList TopicSubscriptions { get; set; } - } -} diff --git a/src/ZendeskApi_v2/Models/Topics/GroupTopicVoteResponse.cs b/src/ZendeskApi_v2/Models/Topics/GroupTopicVoteResponse.cs deleted file mode 100644 index 365adac7..00000000 --- a/src/ZendeskApi_v2/Models/Topics/GroupTopicVoteResponse.cs +++ /dev/null @@ -1,18 +0,0 @@ -// JSON C# Class Generator -// http://at-my-window.blogspot.com/?page=json-class-generator - -using System; -using System.Collections.Generic; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace ZendeskApi_v2.Models.Topics -{ - - public class GroupTopicVoteResponse : GroupResponseBase - { - - [JsonProperty("topic_votes")] - public IList TopicVotes { get; set; } - } -} diff --git a/src/ZendeskApi_v2/Models/Topics/IndividualTopicCommentResponse.cs b/src/ZendeskApi_v2/Models/Topics/IndividualTopicCommentResponse.cs deleted file mode 100644 index 06d3dee3..00000000 --- a/src/ZendeskApi_v2/Models/Topics/IndividualTopicCommentResponse.cs +++ /dev/null @@ -1,10 +0,0 @@ -using Newtonsoft.Json; - -namespace ZendeskApi_v2.Models.Topics -{ - public class IndividualTopicCommentResponse - { - [JsonProperty("topic_comment")] - public TopicComment TopicComment { get; set; } - } -} \ No newline at end of file diff --git a/src/ZendeskApi_v2/Models/Topics/IndividualTopicResponse.cs b/src/ZendeskApi_v2/Models/Topics/IndividualTopicResponse.cs deleted file mode 100644 index 68295279..00000000 --- a/src/ZendeskApi_v2/Models/Topics/IndividualTopicResponse.cs +++ /dev/null @@ -1,10 +0,0 @@ -using Newtonsoft.Json; - -namespace ZendeskApi_v2.Models.Topics -{ - public class IndividualTopicResponse - { - [JsonProperty("topic")] - public Topic Topic { get; set; } - } -} \ No newline at end of file diff --git a/src/ZendeskApi_v2/Models/Topics/IndividualTopicSubscriptionResponse.cs b/src/ZendeskApi_v2/Models/Topics/IndividualTopicSubscriptionResponse.cs deleted file mode 100644 index e8a369c3..00000000 --- a/src/ZendeskApi_v2/Models/Topics/IndividualTopicSubscriptionResponse.cs +++ /dev/null @@ -1,10 +0,0 @@ -using Newtonsoft.Json; - -namespace ZendeskApi_v2.Models.Topics -{ - public class IndividualTopicSubscriptionResponse - { - [JsonProperty("topic_subscription")] - public TopicSubscription TopicSubscription { get; set; } - } -} \ No newline at end of file diff --git a/src/ZendeskApi_v2/Models/Topics/IndividualTopicVoteResponse.cs b/src/ZendeskApi_v2/Models/Topics/IndividualTopicVoteResponse.cs deleted file mode 100644 index 9dc3b684..00000000 --- a/src/ZendeskApi_v2/Models/Topics/IndividualTopicVoteResponse.cs +++ /dev/null @@ -1,10 +0,0 @@ -using Newtonsoft.Json; - -namespace ZendeskApi_v2.Models.Topics -{ - public class IndividualTopicVoteResponse - { - [JsonProperty("topic_vote")] - public TopicVote TopicVote { get; set; } - } -} \ No newline at end of file diff --git a/src/ZendeskApi_v2/Models/Topics/Topic.cs b/src/ZendeskApi_v2/Models/Topics/Topic.cs deleted file mode 100644 index 22331313..00000000 --- a/src/ZendeskApi_v2/Models/Topics/Topic.cs +++ /dev/null @@ -1,80 +0,0 @@ -// JSON C# Class Generator -// http://at-my-window.blogspot.com/?page=json-class-generator - -using System; -using System.Collections.Generic; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using ZendeskApi_v2.Models.Shared; - - -namespace ZendeskApi_v2.Models.Topics -{ - - public class Topic - { - - [JsonProperty("url")] - public string Url { get; set; } - - [JsonProperty("id")] - public long? Id { get; set; } - - [JsonProperty("title")] - public string Title { get; set; } - - [JsonProperty("body")] - public string Body { get; set; } - - [JsonProperty("topic_type")] - public string TopicType { get; set; } - - [JsonProperty("submitter_id")] - public long? SubmitterId { get; set; } - - [JsonProperty("updater_id")] - public long? UpdaterId { get; set; } - - [JsonProperty("forum_id")] - public long? ForumId { get; set; } - - [JsonProperty("locked")] - public bool Locked { get; set; } - - [JsonProperty("pinned")] - public bool Pinned { get; set; } - - [JsonProperty("highlighted")] - public bool Highlighted { get; set; } - - [JsonProperty("position")] - public long? Position { get; set; } - - [JsonProperty("tags")] - public IList Tags { get; set; } - - [JsonProperty("attachments")] - public IList Attachments { get; set; } - - [JsonProperty("comments_count")] - public long CommentsCount { get; set; } - - [JsonProperty("created_at")] - [JsonConverter(typeof(IsoDateTimeConverter))] - public DateTimeOffset? CreatedAt { get; set; } - - [JsonProperty("updated_at")] - [JsonConverter(typeof(IsoDateTimeConverter))] - public DateTimeOffset? UpdatedAt { get; set; } - - /// - /// Used for uploading Topics only - /// When creating and updating Topics you may attach files by passing in an array of the tokens received from uploading the files. - /// Use Attachments.UploadAttachment to get the token first. - /// - [JsonProperty("uploads")] - public IList Uploads { get; set; } - - } -} diff --git a/src/ZendeskApi_v2/Models/Topics/TopicComment.cs b/src/ZendeskApi_v2/Models/Topics/TopicComment.cs deleted file mode 100644 index d035a9a4..00000000 --- a/src/ZendeskApi_v2/Models/Topics/TopicComment.cs +++ /dev/null @@ -1,52 +0,0 @@ -// JSON C# Class Generator -// http://at-my-window.blogspot.com/?page=json-class-generator - -using System; -using System.Collections.Generic; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using ZendeskApi_v2.Models.Shared; - -namespace ZendeskApi_v2.Models.Topics -{ - - public class TopicComment - { - - [JsonProperty("id")] - public long? Id { get; set; } - - [JsonProperty("topic_id")] - public long? TopicId { get; set; } - - [JsonProperty("user_id")] - public long? UserId { get; set; } - - [JsonProperty("body")] - public string Body { get; set; } - - [JsonProperty("informative")] - public bool Informative { get; set; } - - [JsonProperty("attachments")] - public IList Attachments { get; set; } - - [JsonProperty("created_at")] - [JsonConverter(typeof(IsoDateTimeConverter))] - public DateTimeOffset? CreatedAt { get; set; } - - [JsonProperty("updated_at")] - [JsonConverter(typeof(IsoDateTimeConverter))] - public DateTimeOffset? UpdatedAt { get; set; } - - /// - /// Used for uploading attachments only - /// When creating and updating comments you may attach files by passing in an array of the tokens received from uploading the files. - /// Use Attachments.UploadAttachment to get the token first. - /// - [JsonProperty("uploads")] - public IList Uploads { get; set; } - - } -} diff --git a/src/ZendeskApi_v2/Models/Topics/TopicSubscription.cs b/src/ZendeskApi_v2/Models/Topics/TopicSubscription.cs deleted file mode 100644 index a85e59b7..00000000 --- a/src/ZendeskApi_v2/Models/Topics/TopicSubscription.cs +++ /dev/null @@ -1,28 +0,0 @@ -// JSON C# Class Generator -// http://at-my-window.blogspot.com/?page=json-class-generator - -using System; -using System.Collections.Generic; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; - -namespace ZendeskApi_v2.Models.Topics -{ - - public class TopicSubscription - { - [JsonProperty("id")] - public long? Id { get; set; } - - [JsonProperty("topic_id")] - public long TopicId { get; set; } - - [JsonProperty("user_id")] - public long UserId { get; set; } - - [JsonProperty("created_at")] - [JsonConverter(typeof(IsoDateTimeConverter))] - public DateTimeOffset? CreatedAt { get; set; } - } -} diff --git a/src/ZendeskApi_v2/Models/Topics/TopicVote.cs b/src/ZendeskApi_v2/Models/Topics/TopicVote.cs deleted file mode 100644 index 6558c984..00000000 --- a/src/ZendeskApi_v2/Models/Topics/TopicVote.cs +++ /dev/null @@ -1,28 +0,0 @@ -// JSON C# Class Generator -// http://at-my-window.blogspot.com/?page=json-class-generator - -using System; -using System.Collections.Generic; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; - -namespace ZendeskApi_v2.Models.Topics -{ - - public class TopicVote - { - [JsonProperty("id")] - public long? Id { get; set; } - - [JsonProperty("user_id")] - public long UserId { get; set; } - - [JsonProperty("topic_id")] - public long TopicId { get; set; } - - [JsonProperty("created_at")] - [JsonConverter(typeof(IsoDateTimeConverter))] - public DateTimeOffset? CreatedAt { get; set; } - } -} diff --git a/src/ZendeskApi_v2/Requests/Categories.cs b/src/ZendeskApi_v2/Requests/Categories.cs deleted file mode 100644 index 11225943..00000000 --- a/src/ZendeskApi_v2/Requests/Categories.cs +++ /dev/null @@ -1,93 +0,0 @@ -using ZendeskApi_v2.Models.Categories; -#if ASYNC -using System.Threading.Tasks; -#endif -using ZendeskApi_v2.Models.Groups; - -namespace ZendeskApi_v2.Requests -{ - public interface ICategories : ICore - { -#if SYNC - GroupCategoryResponse GetCategories(); - IndividualCategoryResponse GetCategoryById(long id); - IndividualCategoryResponse CreateCategory(Category category); - IndividualCategoryResponse UpdateCategory(Category category); - bool DeleteCategory(long id); -#endif - -#if ASYNC - Task GetCategoriesAsync(); - Task GetCategoryByIdAsync(long id); - Task CreateCategoryAsync(Category category); - Task UpdateCategoryAsync(Category category); - Task DeleteCategoryAsync(long id); -#endif - } - - public class Categories : Core, ICategories - { - public Categories(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken) - : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken) - { - } - -#if SYNC - public GroupCategoryResponse GetCategories() - { - return GenericGet("categories.json"); - } - - public IndividualCategoryResponse GetCategoryById(long id) - { - return GenericGet($"categories/{id}.json"); - } - - public IndividualCategoryResponse CreateCategory(Category category) - { - var body = new {category}; - return GenericPost(string.Format("categories.json"), body); - } - - public IndividualCategoryResponse UpdateCategory(Category category) - { - var body = new { category }; - return GenericPut($"categories/{category.Id}.json", body); - } - - public bool DeleteCategory(long id) - { - return GenericDelete($"categories/{id}.json"); - } -#endif - -#if ASYNC - public async Task GetCategoriesAsync() - { - return await GenericGetAsync("categories.json"); - } - - public async Task GetCategoryByIdAsync(long id) - { - return await GenericGetAsync($"categories/{id}.json"); - } - - public async Task CreateCategoryAsync(Category category) - { - var body = new { category }; - return await GenericPostAsync(string.Format("categories.json"), body); - } - - public async Task UpdateCategoryAsync(Category category) - { - var body = new { category }; - return await GenericPutAsync($"categories/{category.Id}.json", body); - } - - public async Task DeleteCategoryAsync(long id) - { - return await GenericDeleteAsync($"categories/{id}.json"); - } -#endif - } -} \ No newline at end of file diff --git a/src/ZendeskApi_v2/Requests/Forums.cs b/src/ZendeskApi_v2/Requests/Forums.cs deleted file mode 100644 index 34537ccf..00000000 --- a/src/ZendeskApi_v2/Requests/Forums.cs +++ /dev/null @@ -1,164 +0,0 @@ -#if ASYNC -using System.Threading.Tasks; -#endif -using ZendeskApi_v2.Models.Forums; -using ZendeskApi_v2.Models.Tags; - -namespace ZendeskApi_v2.Requests -{ - public interface IForums : ICore - { -#if SYNC - GroupForumResponse GetForums(); - IndividualForumResponse GetForumById(long forumId); - GroupForumResponse GetForumsByCategory(long categoryId); - IndividualForumResponse CreateForum(Forum forum); - IndividualForumResponse UpdateForum(Forum forum); - bool DeleteForum(long id); - GroupForumSubcriptionResponse GetForumSubscriptions(); - GroupForumSubcriptionResponse GetForumSubscriptionsByForumId(long forumId); - IndividualForumSubcriptionResponse GetForumSubscriptionsById(long subscriptionId); - IndividualForumSubcriptionResponse CreateForumSubscription(ForumSubscription forumSubscription); - bool DeleteForumSubscription(long subscriptionId); -#endif - -#if ASYNC - Task GetForumsAsync(); - Task GetForumByIdAsync(long forumId); - Task GetForumsByCategoryAsync(long categoryId); - Task CreateForumAsync(Forum forum); - Task UpdateForumAsync(Forum forum); - Task DeleteForumAsync(long id); - Task GetForumSubscriptionsAsync(); - Task GetForumSubscriptionsByForumIdAsync(long forumId); - Task GetForumSubscriptionsByIdAsync(long subscriptionId); - Task CreateForumSubscriptionAsync(ForumSubscription forumSubscription); - Task DeleteForumSubscriptionAsync(long subscriptionId); -#endif - } - - public class Forums : Core, IForums - { - public Forums(string yourZendeskUrl, string user, string password, string apiToken, string p_OAuthToken) - : base(yourZendeskUrl, user, password, apiToken, p_OAuthToken) - { - } -#if SYNC - public GroupForumResponse GetForums() - { - return GenericGet("forums.json"); - } - - public IndividualForumResponse GetForumById(long forumId) - { - return GenericGet($"forums/{forumId}.json"); - } - - public GroupForumResponse GetForumsByCategory(long categoryId) - { - return GenericGet($"categories/{categoryId}/forums.json"); - } - - public IndividualForumResponse CreateForum(Forum forum) - { - var body = new { forum }; - return GenericPost("forums.json", body); - } - - public IndividualForumResponse UpdateForum(Forum forum) - { - var body = new { forum }; - return GenericPut($"forums/{forum.Id}.json", body); - } - - public bool DeleteForum(long id) - { - return GenericDelete($"forums/{id}.json"); - } - - public GroupForumSubcriptionResponse GetForumSubscriptions() - { - return GenericGet("forum_subscriptions.json"); - } - - public GroupForumSubcriptionResponse GetForumSubscriptionsByForumId(long forumId) - { - return GenericGet($"forums/{forumId}/subscriptions.json"); - } - - public IndividualForumSubcriptionResponse GetForumSubscriptionsById(long subscriptionId) - { - return GenericGet($"forum_subscriptions/{subscriptionId}.json"); - } - - public IndividualForumSubcriptionResponse CreateForumSubscription(ForumSubscription forumSubscription) - { - return GenericPost(string.Format("forum_subscriptions.json"), forumSubscription); - } - - public bool DeleteForumSubscription(long subscriptionId) - { - return GenericDelete($"forum_subscriptions/{subscriptionId}.json"); - } - -#endif -#if ASYNC - public async Task GetForumsAsync() - { - return await GenericGetAsync("forums.json"); - } - - public async Task GetForumByIdAsync(long forumId) - { - return await GenericGetAsync($"forums/{forumId}.json"); - } - - public async Task GetForumsByCategoryAsync(long categoryId) - { - return await GenericGetAsync($"categories/{categoryId}/forums.json"); - } - - public async Task CreateForumAsync(Forum forum) - { - var body = new { forum }; - return await GenericPostAsync("forums.json", body); - } - - public async Task UpdateForumAsync(Forum forum) - { - var body = new { forum }; - return await GenericPutAsync($"forums/{forum.Id}.json", body); - } - - public async Task DeleteForumAsync(long id) - { - return await GenericDeleteAsync($"forums/{id}.json"); - } - - public async Task GetForumSubscriptionsAsync() - { - return await GenericGetAsync("forum_subscriptions.json"); - } - - public async Task GetForumSubscriptionsByForumIdAsync(long forumId) - { - return await GenericGetAsync($"forums/{forumId}/subscriptions.json"); - } - - public async Task GetForumSubscriptionsByIdAsync(long subscriptionId) - { - return await GenericGetAsync($"forum_subscriptions/{subscriptionId}.json"); - } - - public async Task CreateForumSubscriptionAsync(ForumSubscription forumSubscription) - { - return await GenericPostAsync(string.Format("forum_subscriptions.json"), forumSubscription); - } - - public async Task DeleteForumSubscriptionAsync(long subscriptionId) - { - return await GenericDeleteAsync($"forum_subscriptions/{subscriptionId}.json"); - } -#endif - } -} \ No newline at end of file diff --git a/src/ZendeskApi_v2/Requests/Topics.cs b/src/ZendeskApi_v2/Requests/Topics.cs deleted file mode 100644 index 931f9bd1..00000000 --- a/src/ZendeskApi_v2/Requests/Topics.cs +++ /dev/null @@ -1,364 +0,0 @@ -using System.Collections.Generic; -#if ASYNC -using System.Threading.Tasks; -#endif -using ZendeskApi_v2.Extensions; -using ZendeskApi_v2.Models.Topics; - -namespace ZendeskApi_v2.Requests -{ - public interface ITopics : ICore - { -#if SYNC - GroupTopicResponse GetTopics(); - IndividualTopicResponse GetTopicById(long topicId); - GroupTopicResponse GetMultipleTopicsById(IEnumerable topicIds); - GroupTopicResponse GetTopicsByForum(long forumId); - GroupTopicResponse GetTopicsByUser(long userId); - IndividualTopicResponse CreateTopic(Topic topic); - IndividualTopicResponse UpdateTopic(Topic topic); - bool DeleteTopic(long topicId); - GroupTopicCommentResponse GetTopicCommentsByTopicId(long topicId); - GroupTopicCommentResponse GetTopicCommentsByUserId(long userId); - IndividualTopicCommentResponse GetSpecificTopicCommentByTopic(long topicId, long commentId); - IndividualTopicCommentResponse GetSpecificTopicCommentByUser(long userId, long commentId); - IndividualTopicCommentResponse CreateTopicComment(long topicId, TopicComment topicComment); - IndividualTopicCommentResponse UpdateTopicComment(TopicComment topicComment); - bool DeleteTopicComment(long topicId, long commentId); - GroupTopicSubscriptionResponse GetTopicSubscriptionsByTopic(long topicId); - GroupTopicSubscriptionResponse GetAllTopicSubscriptions(); - IndividualTopicSubscriptionResponse GetTopicSubscriptionById(long topicSubscriptionId); - IndividualTopicSubscriptionResponse CreateTopicSubscription(long userId, long topicId); - bool DeleteTopicSubscription(long topicSubscriptionId); - GroupTopicVoteResponse GetTopicVotes(long topicId); - GroupTopicVoteResponse GetTopicVotesByUser(long userId); - - /// - /// Checks to see if the current user has cast a vote in this topic. Returns null if not - /// - /// - /// - IndividualTopicVoteResponse CheckForVote(long topicId); - - IndividualTopicVoteResponse CreateVote(long topicId); - bool DeleteVote(long topicId); -#endif - -#if ASYNC - Task GetTopicsAsync(); - Task GetTopicByIdAsync(long topicId); - Task GetMultipleTopicsByIdAsync(IEnumerable topicIds); - Task GetTopicsByForumAsync(long forumId); - Task GetTopicsByUserAsync(long userId); - Task CreateTopicAsync(Topic topic); - Task UpdateTopicAsync(Topic topic); - Task DeleteTopicAsync(long topicId); - Task GetTopicCommentsByTopicIdAsync(long topicId); - Task GetTopicCommentsByUserIdAsync(long userId); - Task GetSpecificTopicCommentByTopicAsync(long topicId, long commentId); - Task GetSpecificTopicCommentByUserAsync(long userId, long commentId); - Task CreateTopicCommentAsync(long topicId, TopicComment topicComment); - Task UpdateTopicCommentAsync(TopicComment topicComment); - Task DeleteTopicCommentAsync(long topicId, long commentId); - Task GetTopicSubscriptionsByTopicAsync(long topicId); - Task GetAllTopicSubscriptionsAsync(); - Task GetTopicSubscriptionByIdAsync(long topicSubscriptionId); - Task CreateTopicSubscriptionAsync(long userId, long topicId); - Task DeleteTopicSubscriptionAsync(long topicSubscriptionId); - Task GetTopicVotesAsync(long topicId); - Task GetTopicVotesByUserAsync(long userId); - - /// - /// Checks to see if the current user has cast a vote in this topic. Returns null if not - /// - /// - /// - Task CheckForVoteAsync(long topicId); - - Task CreateVoteAsync(long topicId); - Task DeleteVoteAsync(long topicId); -#endif - } - - 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) - { - } - -#if SYNC - public GroupTopicResponse GetTopics() - { - return GenericGet("topics.json"); - } - - public IndividualTopicResponse GetTopicById(long topicId) - { - return GenericGet($"topics/{topicId}.json"); - } - - public GroupTopicResponse GetMultipleTopicsById(IEnumerable topicIds) - { - return GenericPost($"topics/show_many?ids={topicIds.ToCsv()}.json"); - } - - public GroupTopicResponse GetTopicsByForum(long forumId) - { - return GenericGet($"forums/{forumId}/topics.json"); - } - - public GroupTopicResponse GetTopicsByUser(long userId) - { - return GenericGet($"users/{userId}/topics.json"); - } - - public IndividualTopicResponse CreateTopic(Topic topic) - { - var body = new {topic}; - return GenericPost(string.Format("topics.json"), body); - } - - public IndividualTopicResponse UpdateTopic(Topic topic) - { - var body = new { topic }; - return GenericPut($"topics/{topic.Id}.json", body); - } - - public bool DeleteTopic(long topicId) - { - return GenericDelete($"topics/{topicId}.json"); - } - - public GroupTopicCommentResponse GetTopicCommentsByTopicId(long topicId) - { - return GenericGet($"topics/{topicId}/comments.json"); - } - - public GroupTopicCommentResponse GetTopicCommentsByUserId(long userId) - { - return GenericGet($"users/{userId}/topic_comments.json"); - } - - public IndividualTopicCommentResponse GetSpecificTopicCommentByTopic(long topicId, long commentId) - { - return GenericGet($"topics/{topicId}/comments/{commentId}.json"); - } - - public IndividualTopicCommentResponse GetSpecificTopicCommentByUser(long userId, long commentId) - { - return GenericGet($"users/{userId}/topic_comments/{commentId}.json"); - } - - public IndividualTopicCommentResponse CreateTopicComment(long topicId, TopicComment topicComment) - { - var body = new { topic_comment = topicComment }; - return GenericPost($"topics/{topicId}/comments.json", body); - } - - public IndividualTopicCommentResponse UpdateTopicComment(TopicComment topicComment) - { - var body = new { topic_comment = topicComment}; - return GenericPut($"topics/{topicComment.TopicId}/comments/{topicComment.Id}.json", body); - } - - public bool DeleteTopicComment(long topicId, long commentId) - { - return GenericDelete($"topics/{topicId}/comments/{commentId}.json"); - } - - public GroupTopicSubscriptionResponse GetTopicSubscriptionsByTopic(long topicId) - { - return GenericGet($"topics/{topicId}/subscriptions.json"); - } - - public GroupTopicSubscriptionResponse GetAllTopicSubscriptions() - { - return GenericGet(string.Format("topic_subscriptions.json")); - } - - public IndividualTopicSubscriptionResponse GetTopicSubscriptionById(long topicSubscriptionId) - { - return GenericGet($"topic_subscriptions/{topicSubscriptionId}.json"); - } - - public IndividualTopicSubscriptionResponse CreateTopicSubscription(long userId, long topicId) - { - var body = new { user_id = userId, topic_id = topicId }; - return GenericPost(string.Format("topic_subscriptions.json"), body); - } - - public bool DeleteTopicSubscription(long topicSubscriptionId) - { - return GenericDelete($"topic_subscriptions/{topicSubscriptionId}.json"); - } - - public GroupTopicVoteResponse GetTopicVotes(long topicId) - { - return GenericGet($"topics/{topicId}/votes.json"); - } - - public GroupTopicVoteResponse GetTopicVotesByUser(long userId) - { - return GenericGet($"users/{userId}/topic_votes.json"); - } - - /// - /// Checks to see if the current user has cast a vote in this topic. Returns null if not - /// - /// - /// - public IndividualTopicVoteResponse CheckForVote(long topicId) - { - return GenericGet($"topics/{topicId}/vote.json"); - } - - public IndividualTopicVoteResponse CreateVote(long topicId) - { - return GenericPost($"topics/{topicId}/vote.json"); - } - - public bool DeleteVote(long topicId) - { - return GenericDelete($"topics/{topicId}/vote.json"); - } -#endif - -#if ASYNC - public async Task GetTopicsAsync() - { - return await GenericGetAsync("topics.json"); - } - - public async Task GetTopicByIdAsync(long topicId) - { - return await GenericGetAsync($"topics/{topicId}.json"); - } - - public async Task GetMultipleTopicsByIdAsync(IEnumerable topicIds) - { - return await GenericPostAsync($"topics/show_many?ids={topicIds.ToCsv()}.json"); - } - - public async Task GetTopicsByForumAsync(long forumId) - { - return await GenericGetAsync($"forums/{forumId}/topics.json"); - } - - public async Task GetTopicsByUserAsync(long userId) - { - return await GenericGetAsync($"users/{userId}/topics.json"); - } - - public async Task CreateTopicAsync(Topic topic) - { - var body = new {topic}; - return await GenericPostAsync(string.Format("topics.json"), body); - } - - public async Task UpdateTopicAsync(Topic topic) - { - var body = new { topic }; - return await GenericPutAsync($"topics/{topic.Id}.json", body); - } - - public async Task DeleteTopicAsync(long topicId) - { - return await GenericDeleteAsync($"topics/{topicId}.json"); - } - - public async Task GetTopicCommentsByTopicIdAsync(long topicId) - { - return await GenericGetAsync($"topics/{topicId}/comments.json"); - } - - public async Task GetTopicCommentsByUserIdAsync(long userId) - { - return await GenericGetAsync($"users/{userId}/topic_comments.json"); - } - - public async Task GetSpecificTopicCommentByTopicAsync(long topicId, long commentId) - { - return await GenericGetAsync($"topics/{topicId}/comments/{commentId}.json"); - } - - public async Task GetSpecificTopicCommentByUserAsync(long userId, long commentId) - { - return await GenericGetAsync($"users/{userId}/topic_comments/{commentId}.json"); - } - - public async Task CreateTopicCommentAsync(long topicId, TopicComment topicComment) - { - var body = new { topic_comment = topicComment }; - return await GenericPostAsync($"topics/{topicId}/comments.json", body); - } - - public async Task UpdateTopicCommentAsync(TopicComment topicComment) - { - var body = new { topic_comment = topicComment}; - return await GenericPutAsync($"topics/{topicComment.TopicId}/comments/{topicComment.Id}.json", body); - } - - public async Task DeleteTopicCommentAsync(long topicId, long commentId) - { - return await GenericDeleteAsync($"topics/{topicId}/comments/{commentId}.json"); - } - - public async Task GetTopicSubscriptionsByTopicAsync(long topicId) - { - return await GenericGetAsync($"topics/{topicId}/subscriptions.json"); - } - - public async Task GetAllTopicSubscriptionsAsync() - { - return await GenericGetAsync(string.Format("topic_subscriptions.json")); - } - - public async Task GetTopicSubscriptionByIdAsync(long topicSubscriptionId) - { - return await GenericGetAsync($"topic_subscriptions/{topicSubscriptionId}.json"); - } - - public async Task CreateTopicSubscriptionAsync(long userId, long topicId) - { - var body = new { user_id = userId, topic_id = topicId }; - return await GenericPostAsync(string.Format("topic_subscriptions.json"), body); - } - - public async Task DeleteTopicSubscriptionAsync(long topicSubscriptionId) - { - return await GenericDeleteAsync($"topic_subscriptions/{topicSubscriptionId}.json"); - } - - public async Task GetTopicVotesAsync(long topicId) - { - return await GenericGetAsync($"topics/{topicId}/votes.json"); - } - - public async Task GetTopicVotesByUserAsync(long userId) - { - return await GenericGetAsync($"users/{userId}/topic_votes.json"); - } - - /// - /// Checks to see if the current user has cast a vote in this topic. Returns null if not - /// - /// - /// - public async Task CheckForVoteAsync(long topicId) - { - return await GenericGetAsync($"topics/{topicId}/vote.json"); - } - - public async Task CreateVoteAsync(long topicId) - { - return await GenericPostAsync($"topics/{topicId}/vote.json"); - } - - public async Task DeleteVoteAsync(long topicId) - { - return await GenericDeleteAsync($"topics/{topicId}/vote.json"); - } -#endif - } -} \ No newline at end of file diff --git a/src/ZendeskApi_v2/ZendeskApi.cs b/src/ZendeskApi_v2/ZendeskApi.cs index d660f1bf..cd0be261 100644 --- a/src/ZendeskApi_v2/ZendeskApi.cs +++ b/src/ZendeskApi_v2/ZendeskApi.cs @@ -3,7 +3,7 @@ using System.Net; using ZendeskApi_v2.HelpCenter; -#if Net35 +#if Net35 using System.Web; using System.Security.Cryptography; #endif @@ -23,9 +23,6 @@ public interface IZendeskApi IOrganizations Organizations { get; } ISearch Search { get; } ITags Tags { get; } - IForums Forums { get; } - ICategories Categories { get; } - ITopics Topics { get; } IAccountsAndActivity AccountsAndActivity { get; } IJobStatuses JobStatuses { get; } ILocales Locales { get; } @@ -54,9 +51,6 @@ public class ZendeskApi : IZendeskApi public IOrganizations Organizations { get; set; } public ISearch Search { get; set; } public ITags Tags { get; set; } - public IForums Forums { get; set; } - public ICategories Categories { get; set; } - public ITopics Topics { get; set; } public IAccountsAndActivity AccountsAndActivity { get; set; } public IJobStatuses JobStatuses { get; set; } public ILocales Locales { get; set; } @@ -71,7 +65,6 @@ public class ZendeskApi : IZendeskApi public string ZendeskUrl { get; set; } - /// /// Constructor that takes 2 params. /// @@ -94,7 +87,6 @@ public ZendeskApi(string yourZendeskUrl, { } - /// /// Constructor that takes 4 params. /// @@ -111,8 +103,6 @@ public ZendeskApi(string yourZendeskUrl, { } - - /// /// Constructor that takes 6 params. /// @@ -141,9 +131,6 @@ public ZendeskApi(string yourZendeskUrl, 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); - Forums = new Forums(formattedUrl, user, password, apiToken, p_OAuthToken); - Categories = new Categories(formattedUrl, user, password, apiToken, p_OAuthToken); - Topics = new Topics(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); @@ -160,6 +147,7 @@ public ZendeskApi(string yourZendeskUrl, } #if SYNC + /// /// Constructor that takes 3 params. /// @@ -170,7 +158,7 @@ public ZendeskApi(string yourZendeskUrl, public ZendeskApi(IWebProxy proxy, string yourZendeskUrl, string user, string password) : this(yourZendeskUrl, user, password, null, "en-us", null) { - if (proxy == null) return; + if (proxy == null) { return; } ((Tickets)Tickets).Proxy = proxy; ((Attachments)Attachments).Proxy = proxy; @@ -183,9 +171,6 @@ public ZendeskApi(IWebProxy proxy, string yourZendeskUrl, string user, string pa ((Organizations)Organizations).Proxy = proxy; ((Search)Search).Proxy = proxy; ((Tags)Tags).Proxy = proxy; - ((Forums)Forums).Proxy = proxy; - ((ZendeskApi_v2.Requests.Categories)Categories).Proxy = proxy; - ((Topics)Topics).Proxy = proxy; ((AccountsAndActivity)AccountsAndActivity).Proxy = proxy; ((JobStatuses)JobStatuses).Proxy = proxy; ((Locales)Locales).Proxy = proxy; @@ -199,16 +184,21 @@ public ZendeskApi(IWebProxy proxy, string yourZendeskUrl, string user, string pa } #endif - Uri GetFormattedZendeskUrl(string yourZendeskUrl) + + private Uri GetFormattedZendeskUrl(string yourZendeskUrl) { yourZendeskUrl = yourZendeskUrl.ToLower(); //Make sure the Authority is https:// if (yourZendeskUrl.StartsWith("http://")) + { yourZendeskUrl = yourZendeskUrl.Replace("http://", "https://"); + } if (!yourZendeskUrl.StartsWith("https://")) + { yourZendeskUrl = "https://" + yourZendeskUrl; + } if (!yourZendeskUrl.EndsWith("/api/v2")) { @@ -216,20 +206,20 @@ Uri GetFormattedZendeskUrl(string yourZendeskUrl) yourZendeskUrl = yourZendeskUrl.Split(new[] { ".zendesk.com" }, StringSplitOptions.RemoveEmptyEntries)[0] + ".zendesk.com/api/v2"; } - if (!yourZendeskUrl.EndsWith("/", StringComparison.CurrentCultureIgnoreCase)) + { yourZendeskUrl += "/"; + } return new Uri(yourZendeskUrl); } -#if Net35 +#if Net35 public string GetLoginUrl(string name, string email, string authenticationToken, string returnToUrl = "") { string url = string.Format("{0}/access/remoteauth/", ZendeskUrl); string timestamp = GetUnixEpoch(DateTime.Now).ToString(); - string message = string.Format("{0}|{1}|||||{2}|{3}", name, email, authenticationToken, timestamp); //string message = name + email + token + timestamp; string hash = Md5(message); @@ -253,7 +243,6 @@ private double GetUnixEpoch(DateTime dateTime) return unixTime.TotalSeconds; } - public string Md5(string strChange) { //Change the syllable into UTF8 code @@ -282,6 +271,5 @@ public string ByteArrayToHexString(byte[] Bytes) return Result.ToString(); } #endif - } } diff --git a/test/ZendeskApi_v2.Test/CategoryTests.cs b/test/ZendeskApi_v2.Test/CategoryTests.cs deleted file mode 100644 index dd8431e6..00000000 --- a/test/ZendeskApi_v2.Test/CategoryTests.cs +++ /dev/null @@ -1,55 +0,0 @@ -using NUnit.Framework; -using ZendeskApi_v2; -using ZendeskApi_v2.Models.Categories; - -namespace Tests -{ - [TestFixture] - public class CategoryTests - { - private ZendeskApi api = new ZendeskApi(Settings.Site, Settings.AdminEmail, Settings.AdminPassword); - - [OneTimeSetUp] - public void Setup() - { - - var res = api.Categories.GetCategoriesAsync().Result; - foreach (var category in res.Categories) - { - if (category.Name == "My Test category two") - { - var test = api.Categories.DeleteCategoryAsync(category.Id.Value).Result; - } - } - } - - - - [Test] - public void CanGetCategories() - { - var res = api.Categories.GetCategories(); - Assert.Greater(res.Count, 0); - - var res1 = api.Categories.GetCategoryById(res.Categories[0].Id.Value); - Assert.AreEqual(res1.Category.Id, res.Categories[0].Id); - } - - [Test] - public void CanCreateUpdateAndDeleteCategories() - { - var res = api.Categories.CreateCategory(new Category() - { - Name = "My Test category two" - }); - Assert.Greater(res.Category.Id, 0); - - res.Category.Description = "updated description"; - var update = api.Categories.UpdateCategory(res.Category); - //update = api.Categories.GetCategoryById(res.Category.Id.Value); - Assert.AreEqual(update.Category.Description, res.Category.Description); - - Assert.True(api.Categories.DeleteCategory(res.Category.Id.Value)); - } - } -} \ No newline at end of file diff --git a/test/ZendeskApi_v2.Test/ForumTests.cs b/test/ZendeskApi_v2.Test/ForumTests.cs deleted file mode 100644 index e07c6860..00000000 --- a/test/ZendeskApi_v2.Test/ForumTests.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System.Linq; -using NUnit.Framework; -using ZendeskApi_v2; -using ZendeskApi_v2.Models.Constants; -using ZendeskApi_v2.Models.Forums; - -namespace Tests -{ - [TestFixture] - public class ForumTests - { - private ZendeskApi api = new ZendeskApi(Settings.Site, Settings.AdminEmail, Settings.AdminPassword); - - [Test] - public void CanGetForums() - { - var res = api.Forums.GetForums(); - Assert.Greater(res.Forums.Count, 0); - - var forum = api.Forums.GetForumById(res.Forums[0].Id.Value); - Assert.AreEqual(forum.Forum.Id, res.Forums[0].Id.Value); - } - - [Test] - public void CanCreateUpdateAndDeleteForums() - { - var res = api.Forums.CreateForum(new Forum() - { - Name = "test forum", - ForumType = ForumTypes.Articles, - Access = ForumAccessTypes.Everybody - }); - Assert.Greater(res.Forum.Id, 0); - - res.Forum.Name = "updated test forum"; - var update = api.Forums.UpdateForum(res.Forum); - Assert.AreEqual(update.Forum.Name, res.Forum.Name); - - Assert.True(api.Forums.DeleteForum(res.Forum.Id.Value)); - } - - [Test] - public void CanCreateGetAndDeleteForumSubscriptions() - { - var subs = api.Forums.GetForumSubscriptions().ForumSubscriptions; - foreach (var sub in subs) - { - api.Forums.DeleteForumSubscription(sub.Id.Value); - } - - - var forum = api.Forums.GetForums().Forums.First(); - - var res = api.Forums.CreateForumSubscription(new ForumSubscription() - { - ForumId = forum.Id, - UserId = Settings.EndUserId, - }); - Assert.Greater(res.ForumSubscription.Id, 0); - - var forumSubs = api.Forums.GetForumSubscriptions(); - Assert.Greater(forumSubs.Count, 0); - - var forumSubsById = api.Forums.GetForumSubscriptionsByForumId(forumSubs.ForumSubscriptions[0].ForumId.Value); - Assert.Greater(forumSubsById.Count, 0); - - var forumSubId = api.Forums.GetForumSubscriptionsById(forumSubs.ForumSubscriptions[0].Id.Value); - Assert.AreEqual(forumSubId.ForumSubscription.Id, forumSubs.ForumSubscriptions[0].Id); - - Assert.True(api.Forums.DeleteForumSubscription(res.ForumSubscription.Id.Value)); - - } - } -} \ No newline at end of file diff --git a/test/ZendeskApi_v2.Test/TopicTests.cs b/test/ZendeskApi_v2.Test/TopicTests.cs deleted file mode 100644 index 84421fec..00000000 --- a/test/ZendeskApi_v2.Test/TopicTests.cs +++ /dev/null @@ -1,145 +0,0 @@ -using System.Diagnostics; -using System.Linq; -using NUnit.Framework; -using ZendeskApi_v2; -using ZendeskApi_v2.Models.Topics; - -namespace Tests -{ - [TestFixture] - public class TopicTests - { - private ZendeskApi api = new ZendeskApi(Settings.Site, Settings.AdminEmail, Settings.AdminPassword); - private long forumId; - - public TopicTests() - { - forumId = api.Forums.GetForums().Forums.First().Id.Value; - } - - [Test] - public void CanGetTopics() - { - var res = api.Topics.GetTopics(); - Assert.Greater(res.Count, 0); - - var byId = api.Topics.GetTopicById(res.Topics[0].Id.Value); - Assert.AreEqual(byId.Topic.Id, res.Topics[0].Id); - - var byForum = api.Topics.GetTopicsByForum(res.Topics[0].ForumId.Value); - Assert.AreEqual(byForum.Topics[0].ForumId, res.Topics[0].ForumId.Value); - - var byUser = api.Topics.GetTopicsByUser(Settings.UserId); - Assert.Greater(byUser.Count, 0); - } - - [Test] - public void CanCreateUpdateAndDeleteTopics() - { - var create = api.Topics.CreateTopic(new Topic() - { - ForumId = forumId, - Title = "My test topic", - Body = "testing" - }); - Assert.Greater(create.Topic.Id, 0); - - create.Topic.Title = "My New Test Topic"; - var update = api.Topics.UpdateTopic(create.Topic); - Assert.AreEqual(update.Topic.Title, create.Topic.Title); - - Assert.True(api.Topics.DeleteTopic(create.Topic.Id.Value)); - } - - - [Test] - public void CanShowManyTopics() - { - var create = api.Topics.CreateTopic(new Topic() - { - ForumId = forumId, - Title = "My test topic5", - Body = "testing5" - }); - - var get = api.Topics.GetTopics(); - - var showMany = api.Topics.GetMultipleTopicsById(get.Topics.Select(x => x.Id.Value).ToList()); - Assert.AreEqual(showMany.Count, get.PageSize); - Assert.Greater(showMany.Count, 0); - - Assert.True(api.Topics.DeleteTopic(create.Topic.Id.Value)); - } - - [Test] - public void CanGetCreateUpdateAndDeleteTopicComments() - { - var topicId = api.Topics.GetTopics().Topics[0].Id.Value; - var create = api.Topics.CreateTopicComment(topicId, new TopicComment() - { - Body = "testing topic comments!" - }); - - Assert.Greater(create.TopicComment.Id.Value, 0); - - create.TopicComment.Body = "even more testing for topic comments!"; - var update = api.Topics.UpdateTopicComment(create.TopicComment); - Assert.AreEqual(update.TopicComment.Body, create.TopicComment.Body); - - var getComents = api.Topics.GetTopicCommentsByTopicId(topicId); - Assert.Greater(getComents.Count, 0); - - var getByUser = api.Topics.GetTopicCommentsByUserId(Settings.UserId); - Assert.Greater(getByUser.Count, 0); - - var getSpecific = api.Topics.GetSpecificTopicCommentByTopic(topicId, update.TopicComment.Id.Value); - Assert.AreEqual(getSpecific.TopicComment.Id, update.TopicComment.Id); - - //This test doesn't seem to work, looks like a problem on Zendesk's side. - //var getSpecificByUser = api.Topics.GetSpecificTopicCommentByUser(AccountsAndActivity.UserId, update.TopicComment.Id.Value); - //Assert.AreEqual(getSpecificByUser.TopicComment.Id, update.TopicComment.Id); - - Assert.True(api.Topics.DeleteTopicComment(update.TopicComment.TopicId.Value, update.TopicComment.Id.Value)); - } - - [Test] - public void CanGetCreateAndDeleteTopicSubscriptions() - { - var topicId = api.Topics.GetTopics().Topics[0].Id.Value; - - var create = api.Topics.CreateTopicSubscription(Settings.EndUserId, topicId); - Assert.Greater(create.TopicSubscription.Id.Value, 0); - - var getAll = api.Topics.GetAllTopicSubscriptions(); - Assert.Greater(getAll.Count, 0); - - var getByTopic = api.Topics.GetTopicSubscriptionsByTopic(topicId); - Assert.Greater(getByTopic.Count, 0); - - var getById = api.Topics.GetTopicSubscriptionById(create.TopicSubscription.Id.Value); - Assert.AreEqual(getById.TopicSubscription.Id, create.TopicSubscription.Id); - - Assert.True(api.Topics.DeleteTopicSubscription(create.TopicSubscription.Id.Value)); - } - - [Test] - public void CanGetCreateAndDeleteTopicVotes() - { - var topicId = api.Topics.GetTopics().Topics[0].Id.Value; - - var create = api.Topics.CreateVote(topicId); - Assert.Greater(create.TopicVote.Id.Value, 0); - - var topicVotes = api.Topics.GetTopicVotes(topicId); - Assert.Greater(topicVotes.Count, 0); - - var userVotes = api.Topics.GetTopicVotesByUser(Settings.UserId); - Assert.Greater(userVotes.Count, 0); - - var checkVote = api.Topics.CheckForVote(topicId); - Assert.Greater(checkVote.TopicVote.Id.Value, 0); - - Assert.True(api.Topics.DeleteVote(topicId)); - } - } -} \ No newline at end of file