Skip to content

Commit

Permalink
Merge pull request #11 from bhushankumarl/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
Bhushankumar L authored Dec 29, 2018
2 parents f0d069a + 1929c51 commit 0c8ef0a
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 25 deletions.
27 changes: 22 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,8 @@ trello.setOauthToken('oauthToken');
- Kindly validate test cases & linting before opening new PR.

## Do you need an expert?
Are you finding a developer for your word class product? If yes, please contact here. [Submit your project request here.](https://goo.gl/forms/UofdG5GY5iHMoUWg2)
```
Originally by [Bhushankumar Lilapara](https://github.com/bhushankumarl) ([email protected]).
```
Are you finding a developer for your world-class product? If yes, please contact here. [Submit your project request here.](https://goo.gl/forms/UofdG5GY5iHMoUWg2)
Originally by [Bhushankumar L](mailto:[email protected]).

## Examples

Expand Down Expand Up @@ -212,6 +210,24 @@ Originally by [Bhushankumar Lilapara](https://github.com/bhushankumarl) (bhushan
});
```

#### Search Cards
```
Trello.board.searchCards('BOARD_ID').then(function (response) {
console.log('response ', response);
}).catch(function (error) {
console.log('error', error);
});
```

#### Search Closed Cards
```
Trello.board.searchCardsFilter('BOARD_ID', 'closed').then(function (response) {
console.log('response ', response);
}).catch(function (error) {
console.log('error', error);
});
```

#### Search Field Board
```
Trello.board.searchField('BOARD_ID', 'FIELD_NAME').then(function (response) {
Expand Down Expand Up @@ -676,4 +692,5 @@ Originally by [Bhushankumar Lilapara](https://github.com/bhushankumarl) (bhushan
}).catch(function (error) {
console.log('error', error);
});
```
```

14 changes: 14 additions & 0 deletions examples/javascript/boards/searchCards.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var apiKey = process.env.TRELLO_API_KEY || 'YOUR_API_KEY';
var oauthToken = process.env.TRELLO_OAUTH_TOKEN || 'OAUTH_TOKEN';

var Trello = require('../../../lib/trello-node-api')(apiKey, oauthToken);

var boardRequest = function () {
Trello.board.searchCards('BOARD_ID').then(function (response) {
console.log('response ', response);
}).catch(function (error) {
console.log('error', error);
});
};

boardRequest();
14 changes: 14 additions & 0 deletions examples/javascript/boards/searchClosedCards.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var apiKey = process.env.TRELLO_API_KEY || 'YOUR_API_KEY';
var oauthToken = process.env.TRELLO_OAUTH_TOKEN || 'OAUTH_TOKEN';

var Trello = require('../../../lib/trello-node-api')(apiKey, oauthToken);

var boardRequest = function () {
Trello.board.searchCardsFilter('BOARD_ID', 'closed').then(function (response) {
console.log('response ', response);
}).catch(function (error) {
console.log('error', error);
});
};

boardRequest();
2 changes: 2 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ declare class TrelloBoard {

searchCards(boardId: string): Promise<any>;

searchCardsFilter(boardId: string, filter: string): Promise<any>;

}

declare class TrelloCard {
Expand Down
8 changes: 7 additions & 1 deletion lib/resources/Boards.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,11 @@ module.exports = TrelloResource.extend({
method: 'GET',
path: '/{id}/cards',
urlParams: ['id']
}),

searchCardsFilter: trelloMethod({
method: 'GET',
path: '/{id}/cards/{filter}',
urlParams: ['id', 'filter']
})
});
});
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "trello-node-api",
"version": "0.0.6",
"version": "0.0.7",
"description": "Trello Node API wrapper",
"keywords": [
"node-trello",
Expand Down Expand Up @@ -60,4 +60,4 @@
"lint": "tsc index.d.ts",
"test.mocha": "npm run lint; mocha -r ts-node/register test/**/*.spec.ts"
}
}
}
4 changes: 4 additions & 0 deletions test/intialize/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const CONFIG = {
TRELLO_API_KEY: process.env.TRELLO_API_KEY || undefined,
TRELLO_OAUTH_TOKEN: process.env.TRELLO_OAUTH_TOKEN || undefined
};
56 changes: 39 additions & 17 deletions test/resources/Board.spec.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
const apiKey = process.env.TRELLO_API_KEY || 'YOUR_API_KEY';
const oauthToken = process.env.TRELLO_OAUTH_TOKEN || 'OAUTH_TOKEN';
import {CONFIG} from '../intialize';
import * as TrelloNodeAPI from '../../lib/trello-node-api';

import * as TrelloNodeAPI from 'trello-node-api';
import * as chai from 'chai';

const expect = chai.expect;

const apiKey = CONFIG.TRELLO_API_KEY;
const oauthToken = CONFIG.TRELLO_OAUTH_TOKEN;

const Trello = new TrelloNodeAPI();
Trello.setApiKey(apiKey);
Trello.setOauthToken(oauthToken);
import {mocha} from 'mocha'
/* tslint:disable:no-string-literal */
describe('Board', () => {

it('It should create the Board', async () => {
let boardDocument: any = {};
describe('Board', function () {

before(function () {
expect(apiKey).to.be.a('string');
expect(oauthToken).to.be.a('string');
});

it('It should create the Board', async function () {
const boardName = 'Auto generated board ' + new Date().getUTCMilliseconds();
let data = {
name: 'BOARD_NAME_1', // REQUIRED
name: boardName, // REQUIRED
defaultLabels: false,
defaultLists: false,
desc: 'Board description.',
idOrganization: 'ORGANIZATION_ID',
desc: 'This is test board. Here is the Board description.',
keepFromSource: 'none',
powerUps: 'all',
prefs_permissionLevel: 'private',
Expand All @@ -28,13 +38,25 @@ describe('Board', () => {
prefs_background: 'blue',
prefs_cardAging: 'regular'
};
let response = await Trello.board.create(data).catch(error => {
if (error) {
console.log('error ', error);
return;
}
});
console.log('response', response);
try {
let response = await Trello.board.create(data);
console.log('response', response);
boardDocument = response;
expect(response).to.be.a('object');
} catch (error) {
console.log('error ', error);
expect(error).to.be.undefined;
}
});

it('It should delete the Board', async function () {
try {
let response = await Trello.board.del(boardDocument.id);
console.log('response', response);
expect(response).to.be.a('object');
} catch (error) {
console.log('error ', error);
expect(error).to.be.undefined;
}
});
});

0 comments on commit 0c8ef0a

Please sign in to comment.