Skip to content

Organizations TypeScript

BL edited this page Jun 8, 2018 · 2 revisions

Usage

export TRELLO_API_KEY=KEY
export TRELLO_OAUTH_TOKEN=TOKEN

Configuration

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);

Organization

Create Organization

    let data = {
        displayName: 'ORGANIZATION_NAME', // REQUIRED
        desc: 'Organization description',
        name: 'NAME',
        website: 'https://example.com'
    };
    let response;
    try {
        response = await Trello.organization.create(data)
    } catch (error) {
        if (error) {
            console.log('error ', error);
        }
    }
    console.log('response', response);

Search Organization

    let response;
    try {
        response = await Trello.organization.search('ORGANIZATION_ID');
    } catch (error) {
        if (error) {
            console.log('error ', error);
        }
    }
    console.log('response', response);

Search Field Organization

    let response;
    try {
        response = await Trello.organization.searchField('ORGANIZATION_ID', 'FIELD_NAME');
    } catch (error) {
        if (error) {
            console.log('error ', error);
        }
    }
    console.log('response', response);

Update Organization

    let id = 'ORGANIZATION_ID'; // REQUIRED
    let data = {
        name: 'or123',
        displayName: 'ORGANIZATION_DISPLAY_NAME',
        desc: 'Organization descriptions',
        website: 'https://example.com',
        prefs_associatedDomain: 'trello.com',
        prefs_externalMembersDisabled: false,
        prefs_googleAppsVersion: 1,
        prefs_boardVisibilityRestrict_org: 'none',
        prefs_boardVisibilityRestrict_private: 'none',
        prefs_boardVisibilityRestrict_public: 'none',
        prefs_orgInviteRestrict: '*.test.com',
        prefs_permissionLevel: 'public'
    };
    let response;
    try {
        response = await Trello.organization.update(id, data);
    } catch (error) {
        if (error) {
            console.log('error ', error);
        }
    }
    console.log('response', response);

Delete Organization

    let response;
    try {
        response = await Trello.organization.del('ORGANIZATION_ID');
    } catch (error) {
        if (error) {
            console.log('error ', error);
        }
    }
    console.log('response', response);