Skip to content

Commit 0c8ef0a

Browse files
author
Bhushankumar L
authored
Merge pull request #11 from bhushankumarl/development
Development
2 parents f0d069a + 1929c51 commit 0c8ef0a

File tree

8 files changed

+104
-25
lines changed

8 files changed

+104
-25
lines changed

README.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,8 @@ trello.setOauthToken('oauthToken');
4646
- Kindly validate test cases & linting before opening new PR.
4747

4848
## Do you need an expert?
49-
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)
50-
```
51-
Originally by [Bhushankumar Lilapara](https://github.com/bhushankumarl) (bhushankumar.lilapara@gmail.com).
52-
```
49+
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)
50+
Originally by [Bhushankumar L](mailto:bhushankumar.lilapara@gmail.com).
5351

5452
## Examples
5553

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

213+
#### Search Cards
214+
```
215+
Trello.board.searchCards('BOARD_ID').then(function (response) {
216+
console.log('response ', response);
217+
}).catch(function (error) {
218+
console.log('error', error);
219+
});
220+
```
221+
222+
#### Search Closed Cards
223+
```
224+
Trello.board.searchCardsFilter('BOARD_ID', 'closed').then(function (response) {
225+
console.log('response ', response);
226+
}).catch(function (error) {
227+
console.log('error', error);
228+
});
229+
```
230+
215231
#### Search Field Board
216232
```
217233
Trello.board.searchField('BOARD_ID', 'FIELD_NAME').then(function (response) {
@@ -676,4 +692,5 @@ Originally by [Bhushankumar Lilapara](https://github.com/bhushankumarl) (bhushan
676692
}).catch(function (error) {
677693
console.log('error', error);
678694
});
679-
```
695+
```
696+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
var apiKey = process.env.TRELLO_API_KEY || 'YOUR_API_KEY';
2+
var oauthToken = process.env.TRELLO_OAUTH_TOKEN || 'OAUTH_TOKEN';
3+
4+
var Trello = require('../../../lib/trello-node-api')(apiKey, oauthToken);
5+
6+
var boardRequest = function () {
7+
Trello.board.searchCards('BOARD_ID').then(function (response) {
8+
console.log('response ', response);
9+
}).catch(function (error) {
10+
console.log('error', error);
11+
});
12+
};
13+
14+
boardRequest();
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
var apiKey = process.env.TRELLO_API_KEY || 'YOUR_API_KEY';
2+
var oauthToken = process.env.TRELLO_OAUTH_TOKEN || 'OAUTH_TOKEN';
3+
4+
var Trello = require('../../../lib/trello-node-api')(apiKey, oauthToken);
5+
6+
var boardRequest = function () {
7+
Trello.board.searchCardsFilter('BOARD_ID', 'closed').then(function (response) {
8+
console.log('response ', response);
9+
}).catch(function (error) {
10+
console.log('error', error);
11+
});
12+
};
13+
14+
boardRequest();

index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ declare class TrelloBoard {
2626

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

29+
searchCardsFilter(boardId: string, filter: string): Promise<any>;
30+
2931
}
3032

3133
declare class TrelloCard {

lib/resources/Boards.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,11 @@ module.exports = TrelloResource.extend({
1414
method: 'GET',
1515
path: '/{id}/cards',
1616
urlParams: ['id']
17+
}),
18+
19+
searchCardsFilter: trelloMethod({
20+
method: 'GET',
21+
path: '/{id}/cards/{filter}',
22+
urlParams: ['id', 'filter']
1723
})
18-
});
24+
});

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "trello-node-api",
3-
"version": "0.0.6",
3+
"version": "0.0.7",
44
"description": "Trello Node API wrapper",
55
"keywords": [
66
"node-trello",
@@ -60,4 +60,4 @@
6060
"lint": "tsc index.d.ts",
6161
"test.mocha": "npm run lint; mocha -r ts-node/register test/**/*.spec.ts"
6262
}
63-
}
63+
}

test/intialize/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const CONFIG = {
2+
TRELLO_API_KEY: process.env.TRELLO_API_KEY || undefined,
3+
TRELLO_OAUTH_TOKEN: process.env.TRELLO_OAUTH_TOKEN || undefined
4+
};

test/resources/Board.spec.ts

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,32 @@
1-
const apiKey = process.env.TRELLO_API_KEY || 'YOUR_API_KEY';
2-
const oauthToken = process.env.TRELLO_OAUTH_TOKEN || 'OAUTH_TOKEN';
1+
import {CONFIG} from '../intialize';
2+
import * as TrelloNodeAPI from '../../lib/trello-node-api';
33

4-
import * as TrelloNodeAPI from 'trello-node-api';
4+
import * as chai from 'chai';
5+
6+
const expect = chai.expect;
7+
8+
const apiKey = CONFIG.TRELLO_API_KEY;
9+
const oauthToken = CONFIG.TRELLO_OAUTH_TOKEN;
510

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

13-
it('It should create the Board', async () => {
15+
let boardDocument: any = {};
16+
describe('Board', function () {
17+
18+
before(function () {
19+
expect(apiKey).to.be.a('string');
20+
expect(oauthToken).to.be.a('string');
21+
});
22+
23+
it('It should create the Board', async function () {
24+
const boardName = 'Auto generated board ' + new Date().getUTCMilliseconds();
1425
let data = {
15-
name: 'BOARD_NAME_1', // REQUIRED
26+
name: boardName, // REQUIRED
1627
defaultLabels: false,
1728
defaultLists: false,
18-
desc: 'Board description.',
19-
idOrganization: 'ORGANIZATION_ID',
29+
desc: 'This is test board. Here is the Board description.',
2030
keepFromSource: 'none',
2131
powerUps: 'all',
2232
prefs_permissionLevel: 'private',
@@ -28,13 +38,25 @@ describe('Board', () => {
2838
prefs_background: 'blue',
2939
prefs_cardAging: 'regular'
3040
};
31-
let response = await Trello.board.create(data).catch(error => {
32-
if (error) {
33-
console.log('error ', error);
34-
return;
35-
}
36-
});
37-
console.log('response', response);
41+
try {
42+
let response = await Trello.board.create(data);
43+
console.log('response', response);
44+
boardDocument = response;
45+
expect(response).to.be.a('object');
46+
} catch (error) {
47+
console.log('error ', error);
48+
expect(error).to.be.undefined;
49+
}
3850
});
3951

52+
it('It should delete the Board', async function () {
53+
try {
54+
let response = await Trello.board.del(boardDocument.id);
55+
console.log('response', response);
56+
expect(response).to.be.a('object');
57+
} catch (error) {
58+
console.log('error ', error);
59+
expect(error).to.be.undefined;
60+
}
61+
});
4062
});

0 commit comments

Comments
 (0)