From 639c34b1bd27b7cb6e1ed09360ceea69ce7574d2 Mon Sep 17 00:00:00 2001 From: Chris Bargren Date: Fri, 20 May 2016 09:25:03 -0700 Subject: [PATCH] Making the signature consistent The `callback` parameter is placed inconsistently among various methods. Putting it at the end makes the module work a bit better with [promisify wrappers](https://github.com/nodegit/promisify-node). --- README.md | 86 +++++++++++++++++++++++++------------------------- lib/recurly.js | 26 +++++++-------- 2 files changed, 56 insertions(+), 56 deletions(-) diff --git a/README.md b/README.md index c81eef8..884dc08 100644 --- a/README.md +++ b/README.md @@ -34,15 +34,15 @@ http://docs.recurly.com/api/accounts - recurly.accounts.list(callback, filter) + recurly.accounts.list(filter, callback) recurly.accounts.create(details, callback) - recurly.accounts.update(accountcode, details, callback) + recurly.accounts.update(accountcode, details, callback) - recurly.accounts.get(accountcode, callback) + recurly.accounts.get(accountcode, callback) - recurly.accounts.close(accountcode, callback) + recurly.accounts.close(accountcode, callback) recurly.accounts.reopen(accountcode, callback) @@ -51,13 +51,13 @@ Billing Information =============== http://docs.recurly.com/api/billing-info - recurly.billingInfo.update(accountcode, details, callback) + recurly.billingInfo.update(accountcode, details, callback) - recurly.billingInfo.get(accountcode, callback) + recurly.billingInfo.get(accountcode, callback) - recurly.billingInfo.remove(accountcode, callback) + recurly.billingInfo.remove(accountcode, callback) @@ -66,7 +66,7 @@ Adjustments http://docs.recurly.com/api/adjustments recurly.adjustments.get(accountcode, callback) - + recurly.adjustments.create(accountcode, details, callback) recurly.adjustments.remove(uuid, callback) @@ -76,8 +76,8 @@ Coupons =============== http://docs.recurly.com/api/coupons - recurly.coupons.list(callback, filter) - + recurly.coupons.list(filter, callback) + recurly.coupons.get(couponcode, callback) recurly.coupons.create(details, callback) @@ -87,7 +87,7 @@ http://docs.recurly.com/api/coupons Coupon Redemtion ================= http://docs.recurly.com/api/coupons/coupon-redemption - + recurly.couponRedemption.redeem(couponcode, details, callback) recurly.couponRedemption.get(accountcode, callback) @@ -102,12 +102,12 @@ Invoices =============== http://docs.recurly.com/api/invoices - recurly.invoices.list(callback, filter) - + recurly.invoices.list(filter, callback) + recurly.invoices.listByAccount(accountcode, callback, filter) recurly.invoices.get(invoicenumber, callback) - + recurly.invoices.create(accountcode, details, callback) recurly.invoices.markSuccessful(invoicenumber, callback) @@ -119,51 +119,51 @@ Subscriptions =============== http://docs.recurly.com/api/subscriptions - recurly.subscriptions.list(callback, filter) - - recurly.subscriptions.listByAccount(accountcode, callback) + recurly.subscriptions.list(callback, filter) + + recurly.subscriptions.listByAccount(accountcode, callback) + + recurly.subscriptions.get(uuid, callback) + + recurly.subscriptions.create(details, callback) - recurly.subscriptions.get(uuid, callback) + recurly.subscriptions.update(uuid, details, callback) - recurly.subscriptions.create(details, callback) - - recurly.subscriptions.update(uuid, details, callback) - - recurly.subscriptions.cancel(uuid, callback) - - recurly.subscriptions.reactivate(uuid, callback) - - recurly.subscriptions.terminate(uuid, refundType, callback) + recurly.subscriptions.cancel(uuid, callback) - recurly.subscriptions.postpone(uuid, nextRenewalDate, callback) + recurly.subscriptions.reactivate(uuid, callback) + + recurly.subscriptions.terminate(uuid, refundType, callback) + + recurly.subscriptions.postpone(uuid, nextRenewalDate, callback) Subscription Plans ================== http://docs.recurly.com/api/plans - recurly.plans.list(callback, filter) + recurly.plans.list(filter, callback) + + recurly.plans.get(plancode, callback) - recurly.plans.get(plancode, callback) - recurly.plans.create(details, callback) - + recurly.plans.update(plancode, details, callback) - + recurly.plans.remove(plancode, callback) Plan Add-ons ================== http://docs.recurly.com/api/plans/add-ons - recurly.planAddons.list(plancode, callback, filter) + recurly.planAddons.list(plancode, filter, callback) + + recurly.planAddons.get(plancode, addoncode, callback) - recurly.planAddons.get(plancode, addoncode, callback) - recurly.planAddons.create(plancode, details, callback) - + recurly.planAddons.update(plancode, addoncode, details, callback) - + recurly.planAddons.remove(plancode, addoncode, callback) @@ -171,16 +171,16 @@ Transactions =============== http://docs.recurly.com/api/transactions - recurly.transactions.list(callback, filter) + recurly.transactions.list(filter, callback) - recurly.transactions.listByAccount(accountcode, callback, filter) + recurly.transactions.listByAccount(accountcode, filter, callback) - recurly.transactions.get(id, callback) + recurly.transactions.get(id, callback) - recurly.transactions.create(details, callback) + recurly.transactions.create(details, callback) - recurly.transactions.refund(id, callback, amount) + recurly.transactions.refund(id, amount, callback) diff --git a/lib/recurly.js b/lib/recurly.js index 81e4cce..af018f6 100644 --- a/lib/recurly.js +++ b/lib/recurly.js @@ -10,7 +10,7 @@ //http://docs.recurly.com/api/accounts this.accounts = { - list: function(callback, filter){ + list: function(filter, callback){ t.request(utils.addQueryParams(routes.accounts.list, filter), callback); }, get: function(accountcode, callback){ @@ -41,7 +41,7 @@ t.request(utils.addParams(routes.adjustments.remove, {uuid: uuid}), callback); } } - + //http://docs.recurly.com/api/billing-info this.billingInfo = { update: function(accountcode, details, callback){ @@ -57,7 +57,7 @@ //http://docs.recurly.com/api/coupons this.coupons = { - list: function(callback, filter){ + list: function(filter, callback){ t.request(utils.addQueryParams(routes.coupons.list, filter), callback); }, get: function(couponcode, callback){ @@ -87,10 +87,10 @@ } this.invoices = { - list: function(callback, filter){ + list: function(filter, callback){ t.request(utils.addQueryParams(routes.invoices.list, filter), callback); }, - listByAccount: function(accountcode, callback, filter){ + listByAccount: function(accountcode, filter, callback){ t.request( utils.addParams( utils.addQueryParams(routes.invoices.listByAccount, filter) @@ -112,7 +112,7 @@ } this.plans = { - list: function(callback, filter){ + list: function(filter, callback){ t.request(utils.addQueryParams(routes.plans.list, filter), callback); }, get: function(plancode, callback){ @@ -130,7 +130,7 @@ } this.planAddons = { - list: function(plancode, callback, filter){ + list: function(plancode, filter, callback){ t.request(utils.addParams(utils.addQueryParams(routes.planAddons.list, filter), {plan_code: plancode}), callback); }, get: function(plancode, addoncode, callback){ @@ -141,10 +141,10 @@ }, update: function(plancode, addoncode, details, callback){ t.request(utils.addParams( - routes.planAddons.update, + routes.planAddons.update, { plan_code: plancode, add_on_code: addoncode - }), + }), callback, new Js2xml('add_on', details).toString()); }, remove: function(plancode, addoncode, callback){ @@ -153,7 +153,7 @@ } this.subscriptions = { - list: function(callback, filter){ + list: function(filter, callback){ t.request(utils.addQueryParams(routes.subscriptions.list, filter), callback); }, listByAccount: function(accountcode, callback){ @@ -184,10 +184,10 @@ } this.transactions = { - list: function(callback, filter){ + list: function(filter, callback){ t.request(utils.addQueryParams(routes.transactions.list, filter), callback); }, - listByAccount: function(accountCode, callback, filter){ + listByAccount: function(accountCode, filter, callback){ t.request( utils.addParams( utils.addQueryParams(routes.transactions.listByAccount, filter), {account_code: accountCode}), @@ -199,7 +199,7 @@ create: function(details, callback){ t.request(routes.transactions.create, callback, new Js2xml('transaction', details).toString()); }, - refund: function(id, callback, amount){ + refund: function(id, amount, callback){ var route = utils.addParams(routes.transactions.refund, {id: id}); if(amount){ route = utils.addQueryParams(route, { amount_in_cents: amount });