Skip to content
This repository was archived by the owner on May 8, 2020. It is now read-only.

LeanKit API C# Wrapper Library

License

Notifications You must be signed in to change notification settings

LeanKit/LeanKit.API.Client

Repository files navigation

LeanKit.API.Client.Library

DEPRECATION NOTICE

This library is deprecated and has been unsupported since January 25, 2019. Additionally, it uses the LeanKit v1 API which is also deprecated. Please use our v2 API directly instead of this library.

The LeanKit.API.Client.Library namespace provides a wrapper library designed to simplify the integration of external systems and utilities with your LeanKit account. This library exposes mechanisms that support both interactions with LeanKit as well as a strongly-typed object model representing the main entities within LeanKit.

This library exposes two primary ways to interact with LeanKit. These are the LeanKitClient and LeanKitIntegration classes. Both of these are explained below.

Installing with NuGet

NuGet is a Visual Studio extension that makes it easy to add, remove, and update libraries and tools in Visual Studio projects that use the .NET Framework. To learn more about NuGet, read the documentation.

To install the LeanKit API Client using NuGet, search for "LeanKit" in the Visual Studio NuGet Package Manager, or install directly using the Package Manager Console:

PM> Install-Package LeanKit.API.Client 

LeanKitClient

This class exposes methods that interact directly with LeanKit API. This class exposes the same methods exposed through the REST API, but hides the complexity of working with HTTP and JSON. This class allows you to send commands and queries to LeanKit using strongly-typed native objects. This class should be used if you are building a simple, stateless integration where you are not interested in interacting with a LeanKit Board over a period of time. This class should also be used if you cannot support a long-running service or process.

Connecting using LeanKitClient

varleanKitAuth=newLeanKitBasicAuth{Hostname="MyAccount",// Only the account name portion of the URL// e.g. https://MyAccount.leankit.comUsername="your-account-email-address",Password="your-account-password"};varapi=newLeanKitClientFactory().Create(leanKitAuth);

Connecting to alternate LeanKit domains

To connect to other LeanKit domains, such as LeanKit for Construction leankit.co, use the UrlTemplateOverride property.

varleanKitAuth=newLeanKitBasicAuth{Hostname="MyAccount",// Only the account name portion of the URL// e.g. https://MyAccount.leankit.comUsername="your-account-email-address",Password="your-account-password",UrlTemplateOverride="https://{0}.leankit.co"};varapi=newLeanKitClientFactory().Create(leanKitAuth);

Sample Helper Class in C#

usingSystem.Collections.Generic;usingSystem.Linq;usingLeanKit.API.Client.Library;usingLeanKit.API.Client.Library.TransferObjects;namespaceCardUpdateTest{publicclassLeanKitHelper{readonlyILeanKitApi_api;publicLeanKitHelper(stringhostName,stringemailAddress,stringpassword){_api=CreateApiClient(hostName,emailAddress,password);}privateILeanKitApiCreateApiClient(stringhostName,stringemailAddress,stringpassword){varauth=newLeanKitBasicAuth{Hostname=hostName,Username=emailAddress,Password=password};varapi=newLeanKitClientFactory().Create(auth);returnapi;}publicList<BoardListing>GetBoards(){varboards=_api.GetBoards().ToList();returnboards;}publicBoardGetBoard(longboardId){return_api.GetBoard(boardId);}}}

Sample Helper Class in Visual Basic .NET

ImportsLeanKit.API.Client.LibraryImportsLeanKit.API.Client.Library.TransferObjectsPublicClassLeanKitHelperDimReadOnly_apiAsILeanKitApiPublicSubNew(hostNameAsString,emailAddressAsString,passwordAsString)_api=CreateApiClient(hostName,emailAddress,password)EndSubPrivateFunctionCreateApiClient(hostNameAsString,emailAddressAsString,passwordAsString)AsILeanKitApiDimauthasLeanKitBasicAuthauth=NewLeanKitBasicAuth()auth.Hostname=hostNameauth.Username=emailAddressauth.Password=passwordDimapiasILeanKitApiapi=newLeanKitClientFactory().Create(auth)CreateApiClient=apiEndFunctionPublicFunctionGetBoards()AsList(OfBoardListing)DimboardsAsList(OfBoardListing)boards=_api.GetBoards()GetBoards=boardsEndFunctionPublicFunctionGetBoard(boardIdAsLong)AsBoardGetBoard=_api.GetBoard(boardId)EndFunctionEndClass

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.

This class is designed to retrieve and hold a reference to the board, and therefore should not be instantiated numerous times. Each instance will be associated to a single LeanKit Board. You will need to create an instance for each Board you wish to interact with.

Connecting using LeanKitIntegration

varleanKitAuth=newLeanKitBasicAuth{Hostname="MyAccount",// Only the account name portion of the URL// e.g. https://MyAccount.leankit.comUsername="your-account-email-address",Password="your-account-password"};// Use the board ID (number) of the board you wish to monitor// This ID can be found in the URL when you visit your LeanKit board// https://accountname.leankit.com/Boards/View/101varboardId=101;varintegration=newLeanKitIntegrationFactory().Create(boardId,leanKitAuth);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's app.config or web.config file to include a <defaultProxy> section.

<system.net> <defaultProxyuseDefaultCredentials="true"> <proxybypassonlocal="true"usesystemdefault="true" /> </defaultProxy> </system.net>

Or, if more granular control of the proxy is required, it could look something like:

<system.net> <defaultProxyenabled="true"useDefaultCredentials="false"> <proxyusesystemdefault="true"proxyaddress="http://192.168.1.10:3128"bypassonlocal="true" /> </defaultProxy> </system.net>

For more help, please review the .NET documentation on proxy configuration.

LeanKitClient Interface

IEnumerable<BoardListing>GetBoards();BoardGetBoard(longboardId);IEnumerable<Lane>GetBacklogLanes(longboardId);IEnumerable<HierarchicalLane>GetArchiveLanes(longboardId);IEnumerable<CardView>GetArchiveCards(longboardId);BoardGetNewerIfExists(longboardId,intversion);IEnumerable<BoardHistoryEvent>GetBoardHistorySince(longboardId,intversion);CardGetCard(longboardId,longcardId);CardGetCardByExternalId(longboardId,stringexternalCardId);BoardIdentifiersGetBoardIdentifiers(longboardId);longMoveCard(longboardId,longcardId,longtoLaneId,intposition,stringwipOverrideReason);longMoveCard(longboardId,longcardId,longtoLaneId,intposition);CardAddResultAddCard(longboardId,CardnewCard,stringwipOverrideReason);CardAddResultAddCard(longboardId,CardnewCard);IEnumerable<Card>AddCards(longboardId,IEnumerable<Card>newCards,stringwipOverrideReason);IEnumerable<Card>AddCards(longboardId,IEnumerable<Card>newCards);CardUpdateResultUpdateCard(longboardId,CardupdatedCard,stringwipOverrideReason);CardUpdateResultUpdateCard(longboardId,CardupdatedCard);CardsUpdateResultUpdateCards(longboardId,IEnumerable<Card>updatedCards,stringwipOverrideReason);CardsUpdateResultUpdateCards(longboardId,IEnumerable<Card>updatedCards);longDeleteCard(longboardId,longcardId);CardsDeleteResultDeleteCards(longboardId,IEnumerable<long>cardIds);BoardUpdatesCheckForUpdates(longboardId,intversion);IEnumerable<Comment>GetComments(longboardId,longcardId);intPostComment(longboardId,longcardId,Commentcomment);IEnumerable<CardEvent>GetCardHistory(longboardId,longcardId);IEnumerable<CardView>SearchCards(longboardId,SearchOptionsoptions);IEnumerable<Asset>GetAttachments(longboardId,longcardId);AssetGetAttachment(longboardId,longcardId,longattachmentId);longSaveAttachment(longboardId,longcardId,stringfileName,stringdescription,stringmimeType,byte[]fileBytes);longDeleteAttachment(longboardId,longcardId,longattachmentId);

LeanKitIntegration Interface

eventEventHandler<BoardStatusCheckedEventArgs> BoardStatusChecked;event EventHandler<BoardInfoRefreshedEventArgs> BoardInfoRefreshed;event EventHandler<BoardChangedEventArgs> BoardChanged;voidStartWatching();voidOnBoardStatusChecked(BoardStatusCheckedEventArgseventArgs);voidOnBoardRefresh(BoardInfoRefreshedEventArgseventArgs);voidOnBoardChanged(BoardChangedEventArgseventArgs);CardGetCard(longcardId);CardGetCardByExternalId(longboardId,stringexternalCardId);voidAddCard(Cardcard);voidAddCard(Cardcard,stringwipOverrideReason);voidUpdateCard(Cardcard);voidUpdateCard(Cardcard,stringwipOverrideReason);IEnumerable<Comment>GetComments(longcardId);voidPostComment(longcardId,Commentcomment);IEnumerable<CardEvent>GetCardHistory(longcardId);voidDeleteCard(longcardId);voidDeleteCards(IEnumerable<long>cardIds);IEnumerable<Lane>GetArchive();BoardGetBoard();voidMoveCard(longcardId,longtoLaneId,intposition,stringwipOverrideReason);voidMoveCard(longcardId,longtoLaneId,intposition);IEnumerable<CardView>SearchCards(SearchOptionsoptions);IEnumerable<Asset>GetAttachments(longcardId);AssetGetAttachment(longcardId,longattachmentId);voidSaveAttachment(longcardId,stringfileName,stringdescription,stringmimeType,byte[]fileBytes);voidDeleteAttachment(longcardId,longattachmentId);

BoardChangedEventArgs Properties

publicList<CardMoveEvent>MovedCards{get;set;}publicList<CardUpdateEvent>UpdatedCards{get;set;}publicList<CardAddEvent>AddedCards{get;set;}publicboolBoardStructureChanged{get;set;}publicBoardUpdatedBoard{get;set;}publicList<CardDeletedEvent>DeletedCards{get;set;}publicList<CardBlockedEvent>BlockedCards{get;set;}publicList<CardUnBlockedEvent>UnBlockedCards{get;set;}publicList<CardUserAssignmentEvent>AssignedUsers{get;set;}publicList<CardUserUnAssignmentEvent>UnAssignedUsers{get;set;}publicList<CommentPostedEvent>PostedComments{get;set;}publicList<WipOverrideEvent>WipOverrides{get;set;}publicList<UserWipOverrideEvent>UserWipOverrides{get;set;}publicboolBoardWasReloaded{get;set;}

Samples

Included are samples to help you understand how to use the stateless LeanKitClient or stateful LeanKitIntegration API libraries.

Questions?

Visit support.leankit.com.

Copyright

Copyright © 2013-2015 LeanKit Inc.

License

LeanKit Integration Service is licensed under MIT. Refer to license.txt for more information.

About

LeanKit API C# Wrapper Library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages