-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
68d53ff
commit e29f042
Showing
39 changed files
with
888 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/JiraServiceDesk.Net/Models/Common/JiraServiceDeskDate.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
|
||
namespace JiraServiceDesk.Net.Models.Common | ||
{ | ||
public class JiraServiceDeskDate | ||
{ | ||
public DateTime? Iso8601 { get; set; } | ||
public DateTime? Jira { get; set; } | ||
public string Friendly { get; set; } | ||
public long EpochMillis { get; set; } | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/JiraServiceDesk.Net/Models/Common/JsonEnumConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using Newtonsoft.Json; | ||
|
||
namespace JiraServiceDesk.Net.Models.Common | ||
{ | ||
public abstract class JsonEnumConverter<TEnum> : JsonConverter | ||
where TEnum : struct, IConvertible | ||
{ | ||
public abstract string ConvertToString(TEnum value); | ||
|
||
public abstract TEnum ConvertFromString(string s); | ||
|
||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) | ||
{ | ||
var actualValue = (TEnum)value; | ||
writer.WriteValue(ConvertToString(actualValue)); | ||
} | ||
|
||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) | ||
{ | ||
string s = (string)reader.Value; | ||
return ConvertFromString(s); | ||
} | ||
|
||
public override bool CanConvert(Type objectType) | ||
{ | ||
return objectType == typeof(string); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace JiraServiceDesk.Net.Models.Common | ||
{ | ||
public abstract class NamedId | ||
{ | ||
public string Id { get; set; } | ||
public string Name { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace JiraServiceDesk.Net.Models.Common | ||
{ | ||
public abstract class NamedIdWithLinks : WithLinks | ||
{ | ||
public abstract class NamedId | ||
{ | ||
public string Id { get; set; } | ||
public string Name { get; set; } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace JiraServiceDesk.Net.Models.Common | ||
{ | ||
public class Reporter : User | ||
{ } | ||
} |
7 changes: 4 additions & 3 deletions
7
...ceDesk.Net/Models/ServiceDesk/Reporter.cs → ...JiraServiceDesk.Net/Models/Common/User.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
namespace JiraServiceDesk.Net.Models.ServiceDesk | ||
namespace JiraServiceDesk.Net.Models.Common | ||
{ | ||
public class Reporter | ||
public abstract class User : WithLinks | ||
{ | ||
public string Name { get; set; } | ||
public string Key { get; set; } | ||
public string EmailAddress { get; set; } | ||
public string DisplayName { get; set; } | ||
public bool Active { get; set; } | ||
public string TimeZone { get; set; } | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace JiraServiceDesk.Net.Models.Request | ||
{ | ||
public class Approval | ||
{ | ||
public Approver Approver { get; set; } | ||
public string ApproverDecision { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
using JiraServiceDesk.Net.Models.Common; | ||
|
||
namespace JiraServiceDesk.Net.Models.Request | ||
{ | ||
public class Approver : User | ||
{ } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using JiraServiceDesk.Net.Models.Common; | ||
|
||
namespace JiraServiceDesk.Net.Models.Request | ||
{ | ||
public class Attachment : WithLinks | ||
{ | ||
public string Filename { get; set; } | ||
public User Author { get; set; } | ||
public JiraServiceDeskDate Created { get; set; } | ||
public int Size { get; set; } | ||
public string MimeType { get; set; } | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/JiraServiceDesk.Net/Models/Request/AttachmentsResult.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace JiraServiceDesk.Net.Models.Request | ||
{ | ||
public class AttachmentsResult | ||
{ | ||
public Comment Comment { get; set; } | ||
public List<Attachment> Attachments { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using JiraServiceDesk.Net.Models.Common; | ||
using Newtonsoft.Json; | ||
|
||
namespace JiraServiceDesk.Net.Models.Request | ||
{ | ||
public class Comment : WithLinks | ||
{ | ||
public string Id { get; set; } | ||
public string Body { get; set; } | ||
[JsonProperty("public")] | ||
public bool IsPublic { get; set; } | ||
public User Author { get; set; } | ||
public JiraServiceDeskDate Created { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using JiraServiceDesk.Net.Models.Common; | ||
|
||
namespace JiraServiceDesk.Net.Models.Request | ||
{ | ||
public class CompletedCycle : Cycle | ||
{ | ||
public JiraServiceDeskDate StopTime { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using JiraServiceDesk.Net.Models.Common; | ||
|
||
namespace JiraServiceDesk.Net.Models.Request | ||
{ | ||
public class CurrentStatus | ||
{ | ||
public string Status { get; set; } | ||
public JiraServiceDeskDate StatusDate { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace JiraServiceDesk.Net.Models.Request | ||
{ | ||
public class CustomerRequest | ||
{ | ||
public string ServiceDeskId { get; set; } | ||
public string RequestTypeId { get; set; } | ||
public RequestFieldValues RequestFieldValues { get; set; } | ||
public string RaiseOnBehalfOf { get; set; } | ||
public List<string> RequestParticipants { get; set; } | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/JiraServiceDesk.Net/Models/Request/CustomerRequestResult.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System.Collections.Generic; | ||
using JiraServiceDesk.Net.Models.Common; | ||
using Newtonsoft.Json; | ||
|
||
namespace JiraServiceDesk.Net.Models.Request | ||
{ | ||
public class CustomerRequestResult : WithLinks | ||
{ | ||
[JsonProperty("_expands")] | ||
public List<string> Expands { get; set; } | ||
public string IssueId { get; set; } | ||
public string IssueKey { get; set; } | ||
public string RequestTypeId { get; set; } | ||
public string ServiceDeskId { get; set; } | ||
public JiraServiceDeskDate CreatedDate { get; set; } | ||
public Reporter Reporter { get; set; } | ||
public List<RequestFieldValue> RequestFieldValues { get; set; } | ||
public CurrentStatus CurrentStatus { get; set; } | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/JiraServiceDesk.Net/Models/Request/CustomerRequestStatus.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using JiraServiceDesk.Net.Models.Common; | ||
|
||
namespace JiraServiceDesk.Net.Models.Request | ||
{ | ||
public class CustomerRequestStatus | ||
{ | ||
public string Status { get; set; } | ||
public JiraServiceDeskDate StatusDate { get; set; } | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/JiraServiceDesk.Net/Models/Request/CustomerRequestTransition.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
using JiraServiceDesk.Net.Models.Common; | ||
|
||
namespace JiraServiceDesk.Net.Models.Request | ||
{ | ||
public class CustomerRequestTransition : NamedId | ||
{ } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using JiraServiceDesk.Net.Models.Common; | ||
|
||
namespace JiraServiceDesk.Net.Models.Request | ||
{ | ||
public abstract class Cycle | ||
{ | ||
public JiraServiceDeskDate StartTime { get; set; } | ||
public bool Breached { get; set; } | ||
public Duration GoalDuration { get; set; } | ||
public Duration ElapsedTime { get; set; } | ||
public Duration RemainingTime { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace JiraServiceDesk.Net.Models.Request | ||
{ | ||
public class Duration | ||
{ | ||
public int Millis { get; set; } | ||
public string Friendly { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
|
||
namespace JiraServiceDesk.Net.Models.Request | ||
{ | ||
[Flags] | ||
public enum Expand | ||
{ | ||
None = 0, | ||
ServiceDesk = 1, | ||
RequestType = 2, | ||
Participant = 4, | ||
Sla = 8, | ||
Status = 16 | ||
} | ||
} |
101 changes: 101 additions & 0 deletions
101
src/JiraServiceDesk.Net/Models/Request/ExpandConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using JiraServiceDesk.Net.Models.Common; | ||
|
||
namespace JiraServiceDesk.Net.Models.Request | ||
{ | ||
public class ExpandConverter : JsonEnumConverter<Expand> | ||
{ | ||
private static readonly Dictionary<Expand, string> s_stringByExpand = new Dictionary<Expand, string> | ||
{ | ||
[Expand.ServiceDesk] = "serviceDesk", | ||
[Expand.RequestType] = "requestType", | ||
[Expand.Participant] = "participant", | ||
[Expand.Sla] = "sla", | ||
[Expand.Status] = "status" | ||
}; | ||
|
||
public static string NullableValueToString(Expand? value) | ||
{ | ||
return value.HasValue | ||
? ValueToString(value.Value) | ||
: null; | ||
} | ||
|
||
public static string ValueToString(Expand value) | ||
{ | ||
var results = new List<string>(); | ||
|
||
if (value.HasFlag(Expand.ServiceDesk)) | ||
{ | ||
results.Add(s_stringByExpand[Expand.ServiceDesk]); | ||
} | ||
if (value.HasFlag(Expand.RequestType)) | ||
{ | ||
results.Add(s_stringByExpand[Expand.RequestType]); | ||
} | ||
if (value.HasFlag(Expand.Participant)) | ||
{ | ||
results.Add(s_stringByExpand[Expand.Participant]); | ||
} | ||
if (value.HasFlag(Expand.Sla)) | ||
{ | ||
results.Add(s_stringByExpand[Expand.Sla]); | ||
} | ||
if (value.HasFlag(Expand.Status)) | ||
{ | ||
results.Add(s_stringByExpand[Expand.Status]); | ||
} | ||
|
||
return string.Join(",", results); | ||
} | ||
|
||
public override string ConvertToString(Expand value) => ValueToString(value); | ||
|
||
private Expand StringToValue(string s) | ||
{ | ||
var pair = s_stringByExpand.FirstOrDefault(kvp => kvp.Value.Equals(s, StringComparison.OrdinalIgnoreCase)); | ||
// ReSharper disable once SuspiciousTypeConversion.Global | ||
if (EqualityComparer<KeyValuePair<RequestOwnership, string>>.Default.Equals(pair)) | ||
{ | ||
throw new ArgumentException($"Unknown expand: {s}"); | ||
} | ||
|
||
return pair.Key; | ||
} | ||
|
||
public override Expand ConvertFromString(string s) | ||
{ | ||
var result = Expand.None; | ||
|
||
var pieces = s.Split(new [] { ",", ", " }, StringSplitOptions.RemoveEmptyEntries); | ||
foreach (string piece in pieces) | ||
{ | ||
var flag = StringToValue(piece); | ||
if (flag == Expand.ServiceDesk) | ||
{ | ||
result |= Expand.ServiceDesk; | ||
} | ||
if (flag == Expand.RequestType) | ||
{ | ||
result |= Expand.RequestType; | ||
} | ||
if (flag == Expand.Participant) | ||
{ | ||
result |= Expand.Participant; | ||
} | ||
if (flag == Expand.Sla) | ||
{ | ||
result |= Expand.Sla; | ||
} | ||
if (flag == Expand.Status) | ||
{ | ||
result |= Expand.Status; | ||
} | ||
} | ||
|
||
return result; | ||
} | ||
} | ||
} |
Oops, something went wrong.