diff --git a/README.md b/README.md index 227d7af..a4d9a45 100644 --- a/README.md +++ b/README.md @@ -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! :) @@ -23,4 +23,15 @@ First, generate your Trello application key [like this](https://trello.com/card/ console.log('Added card:', trelloCard); } }); -``` \ No newline at end of file +``` + +## History + +### 0.3.0 + +* Project `trello_ex` merged again with original project `trello` +* Using 'restler' again + +### 0.2.0 + +* `getBoards` added \ No newline at end of file diff --git a/main.js b/main.js index 7543d1c..7403e33 100644 --- a/main.js +++ b/main.js @@ -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; @@ -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; @@ -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); }; @@ -132,5 +149,4 @@ Trello.prototype.deleteWebhook = function (webHookId, callback) { makeRequest(rest.del, this.uri + '/1/webhooks/' + webHookId, { query: query }, callback); }; - module.exports = Trello; \ No newline at end of file diff --git a/package.json b/package.json index 097c6c5..7c065fb 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,15 @@ { "name": "trello", - "version": "0.2.0", + "version": "0.3.0", "author": "Graeme Foster ", "description": "Do stuff with Trello", "contributors": [ "Brett Swift", - "Mike Beasley" + "Mike Beasley", + "Norbert Eder " ], "scripts": { - "test": "node_modules/mocha/bin/mocha" + "test": "node node_modules/mocha/bin/mocha" }, "main": "main.js", "repository": { diff --git a/test/spec.js b/test/spec.js index c364b01..227d0f9 100644 --- a/test/spec.js +++ b/test/spec.js @@ -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;