From 6c8dcdef16ca3fdc649f84b3fe7c5802d4a95b1e Mon Sep 17 00:00:00 2001 From: Robert Peerenboom Date: Tue, 19 Sep 2023 20:45:38 +0200 Subject: [PATCH] Erweiterung Links --- src/Zammad.Client/Resources/Assets.cs | 26 +++++++++++ src/Zammad.Client/Resources/Link.cs | 28 +++++++++++ src/Zammad.Client/Resources/Relations.cs | 15 ++++++ src/Zammad.Client/Resources/Role.cs | 59 ++++++++++++++++++++++++ src/Zammad.Client/TicketClient.cs | 4 ++ 5 files changed, 132 insertions(+) create mode 100644 src/Zammad.Client/Resources/Assets.cs create mode 100644 src/Zammad.Client/Resources/Link.cs create mode 100644 src/Zammad.Client/Resources/Relations.cs create mode 100644 src/Zammad.Client/Resources/Role.cs diff --git a/src/Zammad.Client/Resources/Assets.cs b/src/Zammad.Client/Resources/Assets.cs new file mode 100644 index 0000000..f7d994a --- /dev/null +++ b/src/Zammad.Client/Resources/Assets.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Data; +using Newtonsoft.Json; + +namespace Zammad.Client.Resources +{ + [JsonObject] + public class Assets + { + [JsonProperty("Ticket")] + public Dictionary Ticket { get; set; } + + [JsonProperty("Group")] + public Dictionary Group { get; set; } + + [JsonProperty("User")] + public Dictionary User { get; set; } + + [JsonProperty("Role")] + public Dictionary Role { get; set; } + + [JsonProperty("Organization")] + public Dictionary Organization { get; set; } + } +} diff --git a/src/Zammad.Client/Resources/Link.cs b/src/Zammad.Client/Resources/Link.cs new file mode 100644 index 0000000..10d1070 --- /dev/null +++ b/src/Zammad.Client/Resources/Link.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Zammad.Client.Resources +{ + public enum LinkType + { + child, + parent + } + public enum LinkObject + { + Ticket + } + [JsonObject] + public class Link + { + [JsonProperty("link_type")] + public string LinkType { get; set; } + + [JsonProperty("link_object")] + public string LinkObject { get; set; } + + [JsonProperty("link_object_value")] + public int LinkObjectValue { get; set; } + } +} diff --git a/src/Zammad.Client/Resources/Relations.cs b/src/Zammad.Client/Resources/Relations.cs new file mode 100644 index 0000000..d30223f --- /dev/null +++ b/src/Zammad.Client/Resources/Relations.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Zammad.Client.Resources +{ + [JsonObject] + public class Relations + { + [JsonProperty("links")] + public List Links { get; set; } + [JsonProperty("assets")] + public Assets Assets { get; set; } + } +} diff --git a/src/Zammad.Client/Resources/Role.cs b/src/Zammad.Client/Resources/Role.cs new file mode 100644 index 0000000..737b6fd --- /dev/null +++ b/src/Zammad.Client/Resources/Role.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Data; +using Newtonsoft.Json; + +namespace Zammad.Client.Resources +{ + [JsonObject] + public class Role + { + [JsonProperty("id")] + public int Id { get; set; } + + [JsonProperty("signature_id")] + public int? SignatureId { get; set; } + + [JsonProperty("email_address_id")] + public int EmailAddressId { get; set; } + + [JsonProperty("name")] + public string Name { get; set; } + + [JsonProperty("assignment_timeout")] + public int? AssignmentTimeout { get; set; } + + [JsonProperty("follow_up_possible")] + public string FollowUpPossible { get; set; } + + [JsonProperty("reopen_time_in_days")] + public int? ReopenTimeInDays { get; set; } + + [JsonProperty("follow_up_assignment")] + public bool FollowUpAssignment { get; set; } + + [JsonProperty("active")] + public bool Active { get; set; } + + [JsonProperty("shared_drafts")] + public bool SharedDrafts { get; set; } + + [JsonProperty("note")] + public string Note { get; set; } + + [JsonProperty("updated_by_id")] + public int UpdatedById { get; set; } + + [JsonProperty("create_by_id")] + public int CreatedById { get; set; } + + [JsonProperty("created_at")] + public DateTime CreatedAt { get; set; } + + [JsonProperty("updated_at")] + public DateTime UpdatedAt { get; set; } + + [JsonProperty("user_ids")] + public List UserIds { get; set; } + } +} diff --git a/src/Zammad.Client/TicketClient.cs b/src/Zammad.Client/TicketClient.cs index be7aaab..9ed4b25 100644 --- a/src/Zammad.Client/TicketClient.cs +++ b/src/Zammad.Client/TicketClient.cs @@ -27,6 +27,10 @@ public Task> GetTicketListAsync(int page, int count) { return GetAsync>("/api/v1/tickets", $"page={page}&per_page={count}"); } + public Task GetTicketRelations(LinkType linktype, LinkObject link_object,int link_object_value) + { + return GetAsync("/api/v1/links", $"link_type={linktype}&link_object={link_object}&link_object_value={link_object_value.ToString()}"); + } public Task> SearchTicketAsync(string query, int limit) {