-
-
Notifications
You must be signed in to change notification settings - Fork 25
Boards TypeScript
BL edited this page Jun 8, 2018
·
2 revisions
export TRELLO_API_KEY=KEY
export TRELLO_OAUTH_TOKEN=TOKEN
Set your Trello Api Key and Trello Auth Token.
import * as TrelloNodeAPI from 'trello-node-api';
const Trello = new TrelloNodeAPI();
Trello.setApiKey(apiKey);
Trello.setOauthToken(oauthToken);
let data = {
name: 'BOARD_NAME', // REQUIRED
defaultLabels: false,
defaultLists: false,
desc: 'Board description.',
idOrganization: 'ORGANIZATION_ID',
idBoardSource: 'BOARD_ID',
keepFromSource: 'none',
powerUps: 'all',
prefs_permissionLevel: 'private',
prefs_voting: 'disabled',
prefs_comments: 'members',
prefs_invitations: 'members',
prefs_selfJoin: true,
prefs_cardCovers: true,
prefs_background: 'blue',
prefs_cardAging: 'regular'
};
let response;
try {
response = await Trello.board.create(data);
} catch (error) {
if (error) {
console.log('error ', error);
}
}
console.log('response', response);
let response;
try {
response = await Trello.board.search('BOARD_ID');
} catch (error) {
if (error) {
console.log('error ', error);
}
}
console.log('response', response);
let response;
try {
response = await Trello.board.searchField('BOARD_ID', 'FIELD_NAME');
} catch (error) {
if (error) {
console.log('error ', error);
}
}
console.log('response', response);
let response;
try {
response = await Trello.board.searchCards('BOARD_ID');
} catch (error) {
if (error) {
console.log('error ', error);
}
}
console.log('response', response);
let id = 'BOARD_ID'; // REQUIRED
let data = {
name: 'BOARD',
desc: 'Board descriptions',
closed: false,
subscribed: false,
idOrganization: 'ORGANIZATION_ID',
prefs_permissionLevel: 'private',
prefs_selfJoin: true,
prefs_cardCovers: true,
prefs_invitations: 'members',
prefs_voting: 'disabled',
prefs_comments: 'members',
prefs_background: 'blue',
prefs_cardAging: 'regular',
prefs_calendarFeedEnabled: false,
labelNames_green: 'Test Label 1',
labelNames_yellow: 'Test Label 2',
labelNames_orange: 'Test Label 3',
labelNames_red: 'Test Label 4',
labelNames_purple: 'Test Label 5',
labelNames_blue: 'Test Label 6'
};
let response;
try {
response = await Trello.board.update(id, data);
} catch (error) {
if (error) {
console.log('error ', error);
}
}
console.log('response', response);
let response;
try {
response = await Trello.board.del('BOARD_ID');
} catch (error) {
if (error) {
console.log('error ', error);
}
}
console.log('response', response);