Skip to content

Commit

Permalink
Merge pull request #8 from devtyr/master
Browse files Browse the repository at this point in the history
Features from trello_ex back to original project
  • Loading branch information
Norbert Eder committed Oct 23, 2014
2 parents ef0d2d2 + 87de8ee commit a2038ac
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 6 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Trello
# trello
## A simple asynchronous client for [Trello](http://www.trello.com)

This is a wrapper for some of the Trello HTTP API. Please feel free to add any other pieces you need! :)
Expand All @@ -23,4 +23,15 @@ First, generate your Trello application key [like this](https://trello.com/card/
console.log('Added card:', trelloCard);
}
});
```
```

## History

### 0.3.0

* Project `trello_ex` merged again with original project `trello`
* Using 'restler' again

### 0.2.0

* `getBoards` added
18 changes: 17 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ Trello.prototype.getCard = function (boardId, cardId, callback) {
makeRequest(rest.get, this.uri + '/1/boards/' + boardId + '/cards/' + cardId, {query: this.createQuery()}, callback);
};

Trello.prototype.getCardsForList = function(listId, actions, callback) {
var query = this.createQuery();
if (actions)
query.actions = actions;
makeRequest(rest.get, this.uri + '/1/lists/' + listId + '/cards', {query: query}, callback);
};

Trello.prototype.addListToBoard = function (boardId, name, callback) {
var query = this.createQuery();
query.name = name;
Expand All @@ -69,6 +76,10 @@ Trello.prototype.addMemberToCard = function (cardId, memberId, callback) {
makeRequest(rest.post, this.uri + '/1/cards/' + cardId + '/members', {query: query}, callback);
};

Trello.prototype.getBoards = function(memberId, callback) {
makeRequest(rest.get, this.uri + '/1/members/' + memberId + '/boards', {query: this.createQuery()}, callback);
};

Trello.prototype.addItemToChecklist = function (checkListId, name, callback) {
var query = this.createQuery();
query.name = name;
Expand Down Expand Up @@ -103,6 +114,12 @@ Trello.prototype.getListsOnBoard = function (boardId, callback) {
makeRequest(rest.get, this.uri + '/1/boards/' + boardId + '/lists', {query: this.createQuery()}, callback);
};

Trello.prototype.getListsOnBoardByFilter = function(boardId, filter, callback) {
var query = this.createQuery();
query.filter = filter;
makeRequest(rest.get, this.uri + '/1/boards/' + boardId + '/lists', {query: query}, callback);
};

Trello.prototype.getCardsOnBoard = function (boardId, callback) {
makeRequest(rest.get, this.uri + '/1/boards/' + boardId + '/cards', {query: this.createQuery()}, callback);
};
Expand Down Expand Up @@ -132,5 +149,4 @@ Trello.prototype.deleteWebhook = function (webHookId, callback) {
makeRequest(rest.del, this.uri + '/1/webhooks/' + webHookId, { query: query }, callback);
};


module.exports = Trello;
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"name": "trello",
"version": "0.2.0",
"version": "0.3.0",
"author": "Graeme Foster <[email protected]>",
"description": "Do stuff with Trello",
"contributors": [
"Brett Swift",
"Mike Beasley"
"Mike Beasley",
"Norbert Eder <[email protected]>"
],
"scripts": {
"test": "node_modules/mocha/bin/mocha"
"test": "node node_modules/mocha/bin/mocha"
},
"main": "main.js",
"repository": {
Expand Down
39 changes: 39 additions & 0 deletions test/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,45 @@ describe('Trello', function () {
});
});

describe('addCard', function() {
var query;
var post;

beforeEach(function (done) {
sinon.stub(restler, 'post', function (uri, options) {
return {on: function (event, callback) {
callback(null, null);
}};
});

trello.addCard('name', 'description', 'listId', function () {
query = restler.post.args[0][1].query;
post = restler.post;
done();
});
});

it('should post to https://api.trello.com/1/cards', function () {
post.should.have.been.calledWith('https://api.trello.com/1/cards');
});

it('should include the description', function () {
query.desc.should.equal('description');
});

it('should include the name', function () {
query.name.should.equal('name');
});

it('should include the list id', function () {
query.idList.should.equal('listId');
});

afterEach(function () {
restler.post.restore();
});
});

describe('addWebhook', function () {
var query;
var post;
Expand Down

0 comments on commit a2038ac

Please sign in to comment.