Merge pull request #118 from 67P/deprecate/old-add-methods

Deprecate old add* methods
This commit is contained in:
bumi 2019-05-01 18:12:18 +00:00 committed by GitHub
commit b6ce9dcfc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View File

@ -1,5 +1,6 @@
const Record = require('./record'); const Record = require('./record');
const ContributionSerializer = require('../serializers/contribution'); const ContributionSerializer = require('../serializers/contribution');
const deprecate = require('./utils/deprecate');
class Contribution extends Record { class Contribution extends Record {
get count () { get count () {
@ -34,7 +35,7 @@ class Contribution extends Record {
}); });
} }
async addContribution (contributionAttr, callOptions = {}) { async add (contributionAttr, callOptions = {}) {
const contribution = new ContributionSerializer(contributionAttr); const contribution = new ContributionSerializer(contributionAttr);
try { await contribution.validate(); } try { await contribution.validate(); }
@ -56,6 +57,11 @@ class Contribution extends Record {
return this.functions.add(...contribution, callOptions); 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; module.exports = Contribution;

View File

@ -1,5 +1,6 @@
const Record = require('./record'); const Record = require('./record');
const ContributionSerializer = require('../serializers/contribution'); const ContributionSerializer = require('../serializers/contribution');
const deprecate = require('./utils/deprecate');
class Proposal extends Record { class Proposal extends Record {
get count () { get count () {
@ -13,7 +14,7 @@ class Proposal extends Record {
}); });
} }
async addProposal (proposalAttr, callOptions = {}) { async add (proposalAttr, callOptions = {}) {
const contribution = new ContributionSerializer(proposalAttr); const contribution = new ContributionSerializer(proposalAttr);
try { await contribution.validate(); } try { await contribution.validate(); }
@ -35,6 +36,11 @@ class Proposal extends Record {
return this.functions.addProposal(...proposal, callOptions); 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; module.exports = Proposal;