Deprecate old add* methods #118

Merged
fsmanuel merged 4 commits from deprecate/old-add-methods into master 2019-05-01 18:12:19 +00:00
2 changed files with 14 additions and 2 deletions

View File

@ -1,5 +1,6 @@
const Record = require('./record');
const ContributionSerializer = require('../serializers/contribution');
const deprecate = require('./utils/deprecate');
class Contribution extends Record {
get count () {
@ -34,7 +35,7 @@ class Contribution extends Record {
});
}
async addContribution (contributionAttr, callOptions = {}) {
async add (contributionAttr, callOptions = {}) {
const contribution = new ContributionSerializer(contributionAttr);
try { await contribution.validate(); }
@ -56,6 +57,11 @@ class Contribution extends Record {
return this.functions.add(...contribution, callOptions);
});
}
addContribution () {
deprecate('The function `addContribution()` is deprecated and will be removed in the next major version. Use `add()` instead');
return this.add(...arguments);
}
}
module.exports = Contribution;

View File

@ -1,5 +1,6 @@
const Record = require('./record');
const ContributionSerializer = require('../serializers/contribution');
const deprecate = require('./utils/deprecate');
class Proposal extends Record {
get count () {
@ -13,7 +14,7 @@ class Proposal extends Record {
});
}
async addProposal (proposalAttr, callOptions = {}) {
async add (proposalAttr, callOptions = {}) {
const contribution = new ContributionSerializer(proposalAttr);
try { await contribution.validate(); }
@ -35,6 +36,11 @@ class Proposal extends Record {
return this.functions.addProposal(...proposal, callOptions);
});
}
addProposal () {
deprecate('The function `addProposal()` is deprecated and will be removed in the next major version. Use `add()` instead');
return this.add(...arguments);
}
}
module.exports = Proposal;