Skip to content

Commit

Permalink
Remove restler and replace it with needle
Browse files Browse the repository at this point in the history
  • Loading branch information
norberteder committed Nov 12, 2021
1 parent ff39b61 commit 160532a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 22 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ Everything that is not available as a function can be requested by calling `make

## History

### 0.12.0

* Replaced `restler` with `needle`

### 0.11.0

* Update optional fields
Expand Down
14 changes: 7 additions & 7 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require('es6-promise').polyfill();
var rest = require('restler');
var rest = require('needle');
var objectAssign = require('object-assign');

var minRequestDelay = 500;
Expand Down Expand Up @@ -82,7 +82,7 @@ Trello.prototype.makeRequest = function (requestMethod, path, options, callback)
'get': rest.get,
'put': rest.put,
'putjson' : rest.put,
'delete': rest.del
'delete': rest.delete
};

if (!methods[method]) {
Expand Down Expand Up @@ -212,7 +212,7 @@ Trello.prototype.addMemberToCard = function (cardId, memberId, callback) {
Trello.prototype.delMemberFromCard = function (cardId, memberId, callback) {
var query = this.createQuery();

return makeRequest(rest.del, this.uri + '/1/cards/' + cardId + '/members/' + memberId, {query: query}, callback);
return makeRequest(rest.delete, this.uri + '/1/cards/' + cardId + '/members/' + memberId, {query: query}, callback);
};

Trello.prototype.getBoards = function(memberId, callback) {
Expand Down Expand Up @@ -365,7 +365,7 @@ Trello.prototype.getCardsOnListWithExtraParams = function (listId, extraParams,
}

Trello.prototype.deleteCard = function (cardId, callback) {
return makeRequest(rest.del, this.uri + '/1/cards/' + cardId, {query: this.createQuery()}, callback);
return makeRequest(rest.delete, this.uri + '/1/cards/' + cardId, {query: this.createQuery()}, callback);
};

Trello.prototype.addWebhook = function (description, callbackUrl, idModel, callback) {
Expand All @@ -382,7 +382,7 @@ Trello.prototype.addWebhook = function (description, callbackUrl, idModel, callb
Trello.prototype.deleteWebhook = function (webHookId, callback) {
var query = this.createQuery();

return makeRequest(rest.del, this.uri + '/1/webhooks/' + webHookId, { query: query }, callback);
return makeRequest(rest.delete, this.uri + '/1/webhooks/' + webHookId, { query: query }, callback);
};

Trello.prototype.getLabelsForBoard = function(boardId, callback) {
Expand Down Expand Up @@ -410,7 +410,7 @@ Trello.prototype.addLabelOnBoard = function(boardId, name, color, callback) {
};

Trello.prototype.deleteLabel = function(labelId, callback) {
return makeRequest(rest.del, this.uri + '/1/labels/' + labelId, {query: this.createQuery()}, callback);
return makeRequest(rest.delete, this.uri + '/1/labels/' + labelId, {query: this.createQuery()}, callback);
};

Trello.prototype.addLabelToCard = function(cardId, labelId, callback) {
Expand All @@ -420,7 +420,7 @@ Trello.prototype.addLabelToCard = function(cardId, labelId, callback) {
};

Trello.prototype.deleteLabelFromCard = function(cardId, labelId, callback){
return makeRequest(rest.del, this.uri + '/1/cards/' + cardId + '/idLabels/'+labelId, {query: this.createQuery()}, callback);
return makeRequest(rest.delete, this.uri + '/1/cards/' + cardId + '/idLabels/'+labelId, {query: this.createQuery()}, callback);
};

Trello.prototype.updateCardPos = function(cardId, position, callback) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "trello",
"version": "0.11.0",
"version": "0.12.0",
"author": "Norbert Eder <[email protected]>",
"description": "This module provides an easy way to make requests to the Trello API.",
"contributors": [
Expand Down Expand Up @@ -52,7 +52,7 @@
"dependencies": {
"es6-promise": "^4.2.8",
"object-assign": "~4.1.0",
"restler": "^3.4.0"
"needle": "3.0.0"
},
"devDependencies": {
"mocha": "^9.1.3",
Expand Down
26 changes: 13 additions & 13 deletions test/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var fs = require('fs');
chai.should();
chai.use(sinonChai);

var restler = require('restler');
var restler = require('needle');
var Trello = require('../main');

describe('Trello', function () {
Expand Down Expand Up @@ -73,14 +73,14 @@ describe('Trello', function () {
});

it('should not throw error if a method passed is DELETE', function (done) {
sinon.stub(restler, 'del').callsFake(function (path, options) {
sinon.stub(restler, 'delete').callsFake(function (path, options) {
return {once: function (event, callback) {
callback(null, null);
}};
});

expect(trello.makeRequest.bind(trello, 'DELETE', 'somePath', {}, function () {})).to.not.throw(Error);
restler.del.restore();
restler.delete.restore();
done();
});

Expand Down Expand Up @@ -464,7 +464,7 @@ describe('Trello', function () {
var del;

beforeEach(function (done) {
sinon.stub(restler, 'del').callsFake(function (uri, options) {
sinon.stub(restler, 'delete').callsFake(function (uri, options) {
return {
once: function (event, callback) {
callback(null, null);
Expand All @@ -473,8 +473,8 @@ describe('Trello', function () {
});

trello.deleteWebhook('x1', function (result) {
query = restler.del.args[0][1].query;
del = restler.del;
query = restler.delete.args[0][1].query;
del = restler.delete;
done();
});

Expand All @@ -489,7 +489,7 @@ describe('Trello', function () {
});

afterEach(function () {
restler.del.restore();
restler.delete.restore();
});
});

Expand Down Expand Up @@ -817,14 +817,14 @@ describe('Trello', function () {
var del;

beforeEach(function (done) {
sinon.stub(restler, 'del').callsFake(function (uri, options) {
sinon.stub(restler, 'delete').callsFake(function (uri, options) {
return {once: function (event, callback) {
callback(null, null);
}};
});

trello.deleteLabel('labelId', function () {
del = restler.del;
del = restler.delete;
done();
});
});
Expand All @@ -834,7 +834,7 @@ describe('Trello', function () {
});

afterEach(function () {
restler.del.restore();
restler.delete.restore();
});
});

Expand Down Expand Up @@ -875,14 +875,14 @@ describe('Trello', function () {
var del;

beforeEach(function (done) {
sinon.stub(restler, 'del').callsFake(function (uri, options) {
sinon.stub(restler, 'delete').callsFake(function (uri, options) {
return {once: function (event, callback) {
callback(null, null);
}};
});

trello.deleteLabelFromCard('cardId', 'labelId', function () {
del = restler.del;
del = restler.delete;
done();
});
});
Expand All @@ -892,7 +892,7 @@ describe('Trello', function () {
});

afterEach(function () {
restler.del.restore();
restler.delete.restore();
});
});

Expand Down

0 comments on commit 160532a

Please sign in to comment.