LeanKit Get Board (Built.io Flow Activity)
/**
* leankit-get-board.js
*
* @author Kurt Collins (twitter/github: @timesync)
*
* @platform Built.io Flow
*
* @description Node.js script to create an activity for the LeanKit Get A Board call.
* This method retrieves information about a single board, including all of the
* Board attributes, the Lanes within the Board and all the Cards within those
* lanes. It includes all the cards in the Backlog, but does not include the
* cards within the Archive. Cards within the Archive can be retrieved using the
* Archive API.
*
* @input
* accessToken: Authentication token.
* accountUrl: The account URL for your LeanKit account.
* boardId: The ID of the board you want to get.
*
* @output
* replyData: Array.
*/
/**
* Imports
*/
const request = require('request');
/**
* Module configuration variables
*/
const activityId = 'leankit-get-board'; // Activity ID
const activityLabel = 'LeanKit Get Board'; // Activity Label
const activityHelp = 'Retrieve information about a single board.'; // Help Text
const activityInputSchema = {
title: 'LeanKit Get Board',
type: 'object',
properties: {
accessToken: {
title: 'Access Token',
type: 'string',
description: 'Access Token',
propertyOrder: 1,
minLength: 1
},
accountUrl: {
title: 'Account URL',
type: 'string',
description: 'The account URL for your LeanKit account.',
propertyOrder: 2,
minLength: 1
},
boardId: {
title: 'Board ID',
type: 'string',
description: 'The ID of the board you want to get.',
propertyOrder: 3,
minLength: 1
}
}
};
const activityOutputSchema = {
title:'Output',
type: 'object',
properties: {
IconConfiguration: {
type: 'object',
title: 'IconConfiguration',
properties: {
'IconPathTemplate': {
type: 'string',
title: 'IconPathTemplate'
},
'AllowedIconImages': {
type: 'array',
title: 'AllowedIconImages',
items: {
title: 'items',
type: 'object',
properties: {
'Size': {
type: 'string',
title: 'Size'
},
'OutputFormat': {
type: 'string',
title: 'OutputFormat'
}
}
}
}
}
},
ParentCards: {
type: 'array',
title: 'ParentCards',
items: {
title: 'items',
type: 'object',
properties: {}
}
},
Id: {
type: 'number',
title: 'Id',
},
Title: {
type: 'string',
title: 'Title'
},
Description: {
type: 'string',
title: 'Description'
},
Version: {
type: 'number',
title: 'Version',
},
Active: {
type: 'boolean',
title: 'Active',
},
OrganizationId: {
type: 'number',
title: 'OrganizationId',
},
OrganizationActivities: {
type: 'array',
title: 'OrganizationActivities',
items: {
title: 'items',
type: 'object',
properties: {}
}
},
Lanes: {
type: 'array',
title: 'Lanes',
items: {
title: 'items',
type: 'object',
properties: {
Id: {
type: 'number',
title: 'Id',
},
Description: {
type: 'string',
title: 'Description'
},
Index: {
type: 'number',
title: 'Index',
},
Active: {
type: 'boolean',
title: 'Active',
},
Title: {
type: 'string',
title: 'Title'
},
CardLimit: {
type: 'number',
title: 'CardLimit',
},
ClassType: {
type: 'number',
title: 'ClassType',
},
Type: {
type: 'number',
title: 'Type',
},
ActivityId: {
type: 'number',
title: 'ActivityId',
},
ActivityName: {
type: 'string',
title: 'ActivityName'
},
CardContextId: {
type: 'number',
title: 'CardContextId',
},
Width: {
type: 'number',
title: 'Width',
},
ParentLaneId: {
type: 'number',
title: 'ParentLaneId',
},
Cards: {
type: 'array',
title: 'Cards',
items: {
type: 'object',
title: 'items',
properties: {
SystemType: {
type: 'string',
title: 'SystemType'
},
LaneId: {
type: 'number',
title: 'LaneId',
},
Title: {
type: 'string',
title: 'Title'
},
Description: {
type: 'string',
title: 'Description'
},
Type: {
type: 'object',
title: 'Type',
properties: {
Id: {
type: 'number',
title: 'Id'
}
}
},
TypeId: {
type: 'number',
title: 'TypeId',
},
Priority: {
type: 'number',
title: 'Priority',
},
PriorityText: {
type: 'string',
title: 'PriorityText'
},
TypeName: {
type: 'string',
title: 'TypeName'
},
TypeIconPath: {
type: 'string',
title: 'TypeIconPath'
},
TypeColorHex: {
type: 'string',
title: 'TypeColorHex'
},
Size: {
type: 'number',
title: 'Size'
},
Active: {
type: 'boolean',
title: 'Active'
},
Color: {
type: 'string',
title: 'Color'
},
Version: {
type: 'number',
title: 'Version'
},
AssignedUsers: {
type: 'array',
title: 'AssignedUsers',
items: {
title: 'items',
type: 'object',
properties: {}
}
},
CardDrillThroughBoards: {
type: 'array',
title: 'CardDrillThroughBoards',
items: {
title: 'items',
type: 'object',
properties: {}
}
},
CardContexts: {
type: 'array',
title: 'CardContexts',
items: {
type: 'object',
title: 'items',
properties: {
TaskBoardId: {
type: 'number',
title: 'TaskBoardId'
},
Id: {
type: 'number',
title: 'Id'
},
Name: {
type: 'string',
title: 'Name'
},
ProgressPercentage: {
type: 'number',
title: 'ProgressPercentage'
},
TotalCards: {
type: 'number',
title: 'TotalCards'
},
TotalSize: {
type: 'number',
title: 'TotalSize'
},
CompletedCardCount: {
type: 'number',
title: 'CompletedCardCount'
},
CompletedCardSize: {
type: 'number',
title: 'CompletedCardSize'
},
}
}
},
IsBlocked: {
type: 'boolean',
title: 'IsBlocked'
},
BlockReason: {
type: 'string',
title: 'BlockReason'
},
BlockStateChangeDate: {
type: 'string',
title: 'BlockStateChangeDate'
},
Index: {
type: 'number',
title: 'Index'
},
DueDate: {
type: 'string',
title: 'DueDate'
},
StartDate: {
type: 'string',
title: 'StartDate'
},
ExternalSystemName: {
type: 'string',
title: 'ExternalSystemName'
},
ExternalSystemURL: {
type: 'string',
title: 'ExternalSystemURL'
},
ExternalCardID: {
type: 'string',
title: 'ExternalCardID'
},
Tags: {
type: 'string',
title: 'Tags'
},
CountOfOldCards: {
type: 'number',
title: 'CountOfOldCards'
},
LastMove: {
type: 'string',
title: 'LastMove'
},
LastActivity: {
type: 'string',
title: 'LastActivity'
},
DateArchived: {
type: 'string',
title: 'DateArchived'
},
LastComment: {
type: 'string',
title: 'LastComment'
},
CommentsCount: {
type: 'number',
title: 'CommentsCount'
},
LastAttachment: {
type: 'string',
title: 'LastAttachment'
},
AttachmentsCount: {
type: 'number',
title: 'AttachmentsCount'
},
AssignedUserName: {
type: 'string',
title: 'AssignedUserName'
},
AssignedUserId: {
type: 'number',
title: 'AssignedUserId'
},
AssignedUserIds: {
type: 'array',
title: 'AssignedUserIds',
items: {
type: 'number',
title: 'items',
properties: {}
}
},
GravatarLink: {
type: 'string',
title: 'GravatarLink'
},
SmallGravatarLink: {
type: 'string',
title: 'SmallGravatarLink'
},
CardDrillThroughBoardsIds: {
type: 'array',
title: 'CardDrillThroughBoardsIds',
items: {
type: 'number',
title: 'items',
}
},
Id: {
type: 'number',
title: 'Id'
},
DrillThroughBoardId: {
type: 'number',
title: 'DrillThroughBoardId'
},
HasDrillThroughBoard: {
type: 'boolean',
title: 'HasDrillThroughBoard'
},
HasMultipleDrillThroughBoards: {
type: 'boolean',
title: 'HasMultipleDrillThroughBoards'
},
DrillThroughStatistics: {
type: 'number',
title: 'DrillThroughStatistics'
},
DrillThroughCompletionPercent: {
type: 'number',
title: 'DrillThroughCompletionPercent'
},
DrillThroughProgressTotal: {
type: 'number',
title: 'DrillThroughProgressTotal'
},
DrillThroughProgressComplete: {
type: 'number',
title: 'DrillThroughProgressComplete'
},
DrillThroughProgressSizeComplete: {
type: 'number',
title: 'DrillThroughProgressSizeComplete'
},
DrillThroughProgressSizeTotal: {
type: 'number',
title: 'DrillThroughProgressSizeTotal'
},
ClassOfServiceId: {
type: 'number',
title: 'ClassOfServiceId'
},
ClassOfServiceTitle: {
type: 'string',
title: 'ClassOfServiceTitle'
},
ClassOfServiceIconPath: {
type: 'string',
title: 'ClassOfServiceIconPath'
},
ClassOfServiceColorHex: {
type: 'string',
title: 'ClassOfServiceColorHex'
},
ClassOfServiceCustomIconName: {
type: 'string',
title: 'ClassOfServiceCustomIconName'
},
ClassOfServiceCustomIconColor: {
type: 'string',
title: 'ClassOfServiceCustomIconColor'
},
CardTypeIconColor: {
type: 'string',
title: 'CardTypeIconColor'
},
CardTypeIconName: {
type: 'string',
title: 'CardTypeIconName'
},
CurrentTaskBoardId: {
type: 'number',
title: 'CurrentTaskBoardId'
},
TaskBoardCompletionPercent: {
type: 'number',
title: 'TaskBoardCompletionPercent'
},
TaskBoardCompletedCardCount: {
type: 'number',
title: 'TaskBoardCompletedCardCount'
},
TaskBoardCompletedCardSize: {
type: 'number',
title: 'TaskBoardCompletedCardSize'
},
TaskBoardTotalCards: {
type: 'number',
title: 'TaskBoardTotalCards'
},
TaskBoardTotalSize: {
type: 'number',
title: 'TaskBoardTotalSize'
},
CurrentContext: {
type: 'string',
title: 'CurrentContext'
},
ParentCardId: {
type: 'number',
title: 'ParentCardId'
},
ParentCardIds: {
type: 'array',
title: 'ParentCardIds',
items: {
type: 'number',
title: 'items',
}
}
}
}
},
Orientation: {
type: 'number',
title: 'Orientation'
},
TaskBoardId: {
type: 'number',
title: 'TaskBoardId'
},
ChildLaneIds: {
type: 'array',
title: 'ChildLaneIds',
items: {
type: 'number',
title: 'items',
}
},
SiblingLaneIds: {
type: 'array',
title: 'SiblingLaneIds',
items: {
type: 'number',
title: 'items',
}
},
IsDrillthroughDoneLane: {
type: 'boolean',
title: 'IsDrillthroughDoneLane'
},
IsDefaultDropLane: {
type: 'boolean',
title: 'IsDefaultDropLane'
},
LaneState: {
type: 'boolean',
title: 'LaneState'
},
}
}
},
BoardUsers: {
type: 'array',
title: 'BoardUsers',
items: {
type: 'object',
title: 'items',
properties: {
Id: {
type: 'number',
title: 'Id'
},
FullName: {
type: 'string',
title: 'FullName'
},
UserName: {
type: 'string',
title: 'UserName'
},
Role: {
type: 'number',
title: 'Role'
},
WIP: {
type: 'number',
title: 'WIP'
},
Enabled: {
type: 'boolean',
title: 'Enabled'
},
IsAccountOwner: {
type: 'boolean',
title: 'IsAccountOwner'
},
IsDeleted: {
type: 'boolean',
title: 'IsDeleted'
},
GravatarFeed: {
type: 'string',
title: 'GravatarFeed'
},
GravatarLink: {
type: 'string',
title: 'GravatarLink'
},
EmailAddress: {
type: 'string',
title: 'EmailAddress'
},
DateFormat: {
type: 'string',
title: 'DateFormat'
},
Settings: {
type: 'string',
title: 'Settings'
},
RoleName: {
type: 'string',
title: 'RoleName'
},
}
}
},
Backlog: {
type: 'array',
title: 'Backlog',
items: {
title: 'items',
type: 'object',
properties: {
Id: {
type: 'number',
title: 'Id'
},
Description: {
type: 'string',
title: 'Description'
},
Index: {
type: 'number',
title: 'Index'
},
Active: {
type: 'boolean',
title: 'Active'
},
Title: {
type: 'string',
title: 'Title'
},
CardLimit: {
type: 'number',
title: 'CardLimit'
},
ClassType: {
type: 'number',
title: 'ClassType'
},
Type: {
type: 'number',
title: 'Type'
},
ActivityId: {
type: 'number',
title: 'ActivityId'
},
ActivityName: {
type: 'string',
title: 'ActivityName'
},
CardContextId: {
type: 'number',
title: 'CardContextId'
},
Width: {
type: 'number',
title: 'Width'
},
ParentLaneId: {
type: 'number',
title: 'ParentLaneId'
},
Cards: {
type: 'array',
title: 'Cards',
items: {
type: 'object',
title: 'items',
properties: {}
}
},
Orientation: {
type: 'number',
title: 'Orientation'
},
TaskBoardId: {
type: 'number',
title: 'TaskBoardId'
},
ChildLaneIds: {
type: 'array',
title: 'ChildLaneIds',
items: {
type: 'number',
title: 'items',
}
},
SiblingLaneIds: {
type: 'array',
title: 'SiblingLaneIds',
items: {
type: 'number',
title: 'items',
}
},
IsDrillthroughDoneLane: {
type: 'boolean',
title: 'IsDrillthroughDoneLane'
},
IsDefaultDropLane: {
type: 'boolean',
title: 'IsDefaultDropLane'
},
LaneState: {
type: 'string',
title: 'LaneState'
},
}
}
},
Archive: {
type: 'array',
title: 'Archive',
items: {
title: 'items',
type: 'object',
properties: {
Id: {
type: 'number',
title: 'Id'
},
Description: {
type: 'string',
title: 'Description'
},
Index: {
type: 'number',
title: 'Index'
},
Active: {
type: 'boolean',
title: 'Active'
},
Title: {
type: 'string',
title: 'Title'
},
CardLimit: {
type: 'number',
title: 'CardLimit'
},
ClassType: {
type: 'number',
title: 'ClassType'
},
Type: {
type: 'number',
title: 'Type'
},
ActivityId: {
type: 'number',
title: 'ActivityId'
},
ActivityName: {
type: 'string',
title: 'ActivityName'
},
CardContextId: {
type: 'number',
title: 'CardContextId'
},
Width: {
type: 'number',
title: 'Width'
},
ParentLaneId: {
type: 'number',
title: 'ParentLaneId'
},
Cards: {
type: 'array',
title: 'Cards',
items: {
type: 'object',
title: 'items',
properties: {}
}
},
Orientation: {
type: 'number',
title: 'Orientation'
},
TaskBoardId: {
type: 'number',
title: 'TaskBoardId'
},
ChildLaneIds: {
type: 'array',
title: 'ChildLaneIds',
items: {
type: 'number',
title: 'items',
}
},
SiblingLaneIds: {
type: 'array',
title: 'SiblingLaneIds',
items: {
type: 'number',
title: 'items',
}
},
IsDrillthroughDoneLane: {
type: 'boolean',
title: 'IsDrillthroughDoneLane'
},
IsDefaultDropLane: {
type: 'boolean',
title: 'IsDefaultDropLane'
},
LaneState: {
type: 'string',
title: 'LaneState'
},
}
}
},
ClassesOfService: {
type: 'object',
title: 'ClassesOfService',
properties: {
Id: {
type: 'number',
title: 'Id'
},
Title: {
type: 'string',
title: 'Title'
},
Policy: {
type: 'string',
title: 'Policy'
},
IconPath: {
type: 'string',
title: 'IconPath'
},
ColorHex: {
type: 'string',
title: 'ColorHex'
},
CustomIconName: {
type: 'string',
title: 'CustomIconName'
},
CustomIconColor: {
type: 'string',
title: 'CustomIconColor'
},
UseColor: {
type: 'boolean',
title: 'UseColor'
},
}
},
CurrentUserRole: {
type: 'number',
title: 'CurrentUserRole'
},
CardTypes: {
type: 'array',
title: 'CardTypes',
items: {
type: 'object',
title: 'items',
properties: {
Id: {
type: 'number',
title: 'Id'
},
Name: {
type: 'string',
title: 'Name'
},
ColorHex: {
type: 'string',
title: 'ColorHex'
},
IsDefault: {
type: 'boolean',
title: 'IsDefault'
},
IconPath: {
type: 'string',
title: 'IconPath'
},
IsCardType: {
type: 'boolean',
title: 'IsCardType'
},
IsTaskType: {
type: 'boolean',
title: 'IsTaskType'
},
IsDefaultTaskType: {
type: 'boolean',
title: 'IsDefaultTaskType'
},
IconName: {
type: 'string',
title: 'IconName'
},
IconColor: {
type: 'string',
title: 'IconColor'
},
}
}
},
ClassOfServiceEnabled: {
type: 'boolean',
title: 'ClassOfServiceEnabled'
},
CardColorField: {
type: 'string',
title: 'CardColorField'
},
IsCardIdEnabled: {
type: 'boolean',
title: 'IsCardIdEnabled'
},
IsHeaderEnabled: {
type: 'boolean',
title: 'IsHeaderEnabled'
},
IsPrefixEnabled: {
type: 'boolean',
title: 'IsPrefixEnabled'
},
IsPrefixIncludedInHyperlink: {
type: 'boolean',
title: 'IsPrefixIncludedInHyperlink'
},
Prefix: {
type: 'string',
title: 'Prefix'
},
IsHyperlinkEnabled: {
type: 'boolean',
title: 'IsHyperlinkEnabled'
},
Format: {
type: 'string',
title: 'Format'
},
AllowMultiUserAssignments: {
type: 'boolean',
title: 'AllowMultiUserAssignments'
},
ArchiveCardDays: {
type: 'number',
title: 'ArchiveCardDays'
},
EnableDrillThroughBoards: {
type: 'boolean',
title: 'EnableDrillThroughBoards'
},
EnableMultipleDrillThroughBoards: {
type: 'boolean',
title: 'EnableMultipleDrillThroughBoards'
},
EnableDrillThroughDoneLane: {
type: 'boolean',
title: 'EnableDrillThroughDoneLane'
},
AllowMoveCardsBetweenBoards: {
type: 'boolean',
title: 'AllowMoveCardsBetweenBoards'
},
SubscribeUsersToAssignedCardsByDefault: {
type: 'boolean',
title: 'SubscribeUsersToAssignedCardsByDefault'
},
AllowAttachments: {
type: 'boolean',
title: 'AllowAttachments'
},
AllowComments: {
type: 'boolean',
title: 'AllowComments'
},
AllowHorizontalSplitInBoardEdit: {
type: 'boolean',
title: 'AllowHorizontalSplitInBoardEdit'
},
MaxFileSize: {
type: 'number',
title: 'MaxFileSize'
},
DisallowedFileExtensions: {
type: 'string',
title: 'DisallowedFileExtensions'
},
EnableTaskBoards: {
type: 'boolean',
title: 'EnableTaskBoards'
},
AllowSeparateCardAndTaskTypes: {
type: 'boolean',
title: 'AllowSeparateCardAndTaskTypes'
},
AllowAddCardTypes: {
type: 'boolean',
title: 'AllowAddCardTypes'
},
BaseWipOnCardSize: {
type: 'boolean',
title: 'BaseWipOnCardSize'
},
AllowUsersToDeleteCards: {
type: 'boolean',
title: 'AllowUsersToDeleteCards'
},
ExcludeCompletedAndArchiveViolations: {
type: 'boolean',
title: 'ExcludeCompletedAndArchiveViolations'
},
IsWelcome: {
type: 'boolean',
title: 'IsWelcome'
},
IsShared: {
type: 'boolean',
title: 'IsShared'
},
SharedBoardRole: {
type: 'number',
title: 'SharedBoardRole'
},
CustomBoardMoniker: {
type: 'string',
title: 'CustomBoardMoniker'
},
TopLevelLaneIds: {
type: 'array',
title: 'TopLevelLaneIds',
items: {
type: 'number',
title: 'items',
}
},
BacklogTopLevelLaneId: {
type: 'number',
title: 'BacklogTopLevelLaneId'
},
ArchiveTopLevelLaneId: {
type: 'number',
title: 'ArchiveTopLevelLaneId'
},
DefaultDropLaneId: {
type: 'number',
title: 'DefaultDropLaneId'
},
HasCustomFields: {
type: 'boolean',
title: 'HasCustomFields'
},
CardContexts: {
type: 'array',
title: 'CardContexts',
items: {
type: 'object',
title: 'items',
properties: {
Id: {
type: 'number',
title: 'Id'
},
Name: {
type: 'string',
title: 'Name'
},
IsDefault: {
type: 'boolean',
title: 'IsDefault'
},
IsMaster: {
type: 'boolean',
title: 'IsMaster'
}
}
}
},
BoardCreator: {
type: 'object',
title: 'BoardCreator',
properties: {}
},
AvailableTags: {
type: 'string',
title: 'AvailableTags'
},
IsAutoIncrementCardIdEnabled: {
type: 'boolean',
title: 'IsAutoIncrementCardIdEnabled'
},
IsExternalUrlEnabled: {
type: 'boolean',
title: 'IsExternalUrlEnabled'
},
IsPermalinkEnabled: {
type: 'boolean',
title: 'IsPermalinkEnabled'
},
CustomIconFieldLabel: {
type: 'string',
title: 'CustomIconFieldLabel'
},
EnableLanePolicies: {
type: 'boolean',
title: 'EnableLanePolicies'
},
EnableLaneSubscription: {
type: 'boolean',
title: 'EnableLaneSubscription'
},
EnableCardHistory: {
type: 'boolean',
title: 'EnableCardHistory'
},
EnableWipLimit: {
type: 'boolean',
title: 'EnableWipLimit'
}
}
};
/**
* executeActivity()
*
* @description This function performs the API call and any necessary manipulation.
*/
function executeActivity(input, output) {
// URL for the API call
const apiUrl = '/kanban/api/boards/';
// Go on and perform the request.
request({
method: 'GET',
headers: {
'Authorization': 'Basic ' + input.accessToken,
'Content-Type': 'application/json'
},
url: input.accountUrl + apiUrl + input.boardId
}, function optionalCallback(err, response, body) {
if (err) {
return output(err);
} else {
var returnedResponse = body;
if (response.statusCode && response.statusCode >= 200 && response.statusCode < 400) {
if (typeof(returnedResponse) === 'string') {
returnedResponse = JSON.parse(body).ReplyData[0];
}
return output(null, returnedResponse);
}
return output(returnedResponse);
}
});
}
/**
* Built.io activity creation happens here.
*/
module.exports = function() {
this.id = activityId;
this.label = activityLabel;
this.help = activityHelp;
this.input = activityInputSchema;
this.output = activityOutputSchema;
this.execute = executeActivity;
};