Permalink
Browse files

improve statements, ids, events, transactions.

  • Loading branch information...
chjj committed Oct 27, 2012
1 parent f7899d2 commit 5e01b8c56abf224055db1555b948821e532053b9
Showing with 32 additions and 12 deletions.
  1. +32 −12 lib/charged.js
View
@@ -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');
};
/**
@@ -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) {
@@ -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');
};
/**
@@ -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');
};
/**

0 comments on commit 5e01b8c

Please sign in to comment.