Skip to content

Commit

Permalink
improve statements, ids, events, transactions.
Browse files Browse the repository at this point in the history
  • Loading branch information
chjj committed Oct 27, 2012
1 parent f7899d2 commit 5e01b8c
Showing 1 changed file with 32 additions and 12 deletions.
44 changes: 32 additions & 12 deletions lib/charged.js
Expand Up @@ -190,24 +190,36 @@ Charged.prototype.resetSubscriptionBalance = function(name, callback) {
* http://docs.chargify.com/api-statements
*/

Charged.prototype.getSubscriptionStatements = function(name, callback) {
Charged.prototype.getSubscriptionStatements = function(name, options, callback) {
if (!callback) {
callback = options;
options = null;
}
var path = '/subscriptions/' + escape(name) + '/statements';
return this.get(path, callback, 'statement');
return this.get(path, options, callback, 'statement');
};

Charged.prototype.getStatement = function(name, callback) {
var path = '/statements/' + escape(name);
return this.get(path, callback, 'statement');
};

Charged.prototype.getSubscriptionIds = function(name, callback) {
Charged.prototype.getSubscriptionIds = function(name, options, callback) {
if (!callback) {
callback = options;
options = null;
}
var path = '/subscriptions/' + escape(name) + '/statements/ids';
return this.get(path, callback, 'statement_ids');
return this.get(path, options, callback, 'statement_ids');
};

Charged.prototype.getStatementIds = function(name, callback) {
Charged.prototype.getStatementIds = function(name, options, callback) {
if (!callback) {
callback = options;
options = null;
}
var path = '/statements/' + escape(name) + '/ids';
return this.get(path, callback, 'statement_ids');
return this.get(path, options, callback, 'statement_ids');
};

/**
Expand Down Expand Up @@ -547,7 +559,7 @@ Charged.prototype.getSubscriptionEvents = function(sub, options, callback) {
options = null;
}
var path = '/subscriptions/' + escape(sub) + '/events';
return this.get(path, options, callback);
return this.get(path, options, callback, 'event');
};

Charged.prototype.getEvents = function(options, callback) {
Expand All @@ -556,7 +568,7 @@ Charged.prototype.getEvents = function(options, callback) {
options = null;
}
var path = '/events';
return this.get(path, options, callback);
return this.get(path, options, callback, 'event');
};

/**
Expand Down Expand Up @@ -630,17 +642,25 @@ Charged.prototype.removeSubscriptionCoupon = function(sub, name, callback) {
* Transactions
*/

Charged.prototype.getTransactions = function(callback) {
return this.get('/transactions', callback, 'transaction');
Charged.prototype.getTransactions = function(options, callback) {
if (!callback) {
callback = options;
options = null;
}
return this.get('/transactions', options, callback, 'transaction');
};

Charged.prototype.getTransaction = function(name, callback) {
return this.get('/transactions/' + escape(name), callback, 'transaction');
};

Charged.prototype.getSubscriptionTransactions = function(name, callback) {
Charged.prototype.getSubscriptionTransactions = function(name, options, callback) {
if (!callback) {
callback = options;
options = null;
}
var path = '/subscriptions/' + escape(name) + '/transactions';
return this.get(path, callback, 'transaction');
return this.get(path, options, callback, 'transaction');
};

/**
Expand Down

0 comments on commit 5e01b8c

Please sign in to comment.