From 72ca9d1ca9a80d1edf63bb0a4c99d36049710296 Mon Sep 17 00:00:00 2001 From: Dan Hounshell Date: Mon, 28 Jul 2014 16:42:40 -0400 Subject: [PATCH 01/40] Added GetDrillThroughStatistics method --- LeanKit.API.Client.Library/ILeanKitApi.cs | 2 ++ .../ILeanKitIntegration.cs | 1 + .../LeanKit.API.Client.Library.csproj | 2 ++ LeanKit.API.Client.Library/LeanKitClient.cs | 6 ++++ .../LeanKitIntegration.cs | 5 ++++ .../TransferObjects/DrillThroughStatistics.cs | 30 +++++++++++++++++++ .../DrillThroughStatisticsCard.cs | 19 ++++++++++++ 7 files changed, 65 insertions(+) create mode 100644 LeanKit.API.Client.Library/TransferObjects/DrillThroughStatistics.cs create mode 100644 LeanKit.API.Client.Library/TransferObjects/DrillThroughStatisticsCard.cs diff --git a/LeanKit.API.Client.Library/ILeanKitApi.cs b/LeanKit.API.Client.Library/ILeanKitApi.cs index 2393f70..40b55de 100644 --- a/LeanKit.API.Client.Library/ILeanKitApi.cs +++ b/LeanKit.API.Client.Library/ILeanKitApi.cs @@ -48,6 +48,7 @@ public interface ILeanKitApi IEnumerable ListNewCards(long boardId); CardMoveBetweenBoardsResult MoveCardToAnotherBoard(long cardId, long destBoardId); User GetCurrentUser(long boardId); + DrillThroughStatistics GetDrillThroughStatistics(long boardId, long cardId); Taskboard GetTaskboardById(long boardId, long taskboardId); Taskboard GetTaskboard(long boardId, long cardId); @@ -58,6 +59,7 @@ public interface ILeanKitApi long DeleteTask(long boardId, long cardId, long taskId); CardMoveResult MoveTask(long boardId, long cardId, long taskId, long toLaneId, int position); CardMoveResult MoveTask(long boardId, long cardId, long taskId, long toLaneId, int position, string wipOverrideReason); + long SaveAttachment(long boardId, long cardId, string fileName, string description, string mimeType, byte[] fileBytes); long DeleteAttachment(long boardId, long cardId, long attachmentId); Asset GetAttachment(long boardId, long cardId, long attachmentId); diff --git a/LeanKit.API.Client.Library/ILeanKitIntegration.cs b/LeanKit.API.Client.Library/ILeanKitIntegration.cs index 26fbb6a..fa61a35 100644 --- a/LeanKit.API.Client.Library/ILeanKitIntegration.cs +++ b/LeanKit.API.Client.Library/ILeanKitIntegration.cs @@ -38,6 +38,7 @@ public interface ILeanKitIntegration void MoveCard(long cardId, long toLaneId, int position, string wipOverrideReason); void MoveCard(long cardId, long toLaneId, int position); IEnumerable SearchCards(SearchOptions options); + DrillThroughStatistics GetDrillThroughStatistics(long cardId, long boardId); Taskboard GetTaskboard(long cardId); void AddTask(Card task, long cardId); diff --git a/LeanKit.API.Client.Library/LeanKit.API.Client.Library.csproj b/LeanKit.API.Client.Library/LeanKit.API.Client.Library.csproj index 3de8532..a2eb398 100644 --- a/LeanKit.API.Client.Library/LeanKit.API.Client.Library.csproj +++ b/LeanKit.API.Client.Library/LeanKit.API.Client.Library.csproj @@ -105,6 +105,8 @@ + + diff --git a/LeanKit.API.Client.Library/LeanKitClient.cs b/LeanKit.API.Client.Library/LeanKitClient.cs index 0b0bda4..347ed41 100644 --- a/LeanKit.API.Client.Library/LeanKitClient.cs +++ b/LeanKit.API.Client.Library/LeanKitClient.cs @@ -310,6 +310,12 @@ public CardMoveBetweenBoardsResult MoveCardToAnotherBoard(long cardId, long dest return _restCommandProcessor.Post(_accountAuth, resource); } + public DrillThroughStatistics GetDrillThroughStatistics(long boardId, long cardId) + { + var resource = string.Format("/Kanban/Api/Card/{0}/GetDrillThroughStatistics/{1}", boardId, cardId); + return _restCommandProcessor.Get(_accountAuth, resource); + } + #endregion #region Taskboard methods diff --git a/LeanKit.API.Client.Library/LeanKitIntegration.cs b/LeanKit.API.Client.Library/LeanKitIntegration.cs index 6b23014..a304189 100644 --- a/LeanKit.API.Client.Library/LeanKitIntegration.cs +++ b/LeanKit.API.Client.Library/LeanKitIntegration.cs @@ -893,6 +893,11 @@ public void DeleteAttachment(long cardId, long attachmentId) _api.DeleteAttachment(_boardId, cardId, attachmentId); } + public DrillThroughStatistics GetDrillThroughStatistics(long boardId, long cardId) + { + return _api.GetDrillThroughStatistics(boardId, cardId); + } + #region obsolete [Obsolete("Creating taskboards is no longer supported", true)] diff --git a/LeanKit.API.Client.Library/TransferObjects/DrillThroughStatistics.cs b/LeanKit.API.Client.Library/TransferObjects/DrillThroughStatistics.cs new file mode 100644 index 0000000..82dfd99 --- /dev/null +++ b/LeanKit.API.Client.Library/TransferObjects/DrillThroughStatistics.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// Copyright (c) LeanKit Inc. All rights reserved. +// +//------------------------------------------------------------------------------ + +namespace LeanKit.API.Client.Library.TransferObjects +{ + public class DrillThroughStatistics + { + public DrillThroughStatisticsCard ParentCard { get; set; } + public bool IsDeleted { get; set; } + public int TotalNumberOfCards { get; set; } + public int NumberOfCardsNotStarted { get; set; } + public int NumberOfCardsStarted { get; set; } + public int NumberOfCardsCompleted { get; set; } + public int BlockedCards { get; set; } + public int NumberOfCardsPastDue { get; set; } + public string ProjectedStartDate { get; set; } + public string ProjectedFinishDate { get; set; } + public string ActualStartDate { get; set; } + public string ActualFinishDate { get; set; } + public bool IsAnyCardProjectedFinishDatePastParentCardProjectedFinishedDate { get; set; } + public int TotalSizeOfCards { get; set; } + public int TotalSizeOfCardsNotStarted { get; set; } + public int TotalSizeOfCardsStarted { get; set; } + public int TotalSizeOfCardsCompleted { get; set; } + public double TotalProgressPercentage { get; set; } + } +} \ No newline at end of file diff --git a/LeanKit.API.Client.Library/TransferObjects/DrillThroughStatisticsCard.cs b/LeanKit.API.Client.Library/TransferObjects/DrillThroughStatisticsCard.cs new file mode 100644 index 0000000..16a7f07 --- /dev/null +++ b/LeanKit.API.Client.Library/TransferObjects/DrillThroughStatisticsCard.cs @@ -0,0 +1,19 @@ +//------------------------------------------------------------------------------ +// +// Copyright (c) LeanKit Inc. All rights reserved. +// +//------------------------------------------------------------------------------ + +namespace LeanKit.API.Client.Library.TransferObjects +{ + public class DrillThroughStatisticsCard + { + public long Id { get; set; } + public bool IsBlocked { get; set; } + public int Size { get; set; } + public string PlannedStartDate { get; set; } + public string PlannedFinishDate { get; set; } + public string ActualStartDate { get; set; } + public string ActualFinishDate { get; set; } + } +} \ No newline at end of file From bc160afefdfb3b4b0f0088a41bf02657b369499a Mon Sep 17 00:00:00 2001 From: Dan Hounshell Date: Wed, 6 Aug 2014 13:59:58 -0400 Subject: [PATCH 02/40] Added drillthrough board properties --- LeanKit.API.Client.Library/TransferObjects/CardView.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/LeanKit.API.Client.Library/TransferObjects/CardView.cs b/LeanKit.API.Client.Library/TransferObjects/CardView.cs index 8926a62..8eea8fe 100644 --- a/LeanKit.API.Client.Library/TransferObjects/CardView.cs +++ b/LeanKit.API.Client.Library/TransferObjects/CardView.cs @@ -54,6 +54,11 @@ public virtual string PriorityText public virtual string DateArchived { get; set; } public virtual string LastComment { get; set; } public virtual int CommentsCount { get; set; } + public string LastAttachment { get; set; } + public int AttachmentsCount { get; set; } + + public virtual long? DrillThroughBoardId { get; set; } + public virtual bool HasDrillThroughBoard { get { return DrillThroughBoardId.HasValue; } } public List Comments { get; set; } public List HistoryEvents { get; set; } From db91f5243003bd6a654f41eae0a570d838b0d254 Mon Sep 17 00:00:00 2001 From: Dan Hounshell Date: Fri, 24 Oct 2014 15:26:52 -0400 Subject: [PATCH 03/40] Added properties to AssignedUserInfo Added Id, EmailAddress and FullName properties to AssignedUserInfo as those are the fields that are included in BoardUpdate when calling checkForUpdates. --- .../TransferObjects/AssignedUserInfo.cs | 34 ++++++++++++++++++- .../TransferObjects/CardView.cs | 8 +++-- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/LeanKit.API.Client.Library/TransferObjects/AssignedUserInfo.cs b/LeanKit.API.Client.Library/TransferObjects/AssignedUserInfo.cs index faa61ab..15095af 100644 --- a/LeanKit.API.Client.Library/TransferObjects/AssignedUserInfo.cs +++ b/LeanKit.API.Client.Library/TransferObjects/AssignedUserInfo.cs @@ -10,7 +10,39 @@ public class AssignedUserInfo { public virtual string GravatarLink { get; set; } public virtual string SmallGravatarLink { get; set; } + + // These values are on board updates + private long? _id; + public virtual long? Id + { + get { return _id; } + set + { + _id = value; + if (!AssignedUserId.HasValue) + { + AssignedUserId = value; + } + } + } + + private string _emailAddress; + public virtual string EmailAddress + { + get { return _emailAddress; } + set + { + _emailAddress = value; + if (string.IsNullOrEmpty(AssignedUserName)) + { + AssignedUserName = value; + } + } + } + public virtual string FullName { get; set; } + + // Are thise used? public virtual string AssignedUserName { get; set; } - public virtual long AssignedUserId { get; set; } + public virtual long? AssignedUserId { get; set; } } } \ No newline at end of file diff --git a/LeanKit.API.Client.Library/TransferObjects/CardView.cs b/LeanKit.API.Client.Library/TransferObjects/CardView.cs index 05b9de6..cc8e3db 100644 --- a/LeanKit.API.Client.Library/TransferObjects/CardView.cs +++ b/LeanKit.API.Client.Library/TransferObjects/CardView.cs @@ -34,7 +34,6 @@ public virtual string PriorityText public virtual bool Active { get; set; } public virtual string Color { get; set; } public virtual long Version { get; set; } - public virtual List AssignedUsers { get; set; } public virtual bool IsBlocked { get; set; } public virtual string BlockReason { get; set; } public virtual int Index { get; set; } @@ -57,6 +56,10 @@ public virtual string PriorityText public string LastAttachment { get; set; } public int AttachmentsCount { get; set; } + public virtual long? AssignedUserId { get; set; } + public long[] AssignedUserIds { get; set; } + public virtual List AssignedUsers { get; set; } + public virtual long? DrillThroughBoardId { get; set; } public virtual bool HasDrillThroughBoard { get { return DrillThroughBoardId.HasValue; } } @@ -88,10 +91,9 @@ public Card ToCard() card.Title = Title; card.TypeId = TypeId; card.Version = Version; - card.AssignedUserIds = (AssignedUsers != null) ? AssignedUsers.Select(x => x.AssignedUserId).ToArray() : null; + card.AssignedUserIds = (AssignedUsers != null) ? (AssignedUserIds != null) ? AssignedUserIds : AssignedUsers.Select(x => x.Id.Value).ToArray() : null; card.Comments = Comments; card.HistoryEvents = HistoryEvents; - card.HistoryEvents = HistoryEvents; card.LastMove = LastMove; card.LastActivity = LastActivity; card.LastComment = LastComment; From 1e9ffdc0afa2f04fb9c849387e07214d96b14f4c Mon Sep 17 00:00:00 2001 From: David Neal Date: Fri, 21 Nov 2014 08:45:16 -0500 Subject: [PATCH 04/40] Adding support for token auth --- .../LeanKit.API.Client.Library.Tests.csproj | 6 +- .../packages.config | 4 +- LeanKit.API.Client.Library/IInitializable.cs | 3 + .../ILeanKitAccountAuth.cs | 13 ++ .../ILeanKitClientFactory.cs | 4 + .../ILeanKitIntegrationFactory.cs | 17 +++ .../IRestCommandProcessor.cs | 12 ++ .../LeanKit.API.Client.Library.csproj | 17 +-- .../LeanKitAccountAuthBase.cs | 24 ++++ .../LeanKitBasicAuth - Copy.cs | 9 ++ .../LeanKitBasicAuth.cs | 7 + LeanKit.API.Client.Library/LeanKitClient.cs | 9 +- .../LeanKitClientFactory.cs | 8 ++ .../LeanKitIntegrationFactory.cs | 29 +++- .../RestSharpCommandProcessor.cs | 128 ++++++++++++++---- .../TokenAuthenticator.cs | 23 ++++ .../TransferObjects/LeanKitAccountAuth.cs | 15 ++ LeanKit.API.Client.Library/packages.config | 4 +- Samples/LeanKitCmdQuery/LeanKitQuery.cs | 2 +- .../LeanKitNotifierApplicationContext.cs | 3 +- Samples/LeanKitScriptCS/ExportCards.csx | 2 +- publish/LeanKit.API.Client.Library.dll.nuspec | 2 +- 22 files changed, 291 insertions(+), 50 deletions(-) create mode 100644 LeanKit.API.Client.Library/ILeanKitAccountAuth.cs create mode 100644 LeanKit.API.Client.Library/LeanKitAccountAuthBase.cs create mode 100644 LeanKit.API.Client.Library/LeanKitBasicAuth - Copy.cs create mode 100644 LeanKit.API.Client.Library/LeanKitBasicAuth.cs create mode 100644 LeanKit.API.Client.Library/TokenAuthenticator.cs diff --git a/LeanKit.API.Client.Library.Tests/LeanKit.API.Client.Library.Tests.csproj b/LeanKit.API.Client.Library.Tests/LeanKit.API.Client.Library.Tests.csproj index 0b0d4f2..edafa23 100644 --- a/LeanKit.API.Client.Library.Tests/LeanKit.API.Client.Library.Tests.csproj +++ b/LeanKit.API.Client.Library.Tests/LeanKit.API.Client.Library.Tests.csproj @@ -38,15 +38,15 @@ False - ..\packages\Newtonsoft.Json.6.0.3\lib\net40\Newtonsoft.Json.dll + ..\packages\Newtonsoft.Json.6.0.6\lib\net40\Newtonsoft.Json.dll False ..\packages\NUnit.2.6.3\lib\nunit.framework.dll - + False - ..\packages\RestSharp.104.4.0\lib\net4\RestSharp.dll + ..\packages\RestSharp.105.0.1\lib\net4\RestSharp.dll False diff --git a/LeanKit.API.Client.Library.Tests/packages.config b/LeanKit.API.Client.Library.Tests/packages.config index a747bde..1895610 100644 --- a/LeanKit.API.Client.Library.Tests/packages.config +++ b/LeanKit.API.Client.Library.Tests/packages.config @@ -1,7 +1,7 @@  - + - + \ No newline at end of file diff --git a/LeanKit.API.Client.Library/IInitializable.cs b/LeanKit.API.Client.Library/IInitializable.cs index 4080adb..8b6ed86 100644 --- a/LeanKit.API.Client.Library/IInitializable.cs +++ b/LeanKit.API.Client.Library/IInitializable.cs @@ -4,12 +4,15 @@ // //------------------------------------------------------------------------------ +using System; using LeanKit.API.Client.Library.TransferObjects; namespace LeanKit.API.Client.Library { public interface ILeanKitClient { + [Obsolete("This is deprecated. Please use ILeanKitAccountAuth instead.")] ILeanKitApi Initialize(LeanKitAccountAuth accountAuth); + ILeanKitApi Initialize(ILeanKitAccountAuth accountAuth); } } \ No newline at end of file diff --git a/LeanKit.API.Client.Library/ILeanKitAccountAuth.cs b/LeanKit.API.Client.Library/ILeanKitAccountAuth.cs new file mode 100644 index 0000000..bfedb77 --- /dev/null +++ b/LeanKit.API.Client.Library/ILeanKitAccountAuth.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace LeanKit.API.Client.Library +{ + public interface ILeanKitAccountAuth + { + string GetAccountUrl(); + string Hostname { get; set; } + } +} diff --git a/LeanKit.API.Client.Library/ILeanKitClientFactory.cs b/LeanKit.API.Client.Library/ILeanKitClientFactory.cs index 6191b12..945eba0 100644 --- a/LeanKit.API.Client.Library/ILeanKitClientFactory.cs +++ b/LeanKit.API.Client.Library/ILeanKitClientFactory.cs @@ -4,6 +4,7 @@ // //------------------------------------------------------------------------------ +using System; using LeanKit.API.Client.Library.TransferObjects; namespace LeanKit.API.Client.Library @@ -15,6 +16,9 @@ namespace LeanKit.API.Client.Library /// public interface ILeanKitClientFactory { + ILeanKitApi Create(ILeanKitAccountAuth accountAuth); + + [Obsolete("This is deprecated. Please use ILeanKitAccountAuth instead.")] ILeanKitApi Create(LeanKitAccountAuth accountAuth); } } \ No newline at end of file diff --git a/LeanKit.API.Client.Library/ILeanKitIntegrationFactory.cs b/LeanKit.API.Client.Library/ILeanKitIntegrationFactory.cs index baad95f..1fc5495 100644 --- a/LeanKit.API.Client.Library/ILeanKitIntegrationFactory.cs +++ b/LeanKit.API.Client.Library/ILeanKitIntegrationFactory.cs @@ -4,6 +4,7 @@ // //------------------------------------------------------------------------------ +using System; using LeanKit.API.Client.Library.TransferObjects; namespace LeanKit.API.Client.Library @@ -20,8 +21,24 @@ public interface ILeanKitIntegrationFactory /// The Identity of the Board that will be watched and modified. /// The account authentication information used to connect to the LeanKit API. /// The used to monitor and modify the specified board. + [Obsolete("This is deprecated. Please use ILeanKitAccountAuth instead.")] ILeanKitIntegration Create(long boardId, LeanKitAccountAuth accountAuth); + [Obsolete("This is deprecated. Please use ILeanKitAccountAuth instead.")] ILeanKitIntegration Create(long boardId, LeanKitAccountAuth accountAuth, IntegrationSettings settings); + /// + /// Factory method that creates and returns the implementation using the + /// LeanKitClient created with the default . + /// + /// + /// The default implementation of the uses RestSharp. + /// + /// The Identity of the Board that will be watched and modified. + /// The account authentication information used to connect to the LeanKit API. + /// The used to monitor and modify the specified board. + [Obsolete("This is deprecated. Please use ILeanKitAccountAuth instead.")] + ILeanKitIntegration Create(long boardId, ILeanKitAccountAuth accountAuth); + [Obsolete("This is deprecated. Please use ILeanKitAccountAuth instead.")] + ILeanKitIntegration Create(long boardId, ILeanKitAccountAuth accountAuth, IntegrationSettings settings); } } \ No newline at end of file diff --git a/LeanKit.API.Client.Library/IRestCommandProcessor.cs b/LeanKit.API.Client.Library/IRestCommandProcessor.cs index 348452f..f8758a1 100644 --- a/LeanKit.API.Client.Library/IRestCommandProcessor.cs +++ b/LeanKit.API.Client.Library/IRestCommandProcessor.cs @@ -4,6 +4,7 @@ // //------------------------------------------------------------------------------ +using System; using System.Collections.Generic; using LeanKit.API.Client.Library.TransferObjects; using RestSharp; @@ -16,10 +17,21 @@ namespace LeanKit.API.Client.Library /// public interface IRestCommandProcessor { + [Obsolete("This is deprecated. Please use ILeanKitAccountAuth instead.")] T Get(LeanKitAccountAuth accountAuth, string resource) where T : new(); + [Obsolete("This is deprecated. Please use ILeanKitAccountAuth instead.")] T Get(LeanKitAccountAuth accountAuth, string resource, object body) where T : new(); + [Obsolete("This is deprecated. Please use ILeanKitAccountAuth instead.")] T Post(LeanKitAccountAuth accountAuth, string resource, object body) where T : new(); + [Obsolete("This is deprecated. Please use ILeanKitAccountAuth instead.")] T Post(LeanKitAccountAuth accountAuth, string resource) where T : new(); + [Obsolete("This is deprecated. Please use ILeanKitAccountAuth instead.")] T PostFile(LeanKitAccountAuth accountAuth, string resource, Dictionary parameters, string fileName, string mimeType, byte[] fileBytes) where T : new(); + + T Get(ILeanKitAccountAuth accountAuth, string resource) where T : new(); + T Get(ILeanKitAccountAuth accountAuth, string resource, object body) where T : new(); + T Post(ILeanKitAccountAuth accountAuth, string resource, object body) where T : new(); + T Post(ILeanKitAccountAuth accountAuth, string resource) where T : new(); + T PostFile(ILeanKitAccountAuth accountAuth, string resource, Dictionary parameters, string fileName, string mimeType, byte[] fileBytes) where T : new(); } } \ No newline at end of file diff --git a/LeanKit.API.Client.Library/LeanKit.API.Client.Library.csproj b/LeanKit.API.Client.Library/LeanKit.API.Client.Library.csproj index a2eb398..7ffc959 100644 --- a/LeanKit.API.Client.Library/LeanKit.API.Client.Library.csproj +++ b/LeanKit.API.Client.Library/LeanKit.API.Client.Library.csproj @@ -37,16 +37,12 @@ - ..\packages\Newtonsoft.Json.6.0.3\lib\net40\Newtonsoft.Json.dll + ..\packages\Newtonsoft.Json.6.0.6\lib\net40\Newtonsoft.Json.dll + True - + False - ..\..\LeanKit.IntegrationService\packages\RestSharp.104.4.0\lib\net4\RestSharp.dll - ..\packages\Newtonsoft.Json.6.0.3\lib\net40\Newtonsoft.Json.dll - - - False - ..\packages\RestSharp.104.4.0\lib\net4\RestSharp.dll + ..\packages\RestSharp.105.0.1\lib\net4\RestSharp.dll @@ -71,6 +67,7 @@ + @@ -78,6 +75,9 @@ + + + @@ -85,6 +85,7 @@ + diff --git a/LeanKit.API.Client.Library/LeanKitAccountAuthBase.cs b/LeanKit.API.Client.Library/LeanKitAccountAuthBase.cs new file mode 100644 index 0000000..6656af1 --- /dev/null +++ b/LeanKit.API.Client.Library/LeanKitAccountAuthBase.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Linq; +using System.Text; + +namespace LeanKit.API.Client.Library +{ + public class LeanKitAccountAuthBase : ILeanKitAccountAuth + { + public LeanKitAccountAuthBase() + { + UrlTemplateOverride = ConfigurationManager.AppSettings["UrlTemplateOverride"] ?? "https://{0}.leankit.com"; + } + + public string Hostname { get; set; } + public string UrlTemplateOverride { get; set; } + + public string GetAccountUrl() + { + return string.Format(UrlTemplateOverride, Hostname); + } + } +} diff --git a/LeanKit.API.Client.Library/LeanKitBasicAuth - Copy.cs b/LeanKit.API.Client.Library/LeanKitBasicAuth - Copy.cs new file mode 100644 index 0000000..6b9be25 --- /dev/null +++ b/LeanKit.API.Client.Library/LeanKitBasicAuth - Copy.cs @@ -0,0 +1,9 @@ +namespace LeanKit.API.Client.Library +{ + public class LeanKitBasicAuth : LeanKitAccountAuthBase + { + public string Username { get; set; } + + public string Password { get; set; } + } +} diff --git a/LeanKit.API.Client.Library/LeanKitBasicAuth.cs b/LeanKit.API.Client.Library/LeanKitBasicAuth.cs new file mode 100644 index 0000000..645ed0f --- /dev/null +++ b/LeanKit.API.Client.Library/LeanKitBasicAuth.cs @@ -0,0 +1,7 @@ +namespace LeanKit.API.Client.Library +{ + public class LeanKitTokenAuth : LeanKitAccountAuthBase + { + public string Token { get; set; } + } +} diff --git a/LeanKit.API.Client.Library/LeanKitClient.cs b/LeanKit.API.Client.Library/LeanKitClient.cs index 347ed41..be4f50a 100644 --- a/LeanKit.API.Client.Library/LeanKitClient.cs +++ b/LeanKit.API.Client.Library/LeanKitClient.cs @@ -83,7 +83,7 @@ public class LeanKitClient : ILeanKitApi, ILeanKitClient { private const string DefaultOverrideReason = "WIP Override performed by external system"; private readonly IRestCommandProcessor _restCommandProcessor; - private LeanKitAccountAuth _accountAuth; + private ILeanKitAccountAuth _accountAuth; public LeanKitClient(IRestCommandProcessor restCommandProcessor) { @@ -524,7 +524,14 @@ public User GetCurrentUser(long boardId) #region ILeanKitClient Members + [Obsolete("This is deprecated. Please use ILeanKitAccountAuth instead.")] public ILeanKitApi Initialize(LeanKitAccountAuth accountAuth) + { + _accountAuth = accountAuth.ToBasicAuth(); + return this; + } + + public ILeanKitApi Initialize(ILeanKitAccountAuth accountAuth) { _accountAuth = accountAuth; return this; diff --git a/LeanKit.API.Client.Library/LeanKitClientFactory.cs b/LeanKit.API.Client.Library/LeanKitClientFactory.cs index b3d3179..58050bf 100644 --- a/LeanKit.API.Client.Library/LeanKitClientFactory.cs +++ b/LeanKit.API.Client.Library/LeanKitClientFactory.cs @@ -4,6 +4,7 @@ // //------------------------------------------------------------------------------ +using System; using LeanKit.API.Client.Library.TransferObjects; using LeanKit.API.Client.Library.Validation; @@ -11,10 +12,17 @@ namespace LeanKit.API.Client.Library { public class LeanKitClientFactory : ILeanKitClientFactory { + [Obsolete("This is deprecated. Please use ILeanKitAccountAuth instead.")] public ILeanKitApi Create(LeanKitAccountAuth accountAuth) { var leanKitClient = new LeanKitClient(new RestSharpCommandProcessor(new ValidationService(null), new IntegrationSettings())); return leanKitClient.Initialize(accountAuth); } + + public ILeanKitApi Create(ILeanKitAccountAuth accountAuth) + { + var leanKitClient = new LeanKitClient(new RestSharpCommandProcessor(new ValidationService(null), new IntegrationSettings())); + return leanKitClient.Initialize(accountAuth); + } } } \ No newline at end of file diff --git a/LeanKit.API.Client.Library/LeanKitIntegrationFactory.cs b/LeanKit.API.Client.Library/LeanKitIntegrationFactory.cs index b67c9af..971d68a 100644 --- a/LeanKit.API.Client.Library/LeanKitIntegrationFactory.cs +++ b/LeanKit.API.Client.Library/LeanKitIntegrationFactory.cs @@ -4,6 +4,7 @@ // //------------------------------------------------------------------------------ +using System; using LeanKit.API.Client.Library.TransferObjects; namespace LeanKit.API.Client.Library @@ -20,13 +21,20 @@ public class LeanKitIntegrationFactory : ILeanKitIntegrationFactory /// The Identity of the Board that will be watched and modified. /// The account authentication information used to connect to the LeanKit API. /// The used to monitor and modify the specified board. - public ILeanKitIntegration Create(long boardId, LeanKitAccountAuth accountAuth) + public ILeanKitIntegration Create(long boardId, ILeanKitAccountAuth accountAuth) { var clientFactory = new LeanKitClientFactory(); var apiClient = clientFactory.Create(accountAuth); return new LeanKitIntegration(boardId, apiClient); } + public ILeanKitIntegration Create(long boardId, ILeanKitAccountAuth accountAuth, IntegrationSettings settings) + { + var clientFactory = new LeanKitClientFactory(); + var apiClient = clientFactory.Create(accountAuth); + return new LeanKitIntegration(boardId, apiClient, settings); + } + /// /// Factory method that creates and returns the implementation using the /// LeanKitClient passed into the method. @@ -43,6 +51,25 @@ public ILeanKitIntegration Create(long boardId, ILeanKitApi apiClient) return new LeanKitIntegration(boardId, apiClient); } + /// + /// Factory method that creates and returns the implementation using the + /// LeanKitClient created with the default . + /// + /// + /// The default implementation of the uses RestSharp. + /// + /// The Identity of the Board that will be watched and modified. + /// The account authentication information used to connect to the LeanKit API. + /// The used to monitor and modify the specified board. + [Obsolete("This is deprecated. Please use ILeanKitAccountAuth instead.")] + public ILeanKitIntegration Create(long boardId, LeanKitAccountAuth accountAuth) + { + var clientFactory = new LeanKitClientFactory(); + var apiClient = clientFactory.Create(accountAuth); + return new LeanKitIntegration(boardId, apiClient); + } + + [Obsolete("This is deprecated. Please use ILeanKitAccountAuth instead.")] public ILeanKitIntegration Create(long boardId, LeanKitAccountAuth accountAuth, IntegrationSettings settings) { var clientFactory = new LeanKitClientFactory(); diff --git a/LeanKit.API.Client.Library/RestSharpCommandProcessor.cs b/LeanKit.API.Client.Library/RestSharpCommandProcessor.cs index ed96131..7cf1b8c 100644 --- a/LeanKit.API.Client.Library/RestSharpCommandProcessor.cs +++ b/LeanKit.API.Client.Library/RestSharpCommandProcessor.cs @@ -33,20 +33,20 @@ public RestSharpCommandProcessor(IValidationService validationService, Integrati _settings = settings; } - public T Get(LeanKitAccountAuth accountAuth, string resource) where T : new() + public T Get(ILeanKitAccountAuth accountAuth, string resource) where T : new() { return Process(accountAuth, - new RestRequest(Method.GET) {Resource = resource, RequestFormat = DataFormat.Json}); + new RestRequest(Method.GET) { Resource = resource, RequestFormat = DataFormat.Json }); } - public T Get(LeanKitAccountAuth accountAuth, string resource, object body) where T : new() + public T Get(ILeanKitAccountAuth accountAuth, string resource, object body) where T : new() { - var restRequest = new RestRequest(Method.GET) {Resource = resource, RequestFormat = DataFormat.Json}; + var restRequest = new RestRequest(Method.GET) { Resource = resource, RequestFormat = DataFormat.Json }; restRequest.AddBody(body); return Process(accountAuth, restRequest); } - public T Post(LeanKitAccountAuth accountAuth, string resource, object body) where T : new() + public T Post(ILeanKitAccountAuth accountAuth, string resource, object body) where T : new() { var restRequest = new RestRequest(Method.POST) { @@ -58,26 +58,26 @@ public RestSharpCommandProcessor(IValidationService validationService, Integrati return Process(accountAuth, restRequest); } - public T Post(LeanKitAccountAuth accountAuth, string resource) where T : new() + public T Post(ILeanKitAccountAuth accountAuth, string resource) where T : new() { return Process(accountAuth, - new RestRequest(Method.POST) {Resource = resource, RequestFormat = DataFormat.Json}); + new RestRequest(Method.POST) { Resource = resource, RequestFormat = DataFormat.Json }); } - public T PostFile(LeanKitAccountAuth accountAuth, string resource, Dictionary parameters, string fileName, string mimeType, byte[] fileBytes) where T : new() + public T PostFile(ILeanKitAccountAuth accountAuth, string resource, Dictionary parameters, string fileName, string mimeType, byte[] fileBytes) where T : new() { var boundary = string.Format("----------{0:N}", Guid.NewGuid()); var contentType = "multipart/form-data; boundary=" + boundary; var formBytes = GetMultipartFormData(parameters, boundary, fileName, mimeType, fileBytes); var request = WebRequest.Create(accountAuth.GetAccountUrl() + resource) as HttpWebRequest; - + if (request == null) throw new Exception("Error posting file. Could not create HttpWebRequest"); request.Method = "POST"; request.ContentType = contentType; request.ContentLength = formBytes.Length; - request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.Default.GetBytes(accountAuth.Username + ":" + accountAuth.Password))); + AddAuth(request, accountAuth); using (var requestStream = request.GetRequestStream()) { @@ -112,6 +112,36 @@ public RestSharpCommandProcessor(IValidationService validationService, Integrati }); return retVal; } + + [Obsolete("This is deprecated. Please use ILeanKitAccountAuth instead.")] + public T Get(LeanKitAccountAuth accountAuth, string resource) where T : new() + { + return Get(accountAuth.ToBasicAuth(), resource); + } + + [Obsolete("This is deprecated. Please use ILeanKitAccountAuth instead.")] + public T Get(LeanKitAccountAuth accountAuth, string resource, object body) where T : new() + { + return Get(accountAuth.ToBasicAuth(), resource, body); + } + + [Obsolete("This is deprecated. Please use ILeanKitAccountAuth instead.")] + public T Post(LeanKitAccountAuth accountAuth, string resource, object body) where T : new() + { + return Post(accountAuth.ToBasicAuth(), resource, body); + } + + [Obsolete("This is deprecated. Please use ILeanKitAccountAuth instead.")] + public T Post(LeanKitAccountAuth accountAuth, string resource) where T : new() + { + return Post(accountAuth.ToBasicAuth(), resource); + } + + [Obsolete("This is deprecated. Please use ILeanKitAccountAuth instead.")] + public T PostFile(LeanKitAccountAuth accountAuth, string resource, Dictionary parameters, string fileName, string mimeType, byte[] fileBytes) where T : new() + { + return PostFile(accountAuth.ToBasicAuth(), resource, parameters, fileName, mimeType, fileBytes); + } private static byte[] GetMultipartFormData(Dictionary parameters, string boundary, string fileName, string mimeType, byte[] fileBytes) { @@ -149,7 +179,7 @@ private static byte[] GetMultipartFormData(Dictionary parameters return formData; } - private T Process(LeanKitAccountAuth accountAuth, IRestRequest request) where T : new() + private T Process(ILeanKitAccountAuth accountAuth, IRestRequest request) where T : new() { var errorMessages = _validationService.ValidateRequest((RestRequest) request); if (errorMessages.Count > 0) @@ -160,8 +190,8 @@ private static byte[] GetMultipartFormData(Dictionary parameters } var client = new RestClient { - BaseUrl = accountAuth.GetAccountUrl(), - Authenticator = new HttpBasicAuthenticator(accountAuth.Username, accountAuth.Password) + BaseUrl = new Uri(accountAuth.GetAccountUrl()), + Authenticator = GetAuthenticator(accountAuth) }; var response = RetryRequest(request, accountAuth, client); @@ -187,7 +217,7 @@ private static byte[] GetMultipartFormData(Dictionary parameters return retVal; } - private static IRestResponse RetryRequest(IRestRequest request, LeanKitAccountAuth accountAuth, + private static IRestResponse RetryRequest(IRestRequest request, ILeanKitAccountAuth accountAuth, RestClient client) { IRestResponse response = new RestResponse(); @@ -223,7 +253,7 @@ private static Uri GetRequestUri(string fullUrl) } private static void ValidateResponse(IRestResponse response, - LeanKitAccountAuth leanKitAccountAuth, + ILeanKitAccountAuth leanKitAccountAuth, IRestRequest request) { var requestedResource = GetRequestUri(leanKitAccountAuth.GetAccountUrl()); @@ -276,7 +306,7 @@ private static void ValidateResponse(IRestResponse response, } } - private static string FormatApiRequestInfo(LeanKitAccountAuth leanKitAccountAuth, IRestRequest request, bool hidePassword = false) + private static string FormatApiRequestInfo(ILeanKitAccountAuth leanKitAccountAuth, IRestRequest request, bool hidePassword = false) { var accountAuthStringStringBuilder = new StringBuilder(); @@ -285,22 +315,64 @@ private static string FormatApiRequestInfo(LeanKitAccountAuth leanKitAccountAuth accountAuthStringStringBuilder.Append(leanKitAccountAuth.Hostname != null ? leanKitAccountAuth.Hostname + ", " : "Unknown, "); - accountAuthStringStringBuilder.Append("Username: "); - accountAuthStringStringBuilder.Append(leanKitAccountAuth.Username != null - ? leanKitAccountAuth.Username + ", " - : "Unknown, "); - - if (!hidePassword) - { - accountAuthStringStringBuilder.Append("Password: "); - accountAuthStringStringBuilder.Append(leanKitAccountAuth.Password != null - ? leanKitAccountAuth.Password + ", " - : "Unknown, "); - } + + var basicAuth = leanKitAccountAuth as LeanKitBasicAuth; + if (basicAuth != null) + { + accountAuthStringStringBuilder.Append("Username: "); + accountAuthStringStringBuilder.Append(basicAuth.Username != null + ? basicAuth.Username + ", " + : "Unknown, "); + + if (!hidePassword) + { + accountAuthStringStringBuilder.Append("Password: "); + accountAuthStringStringBuilder.Append(basicAuth.Password != null + ? basicAuth.Password + ", " + : "Unknown, "); + } + } + + var tokenAuth = leanKitAccountAuth as LeanKitTokenAuth; + if (tokenAuth != null && !hidePassword) + { + + accountAuthStringStringBuilder.Append("Token: "); + accountAuthStringStringBuilder.Append(tokenAuth.Token != null + ? tokenAuth.Token + ", " + : "Unknown, "); + } accountAuthStringStringBuilder.Append("Resource: "); accountAuthStringStringBuilder.Append(request.Resource != null ? request.Resource + ", " : "Unknown, "); return accountAuthStringStringBuilder.ToString(); } + + private static void AddAuth(WebRequest request, ILeanKitAccountAuth auth) + { + if (auth is LeanKitBasicAuth) + { + var basicAuth = auth as LeanKitBasicAuth; + request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.Default.GetBytes(basicAuth.Username + ":" + basicAuth.Password))); + } + else if (auth is LeanKitTokenAuth) + { + request.Headers.Add("Authorization", "Token " + (auth as LeanKitTokenAuth).Token); + } + } + + private static IAuthenticator GetAuthenticator(ILeanKitAccountAuth auth) + { + if (auth is LeanKitBasicAuth) + { + var basicAuth = auth as LeanKitBasicAuth; + return new HttpBasicAuthenticator(basicAuth.Username, basicAuth.Password); + } + if (auth is LeanKitTokenAuth) + { + return new TokenAuthenticator((auth as LeanKitTokenAuth).Token); + } + throw new ArgumentException("Unknown ILeanKitAccountAuth type"); + } } } \ No newline at end of file diff --git a/LeanKit.API.Client.Library/TokenAuthenticator.cs b/LeanKit.API.Client.Library/TokenAuthenticator.cs new file mode 100644 index 0000000..b9502c0 --- /dev/null +++ b/LeanKit.API.Client.Library/TokenAuthenticator.cs @@ -0,0 +1,23 @@ +using System; +using System.Linq; +using RestSharp; + +namespace LeanKit.API.Client.Library +{ + public class TokenAuthenticator : IAuthenticator + { + private readonly string _token; + + public TokenAuthenticator(string token) + { + _token = token; + } + + public void Authenticate(IRestClient client, IRestRequest request) + { + if (request.Parameters.Any(p => p.Name.Equals("Authorization", StringComparison.OrdinalIgnoreCase))) return; + var authHeader = string.Format("Token {0}", _token); + request.AddParameter("Authorization", authHeader, ParameterType.HttpHeader); + } + } +} diff --git a/LeanKit.API.Client.Library/TransferObjects/LeanKitAccountAuth.cs b/LeanKit.API.Client.Library/TransferObjects/LeanKitAccountAuth.cs index 8b0c8e0..067bdea 100644 --- a/LeanKit.API.Client.Library/TransferObjects/LeanKitAccountAuth.cs +++ b/LeanKit.API.Client.Library/TransferObjects/LeanKitAccountAuth.cs @@ -28,4 +28,19 @@ public string GetAccountUrl() return string.Format(UrlTemplateOverride, Hostname); } } + + public static class LeanKitAccountAuthExtension + { + public static LeanKitBasicAuth ToBasicAuth(this LeanKitAccountAuth accountAuth) + { + var auth = new LeanKitBasicAuth + { + Username = accountAuth.Username, + Password = accountAuth.Password, + Hostname = accountAuth.Hostname, + UrlTemplateOverride = accountAuth.UrlTemplateOverride + }; + return auth; + } + } } \ No newline at end of file diff --git a/LeanKit.API.Client.Library/packages.config b/LeanKit.API.Client.Library/packages.config index ecd78c2..b0f3649 100644 --- a/LeanKit.API.Client.Library/packages.config +++ b/LeanKit.API.Client.Library/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/Samples/LeanKitCmdQuery/LeanKitQuery.cs b/Samples/LeanKitCmdQuery/LeanKitQuery.cs index f51d1fa..bbf1162 100644 --- a/Samples/LeanKitCmdQuery/LeanKitQuery.cs +++ b/Samples/LeanKitCmdQuery/LeanKitQuery.cs @@ -42,7 +42,7 @@ public void RunQuery() { ValidateQuery(); - var leanKitAuth = new LeanKitAccountAuth + var leanKitAuth = new LeanKitBasicAuth { Hostname = _args.Host, Username = _args.User, diff --git a/Samples/LeanKitNotifier/LeanKitNotifierApplicationContext.cs b/Samples/LeanKitNotifier/LeanKitNotifierApplicationContext.cs index decf646..9918170 100644 --- a/Samples/LeanKitNotifier/LeanKitNotifierApplicationContext.cs +++ b/Samples/LeanKitNotifier/LeanKitNotifierApplicationContext.cs @@ -9,7 +9,6 @@ using System.Windows.Forms; using LeanKit.API.Client.Library; using LeanKit.API.Client.Library.EventArguments; -using LeanKit.API.Client.Library.TransferObjects; namespace LeanKitNotifier { @@ -54,7 +53,7 @@ private void InitializeLeanKitMonitoring() var password = ConfigurationManager.AppSettings["LeanKit-Password"]; var boardIds = ConfigurationManager.AppSettings["LeanKit-BoardId"]; - var leanKitAuth = new LeanKitAccountAuth + var leanKitAuth = new LeanKitBasicAuth { Hostname = host, Username = email, diff --git a/Samples/LeanKitScriptCS/ExportCards.csx b/Samples/LeanKitScriptCS/ExportCards.csx index a948f26..ff434aa 100644 --- a/Samples/LeanKitScriptCS/ExportCards.csx +++ b/Samples/LeanKitScriptCS/ExportCards.csx @@ -17,7 +17,7 @@ var userName = "user@email.com"; // Change to your account email address var password = "p@ssword"; // Change to your account password var boardId = 101; // Change to your board ID, e.g. https://accountname.leankit.com/Boards/View/101 -var leanKitAuth = new LeanKitAccountAuth { +var leanKitAuth = new LeanKitBasicAuth { Hostname = host, Username = userName, Password = password diff --git a/publish/LeanKit.API.Client.Library.dll.nuspec b/publish/LeanKit.API.Client.Library.dll.nuspec index a907e16..d1b5416 100644 --- a/publish/LeanKit.API.Client.Library.dll.nuspec +++ b/publish/LeanKit.API.Client.Library.dll.nuspec @@ -2,7 +2,7 @@ LeanKit.API.Client - 1.0.1 + 1.0.3 LeanKit LeanKit https://raw.githubusercontent.com/LeanKit/LeanKit.API.Client/master/License.txt From f61ece7e1b6496e710fac91ddc91bbc2252170de Mon Sep 17 00:00:00 2001 From: David Neal Date: Fri, 21 Nov 2014 09:25:14 -0500 Subject: [PATCH 05/40] Fixed a few issues in review --- LeanKit.API.Client.Library/ILeanKitIntegrationFactory.cs | 2 -- .../LeanKit.API.Client.Library.csproj | 2 +- LeanKit.API.Client.Library/LeanKitBasicAuth - Copy.cs | 9 --------- LeanKit.API.Client.Library/LeanKitBasicAuth.cs | 8 +++++--- LeanKit.API.Client.Library/LeanKitTokenAuth.cs | 7 +++++++ 5 files changed, 13 insertions(+), 15 deletions(-) delete mode 100644 LeanKit.API.Client.Library/LeanKitBasicAuth - Copy.cs create mode 100644 LeanKit.API.Client.Library/LeanKitTokenAuth.cs diff --git a/LeanKit.API.Client.Library/ILeanKitIntegrationFactory.cs b/LeanKit.API.Client.Library/ILeanKitIntegrationFactory.cs index 1fc5495..5652cde 100644 --- a/LeanKit.API.Client.Library/ILeanKitIntegrationFactory.cs +++ b/LeanKit.API.Client.Library/ILeanKitIntegrationFactory.cs @@ -36,9 +36,7 @@ public interface ILeanKitIntegrationFactory /// The Identity of the Board that will be watched and modified. /// The account authentication information used to connect to the LeanKit API. /// The used to monitor and modify the specified board. - [Obsolete("This is deprecated. Please use ILeanKitAccountAuth instead.")] ILeanKitIntegration Create(long boardId, ILeanKitAccountAuth accountAuth); - [Obsolete("This is deprecated. Please use ILeanKitAccountAuth instead.")] ILeanKitIntegration Create(long boardId, ILeanKitAccountAuth accountAuth, IntegrationSettings settings); } } \ No newline at end of file diff --git a/LeanKit.API.Client.Library/LeanKit.API.Client.Library.csproj b/LeanKit.API.Client.Library/LeanKit.API.Client.Library.csproj index 7ffc959..86a17f4 100644 --- a/LeanKit.API.Client.Library/LeanKit.API.Client.Library.csproj +++ b/LeanKit.API.Client.Library/LeanKit.API.Client.Library.csproj @@ -76,8 +76,8 @@ - + diff --git a/LeanKit.API.Client.Library/LeanKitBasicAuth - Copy.cs b/LeanKit.API.Client.Library/LeanKitBasicAuth - Copy.cs deleted file mode 100644 index 6b9be25..0000000 --- a/LeanKit.API.Client.Library/LeanKitBasicAuth - Copy.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace LeanKit.API.Client.Library -{ - public class LeanKitBasicAuth : LeanKitAccountAuthBase - { - public string Username { get; set; } - - public string Password { get; set; } - } -} diff --git a/LeanKit.API.Client.Library/LeanKitBasicAuth.cs b/LeanKit.API.Client.Library/LeanKitBasicAuth.cs index 645ed0f..6b9be25 100644 --- a/LeanKit.API.Client.Library/LeanKitBasicAuth.cs +++ b/LeanKit.API.Client.Library/LeanKitBasicAuth.cs @@ -1,7 +1,9 @@ namespace LeanKit.API.Client.Library { - public class LeanKitTokenAuth : LeanKitAccountAuthBase + public class LeanKitBasicAuth : LeanKitAccountAuthBase { - public string Token { get; set; } - } + public string Username { get; set; } + + public string Password { get; set; } + } } diff --git a/LeanKit.API.Client.Library/LeanKitTokenAuth.cs b/LeanKit.API.Client.Library/LeanKitTokenAuth.cs new file mode 100644 index 0000000..645ed0f --- /dev/null +++ b/LeanKit.API.Client.Library/LeanKitTokenAuth.cs @@ -0,0 +1,7 @@ +namespace LeanKit.API.Client.Library +{ + public class LeanKitTokenAuth : LeanKitAccountAuthBase + { + public string Token { get; set; } + } +} From dc0038a4fbd4bf2cb2d60a0f4ce1b551721703e7 Mon Sep 17 00:00:00 2001 From: David Neal Date: Fri, 21 Nov 2014 09:32:01 -0500 Subject: [PATCH 06/40] Removing unnecessary backwards compatibility --- .../IRestCommandProcessor.cs | 11 ------- .../RestSharpCommandProcessor.cs | 29 ------------------- 2 files changed, 40 deletions(-) diff --git a/LeanKit.API.Client.Library/IRestCommandProcessor.cs b/LeanKit.API.Client.Library/IRestCommandProcessor.cs index f8758a1..46f743f 100644 --- a/LeanKit.API.Client.Library/IRestCommandProcessor.cs +++ b/LeanKit.API.Client.Library/IRestCommandProcessor.cs @@ -17,17 +17,6 @@ namespace LeanKit.API.Client.Library /// public interface IRestCommandProcessor { - [Obsolete("This is deprecated. Please use ILeanKitAccountAuth instead.")] - T Get(LeanKitAccountAuth accountAuth, string resource) where T : new(); - [Obsolete("This is deprecated. Please use ILeanKitAccountAuth instead.")] - T Get(LeanKitAccountAuth accountAuth, string resource, object body) where T : new(); - [Obsolete("This is deprecated. Please use ILeanKitAccountAuth instead.")] - T Post(LeanKitAccountAuth accountAuth, string resource, object body) where T : new(); - [Obsolete("This is deprecated. Please use ILeanKitAccountAuth instead.")] - T Post(LeanKitAccountAuth accountAuth, string resource) where T : new(); - [Obsolete("This is deprecated. Please use ILeanKitAccountAuth instead.")] - T PostFile(LeanKitAccountAuth accountAuth, string resource, Dictionary parameters, string fileName, string mimeType, byte[] fileBytes) where T : new(); - T Get(ILeanKitAccountAuth accountAuth, string resource) where T : new(); T Get(ILeanKitAccountAuth accountAuth, string resource, object body) where T : new(); T Post(ILeanKitAccountAuth accountAuth, string resource, object body) where T : new(); diff --git a/LeanKit.API.Client.Library/RestSharpCommandProcessor.cs b/LeanKit.API.Client.Library/RestSharpCommandProcessor.cs index 7cf1b8c..e7460a9 100644 --- a/LeanKit.API.Client.Library/RestSharpCommandProcessor.cs +++ b/LeanKit.API.Client.Library/RestSharpCommandProcessor.cs @@ -113,35 +113,6 @@ public RestSharpCommandProcessor(IValidationService validationService, Integrati return retVal; } - [Obsolete("This is deprecated. Please use ILeanKitAccountAuth instead.")] - public T Get(LeanKitAccountAuth accountAuth, string resource) where T : new() - { - return Get(accountAuth.ToBasicAuth(), resource); - } - - [Obsolete("This is deprecated. Please use ILeanKitAccountAuth instead.")] - public T Get(LeanKitAccountAuth accountAuth, string resource, object body) where T : new() - { - return Get(accountAuth.ToBasicAuth(), resource, body); - } - - [Obsolete("This is deprecated. Please use ILeanKitAccountAuth instead.")] - public T Post(LeanKitAccountAuth accountAuth, string resource, object body) where T : new() - { - return Post(accountAuth.ToBasicAuth(), resource, body); - } - - [Obsolete("This is deprecated. Please use ILeanKitAccountAuth instead.")] - public T Post(LeanKitAccountAuth accountAuth, string resource) where T : new() - { - return Post(accountAuth.ToBasicAuth(), resource); - } - - [Obsolete("This is deprecated. Please use ILeanKitAccountAuth instead.")] - public T PostFile(LeanKitAccountAuth accountAuth, string resource, Dictionary parameters, string fileName, string mimeType, byte[] fileBytes) where T : new() - { - return PostFile(accountAuth.ToBasicAuth(), resource, parameters, fileName, mimeType, fileBytes); - } private static byte[] GetMultipartFormData(Dictionary parameters, string boundary, string fileName, string mimeType, byte[] fileBytes) { From 7ecd269d36211f569661cb85a9402f5d34ef5489 Mon Sep 17 00:00:00 2001 From: David Neal Date: Fri, 21 Nov 2014 09:35:04 -0500 Subject: [PATCH 07/40] Updating Readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6164ea2..a3bd0bf 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ This class exposes methods that interact directly with LeanKit API. This class e ### Connecting using LeanKitClient ``` -var leanKitAuth = new LeanKitAccountAuth +var leanKitAuth = new LeanKitBasicAuth { Hostname = "your-leankit-account-name", // e.g. https://accountname.leankit.com Username = "your-account-email-address", @@ -39,7 +39,7 @@ This class is designed to retrieve and hold a reference to the board, and theref ### Connecting using LeanKitIntegration ``` -var leanKitAuth = new LeanKitAccountAuth +var leanKitAuth = new LeanKitBasicAuth { Hostname = "your-leankit-account-name", // e.g. https://accountname.leankit.com Username = "your-account-email-address", From 8931806fe5567caabdaf5a9ad731f20d00b62f3e Mon Sep 17 00:00:00 2001 From: David Neal Date: Fri, 21 Nov 2014 11:32:16 -0500 Subject: [PATCH 08/40] Updating nuget package --- publish/LeanKit.API.Client.Library.dll.nuspec | 6 +++--- publish/readme.md | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 publish/readme.md diff --git a/publish/LeanKit.API.Client.Library.dll.nuspec b/publish/LeanKit.API.Client.Library.dll.nuspec index d1b5416..b98b31d 100644 --- a/publish/LeanKit.API.Client.Library.dll.nuspec +++ b/publish/LeanKit.API.Client.Library.dll.nuspec @@ -2,7 +2,7 @@ LeanKit.API.Client - 1.0.3 + 1.0.5 LeanKit LeanKit https://raw.githubusercontent.com/LeanKit/LeanKit.API.Client/master/License.txt @@ -14,8 +14,8 @@ Copyright 2014 LeanKit - - + + \ No newline at end of file diff --git a/publish/readme.md b/publish/readme.md new file mode 100644 index 0000000..93e2917 --- /dev/null +++ b/publish/readme.md @@ -0,0 +1,7 @@ +## Publishing to Nuget + +[Creating and Publishing a Nuget Package](http://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-package) + +`nuget pack .\LeanKit.API.Client.Library.dll.nuspec` + +`nuget push .\LeanKit.API.Client.1.0.3.nupkg` \ No newline at end of file From f945e928c40bc12e800088aee28b7cda01b75405 Mon Sep 17 00:00:00 2001 From: David Neal Date: Mon, 1 Dec 2014 22:08:13 -0500 Subject: [PATCH 09/40] Updating README to clarify Hostname property --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a3bd0bf..5f219bf 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ This class exposes methods that interact directly with LeanKit API. This class e ``` var leanKitAuth = new LeanKitBasicAuth { - Hostname = "your-leankit-account-name", // e.g. https://accountname.leankit.com + Hostname = "your-leankit-account-name", // Only the hostname part of the URL, e.g. https://ACCOUNTNAME.leankit.com Username = "your-account-email-address", Password = "your-account-password" }; @@ -41,7 +41,7 @@ This class is designed to retrieve and hold a reference to the board, and theref ``` var leanKitAuth = new LeanKitBasicAuth { - Hostname = "your-leankit-account-name", // e.g. https://accountname.leankit.com + Hostname = "your-leankit-account-name", // Only the hostname part of the URL, e.g. https://ACCOUNTNAME.leankit.com Username = "your-account-email-address", Password = "your-account-password" }; From c2d0efe29310be05611e7fc5559789966db87fb1 Mon Sep 17 00:00:00 2001 From: David Neal Date: Mon, 1 Dec 2014 22:10:27 -0500 Subject: [PATCH 10/40] Updating README to clarify the Hostname property --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5f219bf..a46f530 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,8 @@ This class exposes methods that interact directly with LeanKit API. This class e ``` var leanKitAuth = new LeanKitBasicAuth { - Hostname = "your-leankit-account-name", // Only the hostname part of the URL, e.g. https://ACCOUNTNAME.leankit.com + Hostname = "your-leankit-account-name", // Only the hostname part of the URL + // e.g. https://ACCOUNTNAME.leankit.com Username = "your-account-email-address", Password = "your-account-password" }; @@ -41,7 +42,8 @@ This class is designed to retrieve and hold a reference to the board, and theref ``` var leanKitAuth = new LeanKitBasicAuth { - Hostname = "your-leankit-account-name", // Only the hostname part of the URL, e.g. https://ACCOUNTNAME.leankit.com + Hostname = "your-leankit-account-name", // Only the hostname part of the URL + // e.g. https://ACCOUNTNAME.leankit.com Username = "your-account-email-address", Password = "your-account-password" }; From f1da7f7706975dd023fc10e0949fc9faa75270cf Mon Sep 17 00:00:00 2001 From: David Neal Date: Mon, 1 Dec 2014 22:11:49 -0500 Subject: [PATCH 11/40] Updating README --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a46f530..dc6572d 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,9 @@ This class exposes methods that interact directly with LeanKit API. This class e ``` var leanKitAuth = new LeanKitBasicAuth { - Hostname = "your-leankit-account-name", // Only the hostname part of the URL - // e.g. https://ACCOUNTNAME.leankit.com + Hostname = "your-leankit-account-name", + // Only the hostname part of the URL + // e.g. https://ACCOUNTNAME.leankit.com Username = "your-account-email-address", Password = "your-account-password" }; @@ -42,8 +43,9 @@ This class is designed to retrieve and hold a reference to the board, and theref ``` var leanKitAuth = new LeanKitBasicAuth { - Hostname = "your-leankit-account-name", // Only the hostname part of the URL - // e.g. https://ACCOUNTNAME.leankit.com + Hostname = "your-leankit-account-name", + // Only the hostname part of the URL + // e.g. https://ACCOUNTNAME.leankit.com Username = "your-account-email-address", Password = "your-account-password" }; From 5e2369a663c154bc1b8590e16f9ad5ffefa31ae0 Mon Sep 17 00:00:00 2001 From: David Neal Date: Mon, 1 Dec 2014 22:14:35 -0500 Subject: [PATCH 12/40] Updating README --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index dc6572d..60b72bf 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,8 @@ This class exposes methods that interact directly with LeanKit API. This class e ``` var leanKitAuth = new LeanKitBasicAuth { - Hostname = "your-leankit-account-name", - // Only the hostname part of the URL + Hostname = "MyAccount", + // Only the account name portion of the URL // e.g. https://ACCOUNTNAME.leankit.com Username = "your-account-email-address", Password = "your-account-password" @@ -43,8 +43,8 @@ This class is designed to retrieve and hold a reference to the board, and theref ``` var leanKitAuth = new LeanKitBasicAuth { - Hostname = "your-leankit-account-name", - // Only the hostname part of the URL + Hostname = "MyAccount", + // Only the account name portion of the URL // e.g. https://ACCOUNTNAME.leankit.com Username = "your-account-email-address", Password = "your-account-password" From 1743bbadb43eed62c1e3d86150fcb49908633d1a Mon Sep 17 00:00:00 2001 From: David Neal Date: Mon, 1 Dec 2014 22:44:26 -0500 Subject: [PATCH 13/40] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 60b72bf..e2c5547 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ var leanKitAuth = new LeanKitBasicAuth { Hostname = "MyAccount", // Only the account name portion of the URL - // e.g. https://ACCOUNTNAME.leankit.com + // e.g. https://MyAccount.leankit.com Username = "your-account-email-address", Password = "your-account-password" }; @@ -45,7 +45,7 @@ var leanKitAuth = new LeanKitBasicAuth { Hostname = "MyAccount", // Only the account name portion of the URL - // e.g. https://ACCOUNTNAME.leankit.com + // e.g. https://MyAccount.leankit.com Username = "your-account-email-address", Password = "your-account-password" }; From 65605bd225bf0020f03c29a5064e25ff6c285a52 Mon Sep 17 00:00:00 2001 From: David Neal Date: Wed, 3 Dec 2014 13:59:58 -0500 Subject: [PATCH 14/40] Adding ExternalCardIdPrefix --- LeanKit.API.Client.Library/TransferObjects/Card.cs | 2 ++ LeanKit.API.Client.Library/TransferObjects/CardView.cs | 2 ++ publish/LeanKit.API.Client.Library.dll.nuspec | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/LeanKit.API.Client.Library/TransferObjects/Card.cs b/LeanKit.API.Client.Library/TransferObjects/Card.cs index 1911615..7c3657a 100644 --- a/LeanKit.API.Client.Library/TransferObjects/Card.cs +++ b/LeanKit.API.Client.Library/TransferObjects/Card.cs @@ -61,6 +61,7 @@ public class Card [StringLength(50, ErrorMessage = "Card ID may have 50 symbols only")] public virtual string ExternalCardID { get; set; } + public virtual string ExternalCardIdPrefix { get; set; } [DomainIdentityValidation] public virtual long[] AssignedUserIds { get; set; } @@ -89,6 +90,7 @@ public CardView ToCardView() cardView.DueDate = DueDate; cardView.ExternalCardID = ExternalCardID; cardView.ExternalSystemName = ExternalSystemName; + cardView.ExternalCardIdPrefix = ExternalCardIdPrefix; cardView.Index = Index; cardView.IsBlocked = IsBlocked; cardView.LaneId = LaneId; diff --git a/LeanKit.API.Client.Library/TransferObjects/CardView.cs b/LeanKit.API.Client.Library/TransferObjects/CardView.cs index cc8e3db..6d26dca 100644 --- a/LeanKit.API.Client.Library/TransferObjects/CardView.cs +++ b/LeanKit.API.Client.Library/TransferObjects/CardView.cs @@ -68,6 +68,7 @@ public virtual string PriorityText public int? ParentCardId { get; set; } public int? ParentBoardId { get; set; } + public string ExternalCardIdPrefix { get; set; } public Card ToCard() { @@ -81,6 +82,7 @@ public Card ToCard() card.ExternalCardID = ExternalCardID; card.ExternalSystemName = ExternalSystemName; card.ExternalSystemUrl = ExternalSystemUrl; + card.ExternalCardIdPrefix = ExternalCardIdPrefix; card.Id = Id; card.Index = Index; card.IsBlocked = IsBlocked; diff --git a/publish/LeanKit.API.Client.Library.dll.nuspec b/publish/LeanKit.API.Client.Library.dll.nuspec index b98b31d..da2fe73 100644 --- a/publish/LeanKit.API.Client.Library.dll.nuspec +++ b/publish/LeanKit.API.Client.Library.dll.nuspec @@ -2,7 +2,7 @@ LeanKit.API.Client - 1.0.5 + 1.0.6 LeanKit LeanKit https://raw.githubusercontent.com/LeanKit/LeanKit.API.Client/master/License.txt @@ -18,4 +18,4 @@ - \ No newline at end of file + From 85d6423a6e674d612aa626e707c21e60ef7e5ccd Mon Sep 17 00:00:00 2001 From: David Neal Date: Wed, 3 Dec 2014 16:14:05 -0500 Subject: [PATCH 15/40] Adding option to download a card attachment --- LeanKit.API.Client.Library/ILeanKitApi.cs | 1 + .../IRestCommandProcessor.cs | 1 + LeanKit.API.Client.Library/LeanKitClient.cs | 6 ++++++ .../RestSharpCommandProcessor.cs | 21 ++++++++++++++++++- publish/LeanKit.API.Client.Library.dll.nuspec | 2 +- 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/LeanKit.API.Client.Library/ILeanKitApi.cs b/LeanKit.API.Client.Library/ILeanKitApi.cs index 40b55de..72db72e 100644 --- a/LeanKit.API.Client.Library/ILeanKitApi.cs +++ b/LeanKit.API.Client.Library/ILeanKitApi.cs @@ -64,6 +64,7 @@ public interface ILeanKitApi long DeleteAttachment(long boardId, long cardId, long attachmentId); Asset GetAttachment(long boardId, long cardId, long attachmentId); IEnumerable GetAttachments(long boardId, long cardId); + byte[] DownloadAttachment(long boardId, long attachmentId); #region Obsolete diff --git a/LeanKit.API.Client.Library/IRestCommandProcessor.cs b/LeanKit.API.Client.Library/IRestCommandProcessor.cs index 46f743f..508ab1f 100644 --- a/LeanKit.API.Client.Library/IRestCommandProcessor.cs +++ b/LeanKit.API.Client.Library/IRestCommandProcessor.cs @@ -22,5 +22,6 @@ public interface IRestCommandProcessor T Post(ILeanKitAccountAuth accountAuth, string resource, object body) where T : new(); T Post(ILeanKitAccountAuth accountAuth, string resource) where T : new(); T PostFile(ILeanKitAccountAuth accountAuth, string resource, Dictionary parameters, string fileName, string mimeType, byte[] fileBytes) where T : new(); + byte[] Download(ILeanKitAccountAuth accountAuth, string resource); } } \ No newline at end of file diff --git a/LeanKit.API.Client.Library/LeanKitClient.cs b/LeanKit.API.Client.Library/LeanKitClient.cs index be4f50a..096ddc8 100644 --- a/LeanKit.API.Client.Library/LeanKitClient.cs +++ b/LeanKit.API.Client.Library/LeanKitClient.cs @@ -508,6 +508,12 @@ public IEnumerable GetAttachments(long boardId, long cardId) return _restCommandProcessor.Get>(_accountAuth, resource); } + public byte[] DownloadAttachment(long boardId, long attachmentId) + { + var resource = string.Format("/Kanban/Api/Card/DownloadAttachment/{0}/{1}", boardId, attachmentId); + return _restCommandProcessor.Download(_accountAuth, resource); + } + #endregion #region User Methods diff --git a/LeanKit.API.Client.Library/RestSharpCommandProcessor.cs b/LeanKit.API.Client.Library/RestSharpCommandProcessor.cs index e7460a9..b1572bf 100644 --- a/LeanKit.API.Client.Library/RestSharpCommandProcessor.cs +++ b/LeanKit.API.Client.Library/RestSharpCommandProcessor.cs @@ -113,7 +113,26 @@ public RestSharpCommandProcessor(IValidationService validationService, Integrati return retVal; } - + public byte[] Download(ILeanKitAccountAuth accountAuth, string resource) + { + var request = new RestRequest(Method.GET) { Resource = resource, RequestFormat = DataFormat.Json }; + var errorMessages = _validationService.ValidateRequest(request); + if (errorMessages.Count > 0) + { + var ex = new ValidationException("Provided request parameters are invalid."); + ex.Data["ErrorMessages"] = errorMessages; + throw ex; + } + var client = new RestClient + { + BaseUrl = new Uri(accountAuth.GetAccountUrl()), + Authenticator = GetAuthenticator(accountAuth) + }; + + return client.DownloadData(request); + } + + private static byte[] GetMultipartFormData(Dictionary parameters, string boundary, string fileName, string mimeType, byte[] fileBytes) { var encoding = Encoding.UTF8; diff --git a/publish/LeanKit.API.Client.Library.dll.nuspec b/publish/LeanKit.API.Client.Library.dll.nuspec index da2fe73..421c18b 100644 --- a/publish/LeanKit.API.Client.Library.dll.nuspec +++ b/publish/LeanKit.API.Client.Library.dll.nuspec @@ -2,7 +2,7 @@ LeanKit.API.Client - 1.0.6 + 1.0.7 LeanKit LeanKit https://raw.githubusercontent.com/LeanKit/LeanKit.API.Client/master/License.txt From 272175292a3d9922183aa45ee0231f0f88ef37ab Mon Sep 17 00:00:00 2001 From: David Neal Date: Wed, 3 Dec 2014 17:03:10 -0500 Subject: [PATCH 16/40] Updating download to return more info --- .../ILeanKitAccountAuth.cs | 9 ++-- LeanKit.API.Client.Library/ILeanKitApi.cs | 3 +- .../IRestCommandProcessor.cs | 4 +- .../LeanKit.API.Client.Library.csproj | 1 + .../LeanKitAccountAuthBase.cs | 10 +++-- .../LeanKitBasicAuth.cs | 8 +++- LeanKit.API.Client.Library/LeanKitClient.cs | 2 +- .../LeanKitTokenAuth.cs | 8 +++- .../RestSharpCommandProcessor.cs | 42 ++++++++++++------- .../TokenAuthenticator.cs | 8 +++- .../TransferObjects/AssetFile.cs | 15 +++++++ .../TransferObjects/PaginationResult.cs | 8 +++- publish/LeanKit.API.Client.Library.dll.nuspec | 2 +- 13 files changed, 87 insertions(+), 33 deletions(-) create mode 100644 LeanKit.API.Client.Library/TransferObjects/AssetFile.cs diff --git a/LeanKit.API.Client.Library/ILeanKitAccountAuth.cs b/LeanKit.API.Client.Library/ILeanKitAccountAuth.cs index bfedb77..95ef95d 100644 --- a/LeanKit.API.Client.Library/ILeanKitAccountAuth.cs +++ b/LeanKit.API.Client.Library/ILeanKitAccountAuth.cs @@ -1,7 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +//------------------------------------------------------------------------------ +// +// Copyright (c) LeanKit Inc. All rights reserved. +// +//------------------------------------------------------------------------------ namespace LeanKit.API.Client.Library { diff --git a/LeanKit.API.Client.Library/ILeanKitApi.cs b/LeanKit.API.Client.Library/ILeanKitApi.cs index 72db72e..7d6751a 100644 --- a/LeanKit.API.Client.Library/ILeanKitApi.cs +++ b/LeanKit.API.Client.Library/ILeanKitApi.cs @@ -6,7 +6,6 @@ using System; using System.Collections.Generic; -using System.IO; using LeanKit.API.Client.Library.TransferObjects; namespace LeanKit.API.Client.Library @@ -64,7 +63,7 @@ public interface ILeanKitApi long DeleteAttachment(long boardId, long cardId, long attachmentId); Asset GetAttachment(long boardId, long cardId, long attachmentId); IEnumerable GetAttachments(long boardId, long cardId); - byte[] DownloadAttachment(long boardId, long attachmentId); + AssetFile DownloadAttachment(long boardId, long attachmentId); #region Obsolete diff --git a/LeanKit.API.Client.Library/IRestCommandProcessor.cs b/LeanKit.API.Client.Library/IRestCommandProcessor.cs index 508ab1f..e407c0b 100644 --- a/LeanKit.API.Client.Library/IRestCommandProcessor.cs +++ b/LeanKit.API.Client.Library/IRestCommandProcessor.cs @@ -4,10 +4,8 @@ // //------------------------------------------------------------------------------ -using System; using System.Collections.Generic; using LeanKit.API.Client.Library.TransferObjects; -using RestSharp; namespace LeanKit.API.Client.Library { @@ -22,6 +20,6 @@ public interface IRestCommandProcessor T Post(ILeanKitAccountAuth accountAuth, string resource, object body) where T : new(); T Post(ILeanKitAccountAuth accountAuth, string resource) where T : new(); T PostFile(ILeanKitAccountAuth accountAuth, string resource, Dictionary parameters, string fileName, string mimeType, byte[] fileBytes) where T : new(); - byte[] Download(ILeanKitAccountAuth accountAuth, string resource); + AssetFile Download(ILeanKitAccountAuth accountAuth, string resource); } } \ No newline at end of file diff --git a/LeanKit.API.Client.Library/LeanKit.API.Client.Library.csproj b/LeanKit.API.Client.Library/LeanKit.API.Client.Library.csproj index 86a17f4..e7f94f4 100644 --- a/LeanKit.API.Client.Library/LeanKit.API.Client.Library.csproj +++ b/LeanKit.API.Client.Library/LeanKit.API.Client.Library.csproj @@ -89,6 +89,7 @@ + diff --git a/LeanKit.API.Client.Library/LeanKitAccountAuthBase.cs b/LeanKit.API.Client.Library/LeanKitAccountAuthBase.cs index 6656af1..63b65dc 100644 --- a/LeanKit.API.Client.Library/LeanKitAccountAuthBase.cs +++ b/LeanKit.API.Client.Library/LeanKitAccountAuthBase.cs @@ -1,8 +1,10 @@ -using System; -using System.Collections.Generic; +//------------------------------------------------------------------------------ +// +// Copyright (c) LeanKit Inc. All rights reserved. +// +//------------------------------------------------------------------------------ + using System.Configuration; -using System.Linq; -using System.Text; namespace LeanKit.API.Client.Library { diff --git a/LeanKit.API.Client.Library/LeanKitBasicAuth.cs b/LeanKit.API.Client.Library/LeanKitBasicAuth.cs index 6b9be25..0864b51 100644 --- a/LeanKit.API.Client.Library/LeanKitBasicAuth.cs +++ b/LeanKit.API.Client.Library/LeanKitBasicAuth.cs @@ -1,4 +1,10 @@ -namespace LeanKit.API.Client.Library +//------------------------------------------------------------------------------ +// +// Copyright (c) LeanKit Inc. All rights reserved. +// +//------------------------------------------------------------------------------ + +namespace LeanKit.API.Client.Library { public class LeanKitBasicAuth : LeanKitAccountAuthBase { diff --git a/LeanKit.API.Client.Library/LeanKitClient.cs b/LeanKit.API.Client.Library/LeanKitClient.cs index 096ddc8..fe3858e 100644 --- a/LeanKit.API.Client.Library/LeanKitClient.cs +++ b/LeanKit.API.Client.Library/LeanKitClient.cs @@ -508,7 +508,7 @@ public IEnumerable GetAttachments(long boardId, long cardId) return _restCommandProcessor.Get>(_accountAuth, resource); } - public byte[] DownloadAttachment(long boardId, long attachmentId) + public AssetFile DownloadAttachment(long boardId, long attachmentId) { var resource = string.Format("/Kanban/Api/Card/DownloadAttachment/{0}/{1}", boardId, attachmentId); return _restCommandProcessor.Download(_accountAuth, resource); diff --git a/LeanKit.API.Client.Library/LeanKitTokenAuth.cs b/LeanKit.API.Client.Library/LeanKitTokenAuth.cs index 645ed0f..282e72d 100644 --- a/LeanKit.API.Client.Library/LeanKitTokenAuth.cs +++ b/LeanKit.API.Client.Library/LeanKitTokenAuth.cs @@ -1,4 +1,10 @@ -namespace LeanKit.API.Client.Library +//------------------------------------------------------------------------------ +// +// Copyright (c) LeanKit Inc. All rights reserved. +// +//------------------------------------------------------------------------------ + +namespace LeanKit.API.Client.Library { public class LeanKitTokenAuth : LeanKitAccountAuthBase { diff --git a/LeanKit.API.Client.Library/RestSharpCommandProcessor.cs b/LeanKit.API.Client.Library/RestSharpCommandProcessor.cs index b1572bf..f09a75b 100644 --- a/LeanKit.API.Client.Library/RestSharpCommandProcessor.cs +++ b/LeanKit.API.Client.Library/RestSharpCommandProcessor.cs @@ -24,6 +24,7 @@ namespace LeanKit.API.Client.Library { public class RestSharpCommandProcessor : IRestCommandProcessor { + private const string LeanKitUserAgent = "LeanKit.API.Client/1.0.8"; private readonly IntegrationSettings _settings; private readonly IValidationService _validationService; @@ -77,6 +78,7 @@ public RestSharpCommandProcessor(IValidationService validationService, Integrati request.Method = "POST"; request.ContentType = contentType; request.ContentLength = formBytes.Length; + request.UserAgent = LeanKitUserAgent; AddAuth(request, accountAuth); using (var requestStream = request.GetRequestStream()) @@ -113,26 +115,37 @@ public RestSharpCommandProcessor(IValidationService validationService, Integrati return retVal; } - public byte[] Download(ILeanKitAccountAuth accountAuth, string resource) + public AssetFile Download(ILeanKitAccountAuth accountAuth, string resource) { - var request = new RestRequest(Method.GET) { Resource = resource, RequestFormat = DataFormat.Json }; - var errorMessages = _validationService.ValidateRequest(request); - if (errorMessages.Count > 0) + var request = WebRequest.Create(accountAuth.GetAccountUrl() + resource) as HttpWebRequest; + + if (request == null) throw new Exception("Error downloading file. Could not create HttpWebRequest"); + request.UserAgent = LeanKitUserAgent; + AddAuth(request, accountAuth); + + var response = request.GetResponse() as HttpWebResponse; + byte[] fileBytes; + using (var responseStream = response.GetResponseStream()) { - var ex = new ValidationException("Provided request parameters are invalid."); - ex.Data["ErrorMessages"] = errorMessages; - throw ex; + var buffer = new byte[4096]; + using (var ms = new MemoryStream()) + { + int read; + while ((read = responseStream.Read(buffer, 0, buffer.Length)) > 0) + { + ms.Write(buffer, 0, read); + } + fileBytes = ms.ToArray(); + } } - var client = new RestClient + return new AssetFile { - BaseUrl = new Uri(accountAuth.GetAccountUrl()), - Authenticator = GetAuthenticator(accountAuth) + FileBytes = fileBytes, + ContentType = response.ContentType, + ContentLength = response.ContentLength }; - - return client.DownloadData(request); } - private static byte[] GetMultipartFormData(Dictionary parameters, string boundary, string fileName, string mimeType, byte[] fileBytes) { var encoding = Encoding.UTF8; @@ -181,7 +194,8 @@ private static byte[] GetMultipartFormData(Dictionary parameters var client = new RestClient { BaseUrl = new Uri(accountAuth.GetAccountUrl()), - Authenticator = GetAuthenticator(accountAuth) + Authenticator = GetAuthenticator(accountAuth), + UserAgent = LeanKitUserAgent }; var response = RetryRequest(request, accountAuth, client); diff --git a/LeanKit.API.Client.Library/TokenAuthenticator.cs b/LeanKit.API.Client.Library/TokenAuthenticator.cs index b9502c0..0e21004 100644 --- a/LeanKit.API.Client.Library/TokenAuthenticator.cs +++ b/LeanKit.API.Client.Library/TokenAuthenticator.cs @@ -1,4 +1,10 @@ -using System; +//------------------------------------------------------------------------------ +// +// Copyright (c) LeanKit Inc. All rights reserved. +// +//------------------------------------------------------------------------------ + +using System; using System.Linq; using RestSharp; diff --git a/LeanKit.API.Client.Library/TransferObjects/AssetFile.cs b/LeanKit.API.Client.Library/TransferObjects/AssetFile.cs new file mode 100644 index 0000000..07fc2f9 --- /dev/null +++ b/LeanKit.API.Client.Library/TransferObjects/AssetFile.cs @@ -0,0 +1,15 @@ +//------------------------------------------------------------------------------ +// +// Copyright (c) LeanKit Inc. All rights reserved. +// +//------------------------------------------------------------------------------ + +namespace LeanKit.API.Client.Library.TransferObjects +{ + public class AssetFile + { + public byte[] FileBytes { get; set; } + public string ContentType { get; set; } + public long ContentLength { get; set; } + } +} \ No newline at end of file diff --git a/LeanKit.API.Client.Library/TransferObjects/PaginationResult.cs b/LeanKit.API.Client.Library/TransferObjects/PaginationResult.cs index 9dd8ede..a44775b 100644 --- a/LeanKit.API.Client.Library/TransferObjects/PaginationResult.cs +++ b/LeanKit.API.Client.Library/TransferObjects/PaginationResult.cs @@ -1,4 +1,10 @@ -using System.Collections.Generic; +//------------------------------------------------------------------------------ +// +// Copyright (c) LeanKit Inc. All rights reserved. +// +//------------------------------------------------------------------------------ + +using System.Collections.Generic; namespace LeanKit.API.Client.Library.TransferObjects { diff --git a/publish/LeanKit.API.Client.Library.dll.nuspec b/publish/LeanKit.API.Client.Library.dll.nuspec index 421c18b..2812034 100644 --- a/publish/LeanKit.API.Client.Library.dll.nuspec +++ b/publish/LeanKit.API.Client.Library.dll.nuspec @@ -2,7 +2,7 @@ LeanKit.API.Client - 1.0.7 + 1.0.8 LeanKit LeanKit https://raw.githubusercontent.com/LeanKit/LeanKit.API.Client/master/License.txt From 11d90284511de0e5a1acfaa5eda5ecf9c87d35d4 Mon Sep 17 00:00:00 2001 From: David Neal Date: Fri, 8 May 2015 13:52:49 -0600 Subject: [PATCH 17/40] Adding latest card properties --- .../Properties/AssemblyInfo.cs | 6 +- .../TransferObjects/Card.cs | 159 ++++++++++++------ .../TransferObjects/CardContext.cs | 10 +- .../TransferObjects/CardView.cs | 147 ++++++++++------ .../LeanKitNotifierApplicationContext.cs | 3 +- publish/LeanKit.API.Client.Library.dll.nuspec | 2 +- publish/readme.md | 4 +- 7 files changed, 226 insertions(+), 105 deletions(-) diff --git a/LeanKit.API.Client.Library/Properties/AssemblyInfo.cs b/LeanKit.API.Client.Library/Properties/AssemblyInfo.cs index 5934694..d82a5d5 100644 --- a/LeanKit.API.Client.Library/Properties/AssemblyInfo.cs +++ b/LeanKit.API.Client.Library/Properties/AssemblyInfo.cs @@ -16,7 +16,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("LeanKit Inc.")] [assembly: AssemblyProduct("LeanKit.API.Client.Library")] -[assembly: AssemblyCopyright("Copyright © LeanKit Inc. 2011")] +[assembly: AssemblyCopyright("Copyright © LeanKit Inc. 2011-2015")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -41,5 +41,5 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file +[assembly: AssemblyVersion("1.1.1.0")] +[assembly: AssemblyFileVersion("1.1.1.0")] \ No newline at end of file diff --git a/LeanKit.API.Client.Library/TransferObjects/Card.cs b/LeanKit.API.Client.Library/TransferObjects/Card.cs index 7c3657a..095b6ea 100644 --- a/LeanKit.API.Client.Library/TransferObjects/Card.cs +++ b/LeanKit.API.Client.Library/TransferObjects/Card.cs @@ -20,63 +20,92 @@ public enum PriorityType public class Card { - public virtual long Id { get; set; } + public long Id { get; set; } [DomainIdentityValidation] - public virtual long LaneId { get; set; } + public long LaneId { get; set; } [Required(ErrorMessage = "Title may not be empty")] [StringLength(255, ErrorMessage = "Title may have 255 symbols only")] - public virtual string Title { get; set; } + public string Title { get; set; } [StringLength(20000, ErrorMessage = "Description may not exceed 20000 characters")] - public virtual string Description { get; set; } + public string Description { get; set; } - public virtual string CreatedOn { get; set; } - public virtual string TypeName { get; set; } + public string CreatedOn { get; set; } + public string TypeName { get; set; } [DomainIdentityValidation] - public virtual long TypeId { get; set; } - - public virtual int Priority { get; set; } - public virtual int Size { get; set; } - public virtual bool Active { get; set; } - public virtual string Color { get; set; } - public virtual long Version { get; set; } - public virtual bool IsBlocked { get; set; } - public virtual string BlockReason { get; set; } - public virtual int Index { get; set; } - public virtual string StartDate { get; set; } - public virtual string DueDate { get; set; } - public virtual string UserWipOverrideComment { get; set; } - public virtual string ExternalSystemName { get; set; } + public long TypeId { get; set; } + + public int Priority { get; set; } + public int Size { get; set; } + public bool Active { get; set; } + public string Color { get; set; } + public long Version { get; set; } + public bool IsBlocked { get; set; } + public string BlockReason { get; set; } + public int Index { get; set; } + public string StartDate { get; set; } + public string DueDate { get; set; } + public string UserWipOverrideComment { get; set; } + public string ExternalSystemName { get; set; } [StringLength(2000, ErrorMessage = "External System Url may have 2000 symbols only")] - public virtual string ExternalSystemUrl { get; set; } + public string ExternalSystemUrl { get; set; } - public virtual string Tags { get; set; } + public string Tags { get; set; } [DomainIdentityValidation] - public virtual long? ClassOfServiceId { get; set; } + public long? ClassOfServiceId { get; set; } [StringLength(50, ErrorMessage = "Card ID may have 50 symbols only")] - public virtual string ExternalCardID { get; set; } - public virtual string ExternalCardIdPrefix { get; set; } + public string ExternalCardID { get; set; } + public string ExternalCardIdPrefix { get; set; } [DomainIdentityValidation] - public virtual long[] AssignedUserIds { get; set; } + public long[] AssignedUserIds { get; set; } - public virtual string LastMove { get; set; } - public virtual string LastActivity { get; set; } - public virtual string DateArchived { get; set; } - public virtual string LastComment { get; set; } - public virtual int CommentsCount { get; set; } + public string LastMove { get; set; } + public string LastActivity { get; set; } + public string DateArchived { get; set; } + public string LastComment { get; set; } + public int CommentsCount { get; set; } public List Comments { get; set; } public List HistoryEvents { get; set; } public List CardContexts { get; set; } - public virtual int? ParentCardId { get; set; } - public virtual int? ParentBoardId { get; set; } + public int? ParentCardId { get; set; } + public int? ParentBoardId { get; set; } + public string ActualFinishDate { get; set; } + public string ActualStartDate { get; set; } + public string AssignedUserName { get; set; } + public string BlockStateChangeDate { get; set; } + public long BoardId { get; set; } + public string BoardTitle { get; set; } + public string CardTypeIconColor { get; set; } + public string CardTypeIconName { get; set; } + public string ClassOfServiceCustomIconColor { get; set; } + public string ClassOfServiceCustomIconName { get; set; } + public string CreateDate { get; set; } + public string CurrentContext { get; set; } + public long? CurrentTaskBoardId { get; set; } + public int? DrillThroughCompletionPercent { get; set; } + public int? DrillThroughProgressTotal { get; set; } + public int? DrillThroughProgressComplete { get; set; } + public int? DrillThroughProgressSizeComplete { get; set; } + public int? DrillThroughProgressSizeTotal { get; set; } + public string GravatarLink { get; set; } + public string Icon { get; set; } + public bool IsOlderThanXDays { get; set; } + public string LaneTitle { get; set; } + public long? ParentTaskboardId { get; set; } + public string SmallGravatarLink { get; set; } + public int? TaskBoardCompletionPercent { get; set; } + public int TaskBoardCompletedCardCount { get; set; } + public int TaskBoardCompletedCardSize { get; set; } + public int? TaskBoardTotalCards { get; set; } + public int? TaskBoardTotalSize { get; set; } public CardView ToCardView() { @@ -109,6 +138,36 @@ public CardView ToCardView() cardView.DateArchived = DateArchived; cardView.ParentBoardId = ParentBoardId; cardView.ParentCardId = ParentCardId; + cardView.ActualFinishDate = ActualFinishDate; + cardView.ActualStartDate = ActualStartDate; + cardView.AssignedUserName = AssignedUserName; + cardView.BlockStateChangeDate = BlockStateChangeDate; + cardView.BoardId = BoardId; + cardView.BoardTitle = BoardTitle; + cardView.CardContexts = CardContexts; + cardView.CardTypeIconColor = CardTypeIconColor; + cardView.CardTypeIconName = CardTypeIconName; + cardView.ClassOfServiceCustomIconColor = ClassOfServiceCustomIconColor; + cardView.ClassOfServiceCustomIconName = ClassOfServiceCustomIconName; + cardView.CreateDate = CreateDate; + cardView.CurrentContext = CurrentContext; + cardView.CurrentTaskBoardId = CurrentTaskBoardId; + cardView.DrillThroughCompletionPercent = DrillThroughCompletionPercent; + cardView.DrillThroughProgressTotal = DrillThroughProgressTotal; + cardView.DrillThroughProgressComplete = DrillThroughProgressComplete; + cardView.DrillThroughProgressSizeComplete = DrillThroughProgressSizeComplete; + cardView.DrillThroughProgressSizeTotal = DrillThroughProgressSizeTotal; + cardView.GravatarLink = GravatarLink; + cardView.Icon = Icon; + cardView.IsOlderThanXDays = IsOlderThanXDays; + cardView.LaneTitle = LaneTitle; + cardView.ParentTaskboardId = ParentTaskboardId; + cardView.SmallGravatarLink = SmallGravatarLink; + cardView.TaskBoardCompletionPercent = TaskBoardCompletionPercent; + cardView.TaskBoardCompletedCardCount = TaskBoardCompletedCardCount; + cardView.TaskBoardCompletedCardSize = TaskBoardCompletedCardSize; + cardView.TaskBoardTotalCards = TaskBoardTotalCards; + cardView.TaskBoardTotalSize = TaskBoardTotalSize; return cardView; } @@ -116,47 +175,47 @@ public CardView ToCardView() public class CardUpdateResult { - public virtual int BoardVersion { get; set; } - public virtual CardView CardDTO { get; set; } + public int BoardVersion { get; set; } + public CardView CardDTO { get; set; } } public class CardAddResult { - public virtual int BoardVersion { get; set; } - public virtual Lane Lane { get; set; } - public virtual long CardId { get; set; } + public int BoardVersion { get; set; } + public Lane Lane { get; set; } + public long CardId { get; set; } } public class CardMoveResult { - public virtual long BoardVersion { get; set; } + public long BoardVersion { get; set; } } public class CardMoveBetweenBoardsResult { - public virtual long BoardVersion { get; set; } - public virtual string DestinationLaneName { get; set; } - public virtual long DestinationLaneId { get; set; } - public virtual long SourceBoardId { get; set; } - public virtual long DestinationBoardId { get; set; } + public long BoardVersion { get; set; } + public string DestinationLaneName { get; set; } + public long DestinationLaneId { get; set; } + public long SourceBoardId { get; set; } + public long DestinationBoardId { get; set; } } public class CardsUpdateResult { - public virtual int UpdatedCardsCount { get; set; } + public int UpdatedCardsCount { get; set; } } public class CardsDeleteResult { - public virtual long BoardVersion { get; set; } + public long BoardVersion { get; set; } } public class CardDelegationResult { - public virtual long ParentBoardId { get; set; } - public virtual long DelegationCardId { get; set; } - public virtual long DestinationLaneId { get; set; } - public virtual string DestinationLaneName { get; set; } + public long ParentBoardId { get; set; } + public long DelegationCardId { get; set; } + public long DestinationLaneId { get; set; } + public string DestinationLaneName { get; set; } } } \ No newline at end of file diff --git a/LeanKit.API.Client.Library/TransferObjects/CardContext.cs b/LeanKit.API.Client.Library/TransferObjects/CardContext.cs index 5367930..4141dfd 100644 --- a/LeanKit.API.Client.Library/TransferObjects/CardContext.cs +++ b/LeanKit.API.Client.Library/TransferObjects/CardContext.cs @@ -15,10 +15,18 @@ public class CardContext public class CardContextView { - public long TaskBoardId { get; set; } public long Id { get; set; } + public long TaskBoardId { get; set; } public string Name { get; set; } + public int TaskBoardCompletionPercent { get; set; } + public int TaskBoardCompletedCardCount { get; set; } + public int TaskBoardCompletedCardSize { get; set; } + public int TaskBoardTotalCards { get; set; } + public int TaskBoardTotalSize { get; set; } public int ProgressPercentage { get; set; } public int TotalCards { get; set; } + public int TotalSize { get; set; } + public int CompletedCardCount { get; set; } + public int CompletedCardSize { get; set; } } } \ No newline at end of file diff --git a/LeanKit.API.Client.Library/TransferObjects/CardView.cs b/LeanKit.API.Client.Library/TransferObjects/CardView.cs index 6d26dca..214a17e 100644 --- a/LeanKit.API.Client.Library/TransferObjects/CardView.cs +++ b/LeanKit.API.Client.Library/TransferObjects/CardView.cs @@ -13,62 +13,83 @@ namespace LeanKit.API.Client.Library.TransferObjects [DebuggerDisplay("{GetType().Name,nq} [{Id}] {Title}")] public class CardView { - public virtual string SystemType { get; set; } - public virtual long Id { get; set; } - public virtual long LaneId { get; set; } - public virtual string Title { get; set; } - public virtual string Description { get; set; } - public virtual CardType Type { get; set; } - public virtual long TypeId { get; set; } - public virtual PriorityType Priority { get; set; } - - public virtual string PriorityText - { - get { return Priority.ToString(); } - } - - public virtual string TypeName { get; set; } - public virtual string TypeIconPath { get; set; } - public virtual string TypeColorHex { get; set; } - public virtual int Size { get; set; } - public virtual bool Active { get; set; } - public virtual string Color { get; set; } - public virtual long Version { get; set; } - public virtual bool IsBlocked { get; set; } - public virtual string BlockReason { get; set; } - public virtual int Index { get; set; } - public virtual string StartDate { get; set; } - public virtual string DueDate { get; set; } - public virtual string ExternalSystemName { get; set; } - public virtual string ExternalSystemUrl { get; set; } - public virtual string ExternalCardID { get; set; } - public virtual string Tags { get; set; } - public virtual long? ClassOfServiceId { get; set; } - public virtual string ClassOfServiceTitle { get; set; } - public virtual string ClassOfServiceIconPath { get; set; } - public virtual string ClassOfServiceColorHex { get; set; } - public virtual int CountOfOldCards { get; set; } - public virtual string LastMove { get; set; } - public virtual string LastActivity { get; set; } - public virtual string DateArchived { get; set; } - public virtual string LastComment { get; set; } - public virtual int CommentsCount { get; set; } + public string SystemType { get; set; } + public long Id { get; set; } + public long LaneId { get; set; } + public string Title { get; set; } + public string Description { get; set; } + public CardType Type { get; set; } + public long TypeId { get; set; } + public PriorityType Priority { get; set; } + public string PriorityText { get { return Priority.ToString(); } } + public string TypeName { get; set; } + public string TypeIconPath { get; set; } + public string TypeColorHex { get; set; } + public int Size { get; set; } + public bool Active { get; set; } + public string Color { get; set; } + public long Version { get; set; } + public bool IsBlocked { get; set; } + public string BlockReason { get; set; } + public int Index { get; set; } + public string StartDate { get; set; } + public string DueDate { get; set; } + public string ExternalSystemName { get; set; } + public string ExternalSystemUrl { get; set; } + public string ExternalCardID { get; set; } + public string Tags { get; set; } + public long? ClassOfServiceId { get; set; } + public string ClassOfServiceTitle { get; set; } + public string ClassOfServiceIconPath { get; set; } + public string ClassOfServiceColorHex { get; set; } + public int CountOfOldCards { get; set; } + public string LastMove { get; set; } + public string LastActivity { get; set; } + public string DateArchived { get; set; } + public string LastComment { get; set; } + public int CommentsCount { get; set; } public string LastAttachment { get; set; } public int AttachmentsCount { get; set; } - - public virtual long? AssignedUserId { get; set; } + public long? AssignedUserId { get; set; } public long[] AssignedUserIds { get; set; } - public virtual List AssignedUsers { get; set; } - - public virtual long? DrillThroughBoardId { get; set; } - public virtual bool HasDrillThroughBoard { get { return DrillThroughBoardId.HasValue; } } - + public List AssignedUsers { get; set; } + public long? DrillThroughBoardId { get; set; } + public bool HasDrillThroughBoard { get { return DrillThroughBoardId.HasValue; } } public List Comments { get; set; } public List HistoryEvents { get; set; } - public int? ParentCardId { get; set; } public int? ParentBoardId { get; set; } public string ExternalCardIdPrefix { get; set; } + public string ActualFinishDate { get; set; } + public string ActualStartDate { get; set; } + public string AssignedUserName { get; set; } + public string BlockStateChangeDate { get; set; } + public long BoardId { get; set; } + public string BoardTitle { get; set; } + public List CardContexts { get; set; } + public string CardTypeIconColor { get; set; } + public string CardTypeIconName { get; set; } + public string ClassOfServiceCustomIconColor { get; set; } + public string ClassOfServiceCustomIconName { get; set; } + public string CreateDate { get; set; } + public string CurrentContext { get; set; } + public long? CurrentTaskBoardId { get; set; } + public int? DrillThroughCompletionPercent { get; set; } + public int? DrillThroughProgressTotal { get; set; } + public int? DrillThroughProgressComplete { get; set; } + public int? DrillThroughProgressSizeComplete { get; set; } + public int? DrillThroughProgressSizeTotal { get; set; } + public string GravatarLink { get; set; } + public string Icon { get; set; } + public bool IsOlderThanXDays { get; set; } + public string LaneTitle { get; set; } + public long? ParentTaskboardId { get; set; } + public string SmallGravatarLink { get; set; } + public int? TaskBoardCompletionPercent { get; set; } + public int TaskBoardCompletedCardCount { get; set; } + public int TaskBoardCompletedCardSize { get; set; } + public int? TaskBoardTotalCards { get; set; } + public int? TaskBoardTotalSize { get; set; } public Card ToCard() { @@ -102,6 +123,36 @@ public Card ToCard() card.DateArchived = DateArchived; card.ParentCardId = ParentCardId; card.ParentBoardId = ParentBoardId; + card.ActualFinishDate = ActualFinishDate; + card.ActualStartDate = ActualStartDate; + card.AssignedUserName = AssignedUserName; + card.BlockStateChangeDate = BlockStateChangeDate; + card.BoardId = BoardId; + card.BoardTitle = BoardTitle; + card.CardContexts = CardContexts; + card.CardTypeIconColor = CardTypeIconColor; + card.CardTypeIconName = CardTypeIconName; + card.ClassOfServiceCustomIconColor = ClassOfServiceCustomIconColor; + card.ClassOfServiceCustomIconName = ClassOfServiceCustomIconName; + card.CreateDate = CreateDate; + card.CurrentContext = CurrentContext; + card.CurrentTaskBoardId = CurrentTaskBoardId; + card.DrillThroughCompletionPercent = DrillThroughCompletionPercent; + card.DrillThroughProgressTotal = DrillThroughProgressTotal; + card.DrillThroughProgressComplete = DrillThroughProgressComplete; + card.DrillThroughProgressSizeComplete = DrillThroughProgressSizeComplete; + card.DrillThroughProgressSizeTotal = DrillThroughProgressSizeTotal; + card.GravatarLink = GravatarLink; + card.Icon = Icon; + card.IsOlderThanXDays = IsOlderThanXDays; + card.LaneTitle = LaneTitle; + card.ParentTaskboardId = ParentTaskboardId; + card.SmallGravatarLink = SmallGravatarLink; + card.TaskBoardCompletionPercent = TaskBoardCompletionPercent; + card.TaskBoardCompletedCardCount = TaskBoardCompletedCardCount; + card.TaskBoardCompletedCardSize = TaskBoardCompletedCardSize; + card.TaskBoardTotalCards = TaskBoardTotalCards; + card.TaskBoardTotalSize = TaskBoardTotalSize; return card; } diff --git a/Samples/LeanKitNotifier/LeanKitNotifierApplicationContext.cs b/Samples/LeanKitNotifier/LeanKitNotifierApplicationContext.cs index 9918170..379e63f 100644 --- a/Samples/LeanKitNotifier/LeanKitNotifierApplicationContext.cs +++ b/Samples/LeanKitNotifier/LeanKitNotifierApplicationContext.cs @@ -90,7 +90,8 @@ private void IntegrationOnBoardChanged(object sender, BoardChangedEventArgs boar if (boardChangedEventArgs.BlockedCards.Any()) sb.AppendLine(string.Format("{0} card(s) were blocked.", boardChangedEventArgs.BlockedCards.Count)); - ShowMessage(sb.ToString()); + var message = sb.ToString(); + if (message.Length > 0) ShowMessage(message); } public void ShowMessage(string message) diff --git a/publish/LeanKit.API.Client.Library.dll.nuspec b/publish/LeanKit.API.Client.Library.dll.nuspec index 2812034..173928b 100644 --- a/publish/LeanKit.API.Client.Library.dll.nuspec +++ b/publish/LeanKit.API.Client.Library.dll.nuspec @@ -2,7 +2,7 @@ LeanKit.API.Client - 1.0.8 + 1.1.1 LeanKit LeanKit https://raw.githubusercontent.com/LeanKit/LeanKit.API.Client/master/License.txt diff --git a/publish/readme.md b/publish/readme.md index 93e2917..f01b708 100644 --- a/publish/readme.md +++ b/publish/readme.md @@ -2,6 +2,8 @@ [Creating and Publishing a Nuget Package](http://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-package) +Copy latest .dll into .\lib\net40 + `nuget pack .\LeanKit.API.Client.Library.dll.nuspec` -`nuget push .\LeanKit.API.Client.1.0.3.nupkg` \ No newline at end of file +`nuget push .\LeanKit.API.Client.1.1.0.nupkg` \ No newline at end of file From 5ac791436ebbbc15eef426d5d6cd91245bf0208f Mon Sep 17 00:00:00 2001 From: David Neal Date: Fri, 12 Jun 2015 17:05:56 -0400 Subject: [PATCH 18/40] Fixed issue when card is updated and moved to the archive at the same time. --- .../Extensions/CollectionExtensions.cs | 25 ++--- .../LeanKitIntegration.cs | 93 +++++++++++-------- .../Properties/AssemblyInfo.cs | 16 ++-- publish/LeanKit.API.Client.Library.dll.nuspec | 2 +- publish/readme.md | 2 +- 5 files changed, 78 insertions(+), 60 deletions(-) diff --git a/LeanKit.API.Client.Library/Extensions/CollectionExtensions.cs b/LeanKit.API.Client.Library/Extensions/CollectionExtensions.cs index 021d63f..7f98e12 100644 --- a/LeanKit.API.Client.Library/Extensions/CollectionExtensions.cs +++ b/LeanKit.API.Client.Library/Extensions/CollectionExtensions.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // Copyright (c) LeanKit Inc. All rights reserved. -// +// //------------------------------------------------------------------------------ using System.Collections.Generic; @@ -16,21 +16,24 @@ public static class CollectionExtensions public static Card FindContainedCard(this IEnumerable lanes, long laneId, long cardId) { var list = lanes as IList ?? lanes.ToList(); - var candidateLane = list.FindLane(laneId); - - //Get the card from the lane - var candidateCard = candidateLane.Cards.FirstOrDefault(card => card.Id == cardId); + if (list.ContainsLane(laneId)) + { + var candidateLane = list.FindLane(laneId); - if (candidateCard != null) return candidateCard.ToCard(); + //Get the card from the lane + var candidateCard = candidateLane.Cards.FirstOrDefault(card => card.Id == cardId); + if (candidateCard != null) return candidateCard.ToCard(); + } //the card may have been moved so look in all the affected lanes - candidateCard = list.SelectMany(x => x.Cards).FirstOrDefault(card => card.Id == cardId); - if (candidateCard == null) + var candidateCard2 = list.SelectMany(x => x.Cards).FirstOrDefault(card => card.Id == cardId); + if (candidateCard2 == null) { - throw new ItemNotFoundException(string.Format("Unable to find the Card [{0}] in the associated Lane [{1}].", cardId, laneId)); + throw new ItemNotFoundException(string.Format("Unable to find the Card [{0}] in the associated Lane [{1}].", cardId, + laneId)); } - return candidateCard.ToCard(); + return candidateCard2.ToCard(); } public static Lane FindLane(this IEnumerable lanes, long laneId) @@ -82,4 +85,4 @@ public static IEnumerable GetFlatLanes(this IEnumerable } } } -} \ No newline at end of file +} diff --git a/LeanKit.API.Client.Library/LeanKitIntegration.cs b/LeanKit.API.Client.Library/LeanKitIntegration.cs index a304189..9d90494 100644 --- a/LeanKit.API.Client.Library/LeanKitIntegration.cs +++ b/LeanKit.API.Client.Library/LeanKitIntegration.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // Copyright (c) LeanKit Inc. All rights reserved. -// +// //------------------------------------------------------------------------------ using System; @@ -72,7 +72,7 @@ public void StartWatching(bool includeTaskboards) private void InitBoard() { //setup the loop intervals - //Probably need to do this on a different thread + //Probably need to do this on a different thread do { try @@ -123,7 +123,7 @@ private CheckForUpdatesLoopResult SetupCheckForUpdatesLoop() { const int pulse = 1000; var pollingInterval = (long) _integrationSettings.CheckForUpdatesIntervalSeconds*1000; - + var stopWatch = new System.Diagnostics.Stopwatch(); stopWatch.Start(); @@ -301,7 +301,6 @@ private CheckForUpdatesLoopResult SetupCheckForUpdatesLoop() { OnClientError(new ClientErrorEventArgs {Exception = ex, Message = "Error checking for board events."}); } - } while (ShouldContinue); stopWatch.Stop(); @@ -533,8 +532,12 @@ private CardUpdateEvent CreateCardUpdateEvent(BoardHistoryEvent boardEvent, IEnu if (originalCard == null) return null; - var updatedCard = - affectedLanes.FindContainedCard(boardEvent.ToLaneId, boardEvent.CardId); + var lanes = affectedLanes.ToList(); + + var updatedCard = (lanes.ContainsCard(boardEvent.CardId)) + ? lanes.FindContainedCard(boardEvent.ToLaneId, boardEvent.CardId) + : GetCard(boardEvent.CardId, true); + return new CardUpdateEvent(boardEvent.EventDateTime, originalCard, updatedCard); } catch (ItemNotFoundException ex) @@ -566,34 +569,39 @@ private static EventType GetEventType(string eventType) public virtual Card GetCard(long cardId) { - Card card; - _boardLock.EnterReadLock(); - try - { - card = _board.GetCardById(cardId); - } - finally + return GetCard(cardId, false); + } + + public virtual Card GetCard(long cardId, bool bypassCache) + { + Card card = null; + if (!bypassCache) { - _boardLock.ExitReadLock(); + _boardLock.EnterReadLock(); + try + { + card = _board.GetCardById(cardId); + } + finally + { + _boardLock.ExitReadLock(); + } } + if (card != null) return card; + // try getting card directly from the api - if (card == null) - { - var c = _api.GetCard(_boardId, cardId); - card = (c != null) ? c.ToCard() : null; - } + var c = _api.GetCard(_boardId, cardId); + card = (c != null) ? c.ToCard() : null; + if (card != null) return card; //try to find in archive, suppose it is not loaded - if (card == null) - { - var archive = _api.GetArchiveCards(_boardId); - var firstOrDefault = (archive != null) ? archive.FirstOrDefault(x => x.Id == cardId) : null; - if (firstOrDefault != null) card = firstOrDefault.ToCard(); - //TODO: need to load the archive - //Also, could be possible that the card is part of the cards older than 90 days - //In that case we my need to do a search too. - } + var archive = _api.GetArchiveCards(_boardId); + var firstOrDefault = (archive != null) ? archive.FirstOrDefault(x => x.Id == cardId) : null; + if (firstOrDefault != null) card = firstOrDefault.ToCard(); + //TODO: need to load the archive + //Also, could be possible that the card is part of the cards older than 90 days + //In that case we my need to do a search too. if (card == null) throw new ItemNotFoundException(); @@ -826,7 +834,7 @@ public void AddTask(Card task, long cardId, string wipOverrideReason) // //ApplyBoardChanges(results.BoardVersion, new[] {results.Lane}); //} finally { // _boardLock.ExitWriteLock(); - //} + //} } public void UpdateTask(Card task, long cardId) @@ -853,7 +861,7 @@ public void UpdateTask(Card task, long cardId, string wipOverrideReason) // } // finally { // _boardLock.ExitWriteLock(); - // } + // } } public void DeleteTask(long taskId, long cardId) @@ -864,7 +872,7 @@ public void DeleteTask(long taskId, long cardId) public void MoveTask(long taskId, long cardId, long toLaneId, int position) { - MoveTask(taskId, cardId, toLaneId, position, string.Empty); + MoveTask(taskId, cardId, toLaneId, position, string.Empty); } public void MoveTask(long taskId, long cardId, long toLaneId, int position, string wipOverrideReason) @@ -901,7 +909,8 @@ public DrillThroughStatistics GetDrillThroughStatistics(long boardId, long cardI #region obsolete [Obsolete("Creating taskboards is no longer supported", true)] - public void CreateTaskboard(long cardId, TaskboardTemplateType templateType, long cardContextId) { + public void CreateTaskboard(long cardId, TaskboardTemplateType templateType, long cardContextId) + { //_boardLock.EnterUpgradeableReadLock(); //try //{ @@ -931,7 +940,8 @@ public void CreateTaskboard(long cardId, TaskboardTemplateType templateType, lon } [Obsolete("Deleting taskboards is no longer supported", true)] - public void DeleteTaskboard(long cardId, long taskboardId) { + public void DeleteTaskboard(long cardId, long taskboardId) + { //_boardLock.EnterUpgradeableReadLock(); //try //{ @@ -962,12 +972,14 @@ public void DeleteTaskboard(long cardId, long taskboardId) { } [Obsolete("Use AddTask instead")] - public void AddTaskboardCard(Card card, long taskboardId) { + public void AddTaskboardCard(Card card, long taskboardId) + { AddTaskboardCard(card, taskboardId, string.Empty); } [Obsolete("Use AddTask instead")] - public void AddTaskboardCard(Card card, long taskboardId, string wipOverrideReason) { + public void AddTaskboardCard(Card card, long taskboardId, string wipOverrideReason) + { //var results = string.IsNullOrEmpty(wipOverrideReason) // ? _api.AddTaskboardCard(_boardId, taskboardId, card) // : _api.AddTaskboardCard(_boardId, taskboardId, card, wipOverrideReason); @@ -982,12 +994,14 @@ public void AddTaskboardCard(Card card, long taskboardId, string wipOverrideReas } [Obsolete("Use UpdateTask instead")] - public void UpdateTaskboardCard(Card card, long taskboardId) { + public void UpdateTaskboardCard(Card card, long taskboardId) + { UpdateTaskboardCard(card, taskboardId, string.Empty); } [Obsolete("Use UpdateTask instead")] - public void UpdateTaskboardCard(Card card, long taskboardId, string wipOverrideReason) { + public void UpdateTaskboardCard(Card card, long taskboardId, string wipOverrideReason) + { //var results = string.IsNullOrEmpty(wipOverrideReason) // ? _api.UpdateTaskboardCard(_boardId, taskboardId, card) // : _api.UpdateTaskboardCard(_boardId, taskboardId, card, wipOverrideReason); @@ -1008,7 +1022,8 @@ public void UpdateTaskboardCard(Card card, long taskboardId, string wipOverrideR } [Obsolete("Use DeleteTask instead")] - public void DeleteTaskboardCard(long cardId, long taskboardId) { + public void DeleteTaskboardCard(long cardId, long taskboardId) + { throw new NotImplementedException(); } @@ -1028,4 +1043,4 @@ public void MoveTaskboardCard(long cardId, long taskboardId, long toLaneId, int #endregion } -} \ No newline at end of file +} diff --git a/LeanKit.API.Client.Library/Properties/AssemblyInfo.cs b/LeanKit.API.Client.Library/Properties/AssemblyInfo.cs index d82a5d5..cf6e657 100644 --- a/LeanKit.API.Client.Library/Properties/AssemblyInfo.cs +++ b/LeanKit.API.Client.Library/Properties/AssemblyInfo.cs @@ -1,13 +1,13 @@ //------------------------------------------------------------------------------ // // Copyright (c) LeanKit Inc. All rights reserved. -// +// //------------------------------------------------------------------------------ using System.Reflection; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. @@ -20,8 +20,8 @@ [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] @@ -33,13 +33,13 @@ // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -// You can specify all the values or you can default the Build and Revision Numbers +// You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.1.1.0")] -[assembly: AssemblyFileVersion("1.1.1.0")] \ No newline at end of file +[assembly: AssemblyVersion("1.2.0.0")] +[assembly: AssemblyFileVersion("1.2.0.0")] diff --git a/publish/LeanKit.API.Client.Library.dll.nuspec b/publish/LeanKit.API.Client.Library.dll.nuspec index 173928b..a52f5b9 100644 --- a/publish/LeanKit.API.Client.Library.dll.nuspec +++ b/publish/LeanKit.API.Client.Library.dll.nuspec @@ -2,7 +2,7 @@ LeanKit.API.Client - 1.1.1 + 1.2.0 LeanKit LeanKit https://raw.githubusercontent.com/LeanKit/LeanKit.API.Client/master/License.txt diff --git a/publish/readme.md b/publish/readme.md index f01b708..5fbd482 100644 --- a/publish/readme.md +++ b/publish/readme.md @@ -6,4 +6,4 @@ Copy latest .dll into .\lib\net40 `nuget pack .\LeanKit.API.Client.Library.dll.nuspec` -`nuget push .\LeanKit.API.Client.1.1.0.nupkg` \ No newline at end of file +`nuget push .\LeanKit.API.Client.1.2.0.nupkg` \ No newline at end of file From dbe666e65ae58a2e7c650cc05f577b3eed309fc8 Mon Sep 17 00:00:00 2001 From: David Neal Date: Wed, 17 Jun 2015 12:43:23 -0400 Subject: [PATCH 19/40] Updating README --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index e2c5547..e8534f3 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,23 @@ var leanKitAuth = new LeanKitBasicAuth var api = new LeanKitClientFactory().Create(leanKitAuth); ``` +#### Connecting to alternate LeanKit domains + +To connect to other LeanKit domains, such as LeanKit for Construction [leankit.co](http://leankit.co), use the `UrlTemplateOverride` property. + +``` +var leanKitAuth = new LeanKitBasicAuth + { + Hostname = "MyAccount", + // Only the account name portion of the URL + // e.g. https://MyAccount.leankit.com + Username = "your-account-email-address", + Password = "your-account-password", + UrlTemplateOverride = "https://{0}.leankit.co" + }; +var api = new LeanKitClientFactory().Create(leanKitAuth); +``` + ## LeanKitIntegration This class is designed to be used in stateful implementations. This class monitors the changes to a Board, and raises events whenever a board is changed. This library helps reduce the complexity of polling for changes. In addition, this class exposes the same command and query methods that are available in the LeanKitClient class. Leveraging its stateful nature, many of these queries and commands can be optimized, and provide more powerful validation. From 48ab95f6b45a7d700c132259770db92654fb60bf Mon Sep 17 00:00:00 2001 From: David Neal Date: Wed, 17 Jun 2015 12:53:28 -0400 Subject: [PATCH 20/40] Updating README to include proxy information --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.md b/README.md index e8534f3..cb0bc39 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,30 @@ integration.BoardChanged += integration_BoardChanged; integration.StartWatching(); ``` +## Connecting through an HTTP proxy server + +To connect to the LeanKit API through an HTTP proxy server, you will need to add or update your .NET application `app.config` or `web.config` file to include a `` section. + +``` + + + + + +``` + +Or, if more granular control of the proxy is required, it could look something like: + +``` + + + + + +``` + +For more help, please review the .NET documentation on [proxy configuration](https://msdn.microsoft.com/en-us/library/kd3cf2ex(v=vs.110).aspx). + ### LeanKitClient Interface ``` From bd0a5c17d8ca52c5d1d76f797b8c1472c4722d45 Mon Sep 17 00:00:00 2001 From: David Neal Date: Wed, 17 Jun 2015 12:55:45 -0400 Subject: [PATCH 21/40] Updating README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cb0bc39..5fa65a3 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ integration.StartWatching(); ## Connecting through an HTTP proxy server -To connect to the LeanKit API through an HTTP proxy server, you will need to add or update your .NET application `app.config` or `web.config` file to include a `` section. +To connect to the LeanKit API through an HTTP proxy server, you will need to add or update your .NET application's `app.config` or `web.config` file to include a `` section. ``` From f26081fa887efad3c89e3af4a4eb5698d8c58e83 Mon Sep 17 00:00:00 2001 From: David Neal Date: Wed, 17 Jun 2015 12:57:10 -0400 Subject: [PATCH 22/40] Updating README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5fa65a3..25f868e 100644 --- a/README.md +++ b/README.md @@ -199,7 +199,7 @@ Visit [support.leankit.com](http://support.leankit.com). ## Copyright -Copyright © 2013-2014 LeanKit Inc. +Copyright © 2013-2015 LeanKit Inc. ## License From 7a3960ca6477ce44983ca0f9837fd1aaba60f024 Mon Sep 17 00:00:00 2001 From: David Neal Date: Tue, 7 Jul 2015 17:26:41 -0400 Subject: [PATCH 23/40] ParentCardId and ParentBoardId should be long --- .../TransferObjects/Card.cs | 8 +++--- .../TransferObjects/CardView.cs | 26 ++++++++++++++----- LeanKit.API.Client.sln | 7 ++++- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/LeanKit.API.Client.Library/TransferObjects/Card.cs b/LeanKit.API.Client.Library/TransferObjects/Card.cs index 095b6ea..9ef1cab 100644 --- a/LeanKit.API.Client.Library/TransferObjects/Card.cs +++ b/LeanKit.API.Client.Library/TransferObjects/Card.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // Copyright (c) LeanKit Inc. All rights reserved. -// +// //------------------------------------------------------------------------------ using System.Collections.Generic; @@ -75,8 +75,8 @@ public class Card public List HistoryEvents { get; set; } public List CardContexts { get; set; } - public int? ParentCardId { get; set; } - public int? ParentBoardId { get; set; } + public long? ParentCardId { get; set; } + public long? ParentBoardId { get; set; } public string ActualFinishDate { get; set; } public string ActualStartDate { get; set; } public string AssignedUserName { get; set; } @@ -218,4 +218,4 @@ public class CardDelegationResult public string DestinationLaneName { get; set; } } -} \ No newline at end of file +} diff --git a/LeanKit.API.Client.Library/TransferObjects/CardView.cs b/LeanKit.API.Client.Library/TransferObjects/CardView.cs index 214a17e..2baa632 100644 --- a/LeanKit.API.Client.Library/TransferObjects/CardView.cs +++ b/LeanKit.API.Client.Library/TransferObjects/CardView.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // Copyright (c) LeanKit Inc. All rights reserved. -// +// //------------------------------------------------------------------------------ using System.Collections.Generic; @@ -21,7 +21,12 @@ public class CardView public CardType Type { get; set; } public long TypeId { get; set; } public PriorityType Priority { get; set; } - public string PriorityText { get { return Priority.ToString(); } } + + public string PriorityText + { + get { return Priority.ToString(); } + } + public string TypeName { get; set; } public string TypeIconPath { get; set; } public string TypeColorHex { get; set; } @@ -54,11 +59,16 @@ public class CardView public long[] AssignedUserIds { get; set; } public List AssignedUsers { get; set; } public long? DrillThroughBoardId { get; set; } - public bool HasDrillThroughBoard { get { return DrillThroughBoardId.HasValue; } } + + public bool HasDrillThroughBoard + { + get { return DrillThroughBoardId.HasValue; } + } + public List Comments { get; set; } public List HistoryEvents { get; set; } - public int? ParentCardId { get; set; } - public int? ParentBoardId { get; set; } + public long? ParentCardId { get; set; } + public long? ParentBoardId { get; set; } public string ExternalCardIdPrefix { get; set; } public string ActualFinishDate { get; set; } public string ActualStartDate { get; set; } @@ -114,7 +124,9 @@ public Card ToCard() card.Title = Title; card.TypeId = TypeId; card.Version = Version; - card.AssignedUserIds = (AssignedUsers != null) ? (AssignedUserIds != null) ? AssignedUserIds : AssignedUsers.Select(x => x.Id.Value).ToArray() : null; + card.AssignedUserIds = (AssignedUsers != null) + ? (AssignedUserIds != null) ? AssignedUserIds : AssignedUsers.Select(x => x.Id.Value).ToArray() + : null; card.Comments = Comments; card.HistoryEvents = HistoryEvents; card.LastMove = LastMove; @@ -157,4 +169,4 @@ public Card ToCard() return card; } } -} \ No newline at end of file +} diff --git a/LeanKit.API.Client.sln b/LeanKit.API.Client.sln index c181752..f261b70 100644 --- a/LeanKit.API.Client.sln +++ b/LeanKit.API.Client.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 -VisualStudioVersion = 12.0.21005.1 +VisualStudioVersion = 12.0.31101.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LeanKit.API.Client.Library", "LeanKit.API.Client.Library\LeanKit.API.Client.Library.csproj", "{E1A6887D-DCEE-4B78-8187-4BBC1B370776}" EndProject @@ -20,6 +20,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LeanKitCmdQuery", "Samples\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LeanKitNotifier", "Samples\LeanKitNotifier\LeanKitNotifier.csproj", "{4AFD2A23-32B8-4586-84A1-D095548CE2A8}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{845E8B5C-18DA-49D6-B9D9-EAB1C11FC1D0}" + ProjectSection(SolutionItems) = preProject + README.md = README.md + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU From c33fa74f362cca6ff6704e9c6d34d871c74b1a85 Mon Sep 17 00:00:00 2001 From: David Neal Date: Tue, 7 Jul 2015 17:31:07 -0400 Subject: [PATCH 24/40] Bumping version number --- LeanKit.API.Client.Library/Properties/AssemblyInfo.cs | 4 ++-- publish/LeanKit.API.Client.Library.dll.nuspec | 2 +- publish/readme.md | 4 ++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/LeanKit.API.Client.Library/Properties/AssemblyInfo.cs b/LeanKit.API.Client.Library/Properties/AssemblyInfo.cs index cf6e657..20d3629 100644 --- a/LeanKit.API.Client.Library/Properties/AssemblyInfo.cs +++ b/LeanKit.API.Client.Library/Properties/AssemblyInfo.cs @@ -41,5 +41,5 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.2.0.0")] -[assembly: AssemblyFileVersion("1.2.0.0")] +[assembly: AssemblyVersion("1.2.1.0")] +[assembly: AssemblyFileVersion("1.2.1.0")] diff --git a/publish/LeanKit.API.Client.Library.dll.nuspec b/publish/LeanKit.API.Client.Library.dll.nuspec index a52f5b9..9c3c35e 100644 --- a/publish/LeanKit.API.Client.Library.dll.nuspec +++ b/publish/LeanKit.API.Client.Library.dll.nuspec @@ -2,7 +2,7 @@ LeanKit.API.Client - 1.2.0 + 1.2.1 LeanKit LeanKit https://raw.githubusercontent.com/LeanKit/LeanKit.API.Client/master/License.txt diff --git a/publish/readme.md b/publish/readme.md index 5fbd482..dc15372 100644 --- a/publish/readme.md +++ b/publish/readme.md @@ -2,6 +2,10 @@ [Creating and Publishing a Nuget Package](http://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-package) +Bump version number in ..\LeanKit.API.Client.Library\Properties\AssemblyInfo.cs + +Bump version number in .\LeanKit.API.Client.Library.dll.nuspec + Copy latest .dll into .\lib\net40 `nuget pack .\LeanKit.API.Client.Library.dll.nuspec` From a7707e2fdeb3edbed945554759de435999271219 Mon Sep 17 00:00:00 2001 From: David Neal Date: Mon, 13 Jul 2015 10:08:32 -0400 Subject: [PATCH 25/40] Fix for return value on posting a new comment --- LeanKit.API.Client.Library/ILeanKitApi.cs | 26 ++++++++++++------- LeanKit.API.Client.Library/LeanKitClient.cs | 9 ++++--- .../Properties/AssemblyInfo.cs | 4 +-- publish/LeanKit.API.Client.Library.dll.nuspec | 2 +- publish/readme.md | 2 +- 5 files changed, 25 insertions(+), 18 deletions(-) diff --git a/LeanKit.API.Client.Library/ILeanKitApi.cs b/LeanKit.API.Client.Library/ILeanKitApi.cs index 7d6751a..fab8494 100644 --- a/LeanKit.API.Client.Library/ILeanKitApi.cs +++ b/LeanKit.API.Client.Library/ILeanKitApi.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // Copyright (c) LeanKit Inc. All rights reserved. -// +// //------------------------------------------------------------------------------ using System; @@ -37,11 +37,11 @@ public interface ILeanKitApi CardsUpdateResult UpdateCards(long boardId, IEnumerable updatedCards); long DeleteCard(long boardId, long cardId); CardsDeleteResult DeleteCards(long boardId, IEnumerable cardIds); - CardDelegationResult DelegateCard(long cardId, long delegationBoardId); - BoardUpdates CheckForUpdates(long boardId, int version); + CardDelegationResult DelegateCard(long cardId, long delegationBoardId); + BoardUpdates CheckForUpdates(long boardId, int version); IEnumerable GetComments(long boardId, long cardId); - int PostComment(long boardId, long cardId, Comment comment); - int PostCommentByExternalId(long boardId, string externalId, Comment comment); + long PostComment(long boardId, long cardId, Comment comment); + long PostCommentByExternalId(long boardId, string externalId, Comment comment); IEnumerable GetCardHistory(long boardId, long cardId); IEnumerable SearchCards(long boardId, SearchOptions options); IEnumerable ListNewCards(long boardId); @@ -66,30 +66,36 @@ public interface ILeanKitApi AssetFile DownloadAttachment(long boardId, long attachmentId); #region Obsolete - + [Obsolete("Creating taskboards is no longer supported", true)] - TaskboardCreateResult CreateTaskboard(long boardId, long containingCardId, TaskboardTemplateType templateType, long cardContextId); + TaskboardCreateResult CreateTaskboard(long boardId, long containingCardId, TaskboardTemplateType templateType, + long cardContextId); + [Obsolete("Deleting taskboards is no longer supported", true)] TaskboardDeleteResult DeleteTaskboard(long boardId, long taskboardId); [Obsolete("Use AddTask instead")] CardAddResult AddTaskboardCard(long boardId, long taskboardId, Card newCard); + [Obsolete("Use AddTask instead")] CardAddResult AddTaskboardCard(long boardId, long taskboardId, Card newCard, string wipOverrideReason); + [Obsolete("Use UpdateTask instead")] CardUpdateResult UpdateTaskboardCard(long boardId, long taskboardId, Card updatedCard, string wipOverrideReason); + [Obsolete("Use UpdateTask instead")] CardUpdateResult UpdateTaskboardCard(long boardId, long taskboardId, Card updatedCard); + [Obsolete("Use DeleteTask instead")] long DeleteTaskboardCard(long boardId, long taskboardId, long cardId); + [Obsolete("Use MoveTask instead")] CardMoveResult MoveTaskboardCard(long boardId, long taskboardId, long cardId, long toLaneId, int position, string wipOverrideReason); + [Obsolete("Use MoveTask instead")] CardMoveResult MoveTaskboardCard(long boardId, long taskboardId, long cardId, long toLaneId, int position); #endregion - - } -} \ No newline at end of file +} diff --git a/LeanKit.API.Client.Library/LeanKitClient.cs b/LeanKit.API.Client.Library/LeanKitClient.cs index fe3858e..552cdab 100644 --- a/LeanKit.API.Client.Library/LeanKitClient.cs +++ b/LeanKit.API.Client.Library/LeanKitClient.cs @@ -272,13 +272,13 @@ public IEnumerable GetComments(long boardId, long cardId) return _restCommandProcessor.Get>(_accountAuth, resource); } - public int PostComment(long boardId, long cardId, Comment comment) + public long PostComment(long boardId, long cardId, Comment comment) { var resource = "/Kanban/Api/Card/SaveComment/" + boardId + "/" + cardId; return _restCommandProcessor.Post(_accountAuth, resource, comment); } - public int PostCommentByExternalId(long boardId, string externalId, Comment comment) + public long PostCommentByExternalId(long boardId, string externalId, Comment comment) { var resource = "/Kanban/Api/Card/SaveCommentByExternalId/" + boardId + "/" + Uri.EscapeDataString(externalId); return _restCommandProcessor.Post(_accountAuth, resource, comment); @@ -483,11 +483,12 @@ public CardMoveResult MoveTaskboardCard(long boardId, long taskboardId, long car #region Attachment Methods - public long SaveAttachment(long boardId, long cardId, string fileName, string description, string mimeType, byte[] fileBytes) + public long SaveAttachment(long boardId, long cardId, string fileName, string description, string mimeType, + byte[] fileBytes) { var resource = string.Format("/kanban/api/card/SaveAttachment/{0}/{1}", boardId, cardId); var parameters = new Dictionary {{"Description", description}, {"Id", 0}}; - return _restCommandProcessor.PostFile(_accountAuth, resource, parameters, fileName, mimeType, fileBytes); + return _restCommandProcessor.PostFile(_accountAuth, resource, parameters, fileName, mimeType, fileBytes); } public long DeleteAttachment(long boardId, long cardId, long attachmentId) diff --git a/LeanKit.API.Client.Library/Properties/AssemblyInfo.cs b/LeanKit.API.Client.Library/Properties/AssemblyInfo.cs index 20d3629..54cf236 100644 --- a/LeanKit.API.Client.Library/Properties/AssemblyInfo.cs +++ b/LeanKit.API.Client.Library/Properties/AssemblyInfo.cs @@ -41,5 +41,5 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.2.1.0")] -[assembly: AssemblyFileVersion("1.2.1.0")] +[assembly: AssemblyVersion("1.2.2.0")] +[assembly: AssemblyFileVersion("1.2.2.0")] diff --git a/publish/LeanKit.API.Client.Library.dll.nuspec b/publish/LeanKit.API.Client.Library.dll.nuspec index 9c3c35e..9637a32 100644 --- a/publish/LeanKit.API.Client.Library.dll.nuspec +++ b/publish/LeanKit.API.Client.Library.dll.nuspec @@ -2,7 +2,7 @@ LeanKit.API.Client - 1.2.1 + 1.2.2 LeanKit LeanKit https://raw.githubusercontent.com/LeanKit/LeanKit.API.Client/master/License.txt diff --git a/publish/readme.md b/publish/readme.md index dc15372..a2fee84 100644 --- a/publish/readme.md +++ b/publish/readme.md @@ -10,4 +10,4 @@ Copy latest .dll into .\lib\net40 `nuget pack .\LeanKit.API.Client.Library.dll.nuspec` -`nuget push .\LeanKit.API.Client.1.2.0.nupkg` \ No newline at end of file +`nuget push .\LeanKit.API.Client.1.2.2.nupkg` \ No newline at end of file From b35336a88eab13de984bf49d43aed6560e9adeca Mon Sep 17 00:00:00 2001 From: David Neal Date: Mon, 13 Jul 2015 10:11:36 -0400 Subject: [PATCH 26/40] Fix for post comment return value --- LeanKit.API.Client.Library/LeanKitClient.cs | 4 ++-- LeanKit.API.Client.Library/Properties/AssemblyInfo.cs | 4 ++-- publish/LeanKit.API.Client.Library.dll.nuspec | 2 +- publish/readme.md | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/LeanKit.API.Client.Library/LeanKitClient.cs b/LeanKit.API.Client.Library/LeanKitClient.cs index 552cdab..c48855e 100644 --- a/LeanKit.API.Client.Library/LeanKitClient.cs +++ b/LeanKit.API.Client.Library/LeanKitClient.cs @@ -275,13 +275,13 @@ public IEnumerable GetComments(long boardId, long cardId) public long PostComment(long boardId, long cardId, Comment comment) { var resource = "/Kanban/Api/Card/SaveComment/" + boardId + "/" + cardId; - return _restCommandProcessor.Post(_accountAuth, resource, comment); + return _restCommandProcessor.Post(_accountAuth, resource, comment); } public long PostCommentByExternalId(long boardId, string externalId, Comment comment) { var resource = "/Kanban/Api/Card/SaveCommentByExternalId/" + boardId + "/" + Uri.EscapeDataString(externalId); - return _restCommandProcessor.Post(_accountAuth, resource, comment); + return _restCommandProcessor.Post(_accountAuth, resource, comment); } public IEnumerable GetCardHistory(long boardId, long cardId) diff --git a/LeanKit.API.Client.Library/Properties/AssemblyInfo.cs b/LeanKit.API.Client.Library/Properties/AssemblyInfo.cs index 54cf236..61a62c3 100644 --- a/LeanKit.API.Client.Library/Properties/AssemblyInfo.cs +++ b/LeanKit.API.Client.Library/Properties/AssemblyInfo.cs @@ -41,5 +41,5 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.2.2.0")] -[assembly: AssemblyFileVersion("1.2.2.0")] +[assembly: AssemblyVersion("1.2.3.0")] +[assembly: AssemblyFileVersion("1.2.3.0")] diff --git a/publish/LeanKit.API.Client.Library.dll.nuspec b/publish/LeanKit.API.Client.Library.dll.nuspec index 9637a32..2e11f3c 100644 --- a/publish/LeanKit.API.Client.Library.dll.nuspec +++ b/publish/LeanKit.API.Client.Library.dll.nuspec @@ -2,7 +2,7 @@ LeanKit.API.Client - 1.2.2 + 1.2.3 LeanKit LeanKit https://raw.githubusercontent.com/LeanKit/LeanKit.API.Client/master/License.txt diff --git a/publish/readme.md b/publish/readme.md index a2fee84..c9aeb85 100644 --- a/publish/readme.md +++ b/publish/readme.md @@ -10,4 +10,4 @@ Copy latest .dll into .\lib\net40 `nuget pack .\LeanKit.API.Client.Library.dll.nuspec` -`nuget push .\LeanKit.API.Client.1.2.2.nupkg` \ No newline at end of file +`nuget push .\LeanKit.API.Client.1.2.3.nupkg` \ No newline at end of file From b483068895133d2e8c6d537f9b3f1858faec5e73 Mon Sep 17 00:00:00 2001 From: David Neal Date: Mon, 20 Jul 2015 14:08:19 -0400 Subject: [PATCH 27/40] Updating board version to long --- LeanKit.API.Client.Library/ILeanKitApi.cs | 6 +++--- LeanKit.API.Client.Library/LeanKitClient.cs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/LeanKit.API.Client.Library/ILeanKitApi.cs b/LeanKit.API.Client.Library/ILeanKitApi.cs index fab8494..408f379 100644 --- a/LeanKit.API.Client.Library/ILeanKitApi.cs +++ b/LeanKit.API.Client.Library/ILeanKitApi.cs @@ -18,8 +18,8 @@ public interface ILeanKitApi IEnumerable GetBacklogLanes(long boardId); IEnumerable GetArchiveLanes(long boardId); IEnumerable GetArchiveCards(long boardId); - Board GetNewerIfExists(long boardId, int version); - IEnumerable GetBoardHistorySince(long boardId, int version); + Board GetNewerIfExists(long boardId, long version); + IEnumerable GetBoardHistorySince(long boardId, long version); CardView GetCard(long boardId, long cardId); Card GetCardByExternalId(long boardId, string externalCardId); BoardIdentifiers GetBoardIdentifiers(long boardId); @@ -38,7 +38,7 @@ public interface ILeanKitApi long DeleteCard(long boardId, long cardId); CardsDeleteResult DeleteCards(long boardId, IEnumerable cardIds); CardDelegationResult DelegateCard(long cardId, long delegationBoardId); - BoardUpdates CheckForUpdates(long boardId, int version); + BoardUpdates CheckForUpdates(long boardId, long version); IEnumerable GetComments(long boardId, long cardId); long PostComment(long boardId, long cardId, Comment comment); long PostCommentByExternalId(long boardId, string externalId, Comment comment); diff --git a/LeanKit.API.Client.Library/LeanKitClient.cs b/LeanKit.API.Client.Library/LeanKitClient.cs index c48855e..fd6f3d6 100644 --- a/LeanKit.API.Client.Library/LeanKitClient.cs +++ b/LeanKit.API.Client.Library/LeanKitClient.cs @@ -134,13 +134,13 @@ public IEnumerable GetArchiveCards(long boardId) return _restCommandProcessor.Get>(_accountAuth, resource); } - public Board GetNewerIfExists(long boardId, int version) + public Board GetNewerIfExists(long boardId, long version) { var resource = string.Format("/Kanban/Api/Board/{0}/BoardVersion/{1}/GetNewerIfExists", boardId, version); return _restCommandProcessor.Get(_accountAuth, resource); } - public IEnumerable GetBoardHistorySince(long boardId, int version) + public IEnumerable GetBoardHistorySince(long boardId, long version) { var resource = string.Format("/Kanban/Api/Board/{0}/BoardVersion/{1}/GetBoardHistorySince", boardId, version); return _restCommandProcessor.Get>(_accountAuth, resource); @@ -260,7 +260,7 @@ public CardDelegationResult DelegateCard(long cardId, long delegationBoardId) return _restCommandProcessor.Post(_accountAuth, resource); } - public BoardUpdates CheckForUpdates(long boardId, int version) + public BoardUpdates CheckForUpdates(long boardId, long version) { var resource = "/Kanban/Api/Board/" + boardId + "/BoardVersion/" + version + "/CheckForUpdates"; return _restCommandProcessor.Get(_accountAuth, resource); From 7cf82f38e6d9acd6fe7c0c325573c094669cdff8 Mon Sep 17 00:00:00 2001 From: David Neal Date: Mon, 20 Jul 2015 14:18:42 -0400 Subject: [PATCH 28/40] Updating usage of board version to long --- LeanKit.API.Client.Library/LeanKitIntegration.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LeanKit.API.Client.Library/LeanKitIntegration.cs b/LeanKit.API.Client.Library/LeanKitIntegration.cs index 9d90494..3e68cb2 100644 --- a/LeanKit.API.Client.Library/LeanKitIntegration.cs +++ b/LeanKit.API.Client.Library/LeanKitIntegration.cs @@ -143,7 +143,7 @@ private CheckForUpdatesLoopResult SetupCheckForUpdatesLoop() stopWatch.Stop(); //Now do the work - var checkResults = _api.CheckForUpdates(_board.Id, (int) _board.Version); + var checkResults = _api.CheckForUpdates(_board.Id, _board.Version); if (checkResults == null) continue; @@ -308,7 +308,7 @@ private CheckForUpdatesLoopResult SetupCheckForUpdatesLoop() return CheckForUpdatesLoopResult.Exit; } - private void ApplyBoardChanges(int boardVersion, IEnumerable affectedLanes) + private void ApplyBoardChanges(long boardVersion, IEnumerable affectedLanes) { _board.Version = boardVersion; From dcc16c338ff827cc59ae9146b9efc1996c696c6b Mon Sep 17 00:00:00 2001 From: David Neal Date: Mon, 20 Jul 2015 14:19:05 -0400 Subject: [PATCH 29/40] Bumping assembly version number --- .gitignore | 1 + LeanKit.API.Client.Library/LeanKit.API.Client.Library.csproj | 3 +++ LeanKit.API.Client.Library/Properties/AssemblyInfo.cs | 4 ++-- publish/LeanKit.API.Client.Library.dll.nuspec | 2 +- publish/readme.md | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 2097bf1..f3c80b6 100644 --- a/.gitignore +++ b/.gitignore @@ -220,3 +220,4 @@ pip-log.txt packages *.DotSettings +.vs \ No newline at end of file diff --git a/LeanKit.API.Client.Library/LeanKit.API.Client.Library.csproj b/LeanKit.API.Client.Library/LeanKit.API.Client.Library.csproj index e7f94f4..a0bbefb 100644 --- a/LeanKit.API.Client.Library/LeanKit.API.Client.Library.csproj +++ b/LeanKit.API.Client.Library/LeanKit.API.Client.Library.csproj @@ -132,6 +132,9 @@ + + copy /Y "$(TargetDir)$(ProjectName).dll" "$(SolutionDir)publish\lib\net40\$(ProjectName).dll" +