From 0bf855aac7caa4fae4f8b259ba96b16861821934 Mon Sep 17 00:00:00 2001 From: Simon Escobar Benitez Date: Fri, 6 Feb 2015 15:14:33 -0500 Subject: [PATCH 1/7] Content-Length Header Fix --- lib/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client.js b/lib/client.js index 9106023..f8ccc33 100644 --- a/lib/client.js +++ b/lib/client.js @@ -20,7 +20,7 @@ headers: { Authorization: "Basic " + (new Buffer(config.API_KEY)).toString('base64'), Accept: 'application/xml', - 'Content-Length': (data) ? data.length : 0 + 'Content-Length': (data) ? Buffer.byteLength(data) : 0 } }; From c47406c910ff9b917ced4bbfcf01cfe5a36ad6a1 Mon Sep 17 00:00:00 2001 From: Simon Escobar Benitez Date: Fri, 6 Feb 2015 15:15:44 -0500 Subject: [PATCH 2/7] Fix js2xml Dependency --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d869925..b0f2fbc 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ , "main" : "./lib/recurly.js" , "dependencies" : { "xml2js": ">= 0.4.0", - "js2xml": "valorkin/js2xml" + "js2xml": "philjackson/js2xml" } , "engines" : { "node" : ">= 0.4" } } From 71b8b7ae627106d242d993751a9085a34eb7b023 Mon Sep 17 00:00:00 2001 From: Simon Escobar Benitez Date: Thu, 12 Feb 2015 16:02:09 -0500 Subject: [PATCH 3/7] Support for custom headers in get invoice as pdf - version 2.2.0 --- lib/client.js | 11 +++++++++-- lib/recurly.js | 37 ++++++++++++++++++++----------------- package.json | 4 ++-- 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/lib/client.js b/lib/client.js index f8ccc33..602bcc1 100644 --- a/lib/client.js +++ b/lib/client.js @@ -8,7 +8,7 @@ config.RECURLY_HOST = config.SUBDOMAIN + '.recurly.com'; return { - request: function (route, callback, data) { + request: function (route, callback, data, headers) { var endpoint = route[0]; var method = route[1]; var that = this; @@ -23,7 +23,11 @@ 'Content-Length': (data) ? Buffer.byteLength(data) : 0 } }; - + if (headers) { + for (var attr in headers) { + options.headers[attr] = headers[attr]; + } + } if (method.toLowerCase() === 'post' || method.toLowerCase() === 'put') { options.headers['Content-Type'] = 'application/xml'; that.debug(data); @@ -45,6 +49,9 @@ if (responsedata === '') { return _cb(res); } + if (headers) { + return _cb(res, null, responsedata); + } return parser.parseString(responsedata, function (err, result) { return _cb(res, null, result); }); diff --git a/lib/recurly.js b/lib/recurly.js index 81e4cce..28e26bd 100644 --- a/lib/recurly.js +++ b/lib/recurly.js @@ -26,9 +26,9 @@ t.request(utils.addParams(routes.accounts.close, {account_code: accountcode}), callback); }, reopen: function(accountcode, callback){ - t.request(utils.addParams(routes.accounts.reopen, {account_code: accountcode}), callback) + t.request(utils.addParams(routes.accounts.reopen, {account_code: accountcode}), callback); } - } + }; this.adjustments = { get: function(accountcode, callback){ @@ -40,8 +40,8 @@ remove: function(uuid, callback){ t.request(utils.addParams(routes.adjustments.remove, {uuid: uuid}), callback); } - } - + }; + //http://docs.recurly.com/api/billing-info this.billingInfo = { update: function(accountcode, details, callback){ @@ -53,7 +53,7 @@ remove: function(accountcode, callback){ t.request(utils.addParams(routes.billingInfo.remove, {account_code: accountcode} ), callback); } - } + }; //http://docs.recurly.com/api/coupons this.coupons = { @@ -69,7 +69,7 @@ deactivate: function(couponcode, callback){ t.request(utils.addParams(routes.coupons.deactivate, {coupon_code: couponcode}), callback); } - } + }; this.couponRedemption = { redeem: function(couponcode, details, callback){ @@ -82,9 +82,9 @@ t.request(utils.addParams(routes.couponRedemption.remove, {account_code: accountcode}), callback); }, getByInvoice: function(invoicenumber, callback){ - t.request(utils.addParams(routes.couponRedemption.getByInvoice, {invoice_number: invoicenumber}), callback) + t.request(utils.addParams(routes.couponRedemption.getByInvoice, {invoice_number: invoicenumber}), callback); } - } + }; this.invoices = { list: function(callback, filter){ @@ -95,11 +95,14 @@ utils.addParams( utils.addQueryParams(routes.invoices.listByAccount, filter) , {account_code: accountcode}) - , callback) + , callback); }, get: function(invoicenumber, callback){ t.request(utils.addParams(routes.invoices.get, {invoice_number: invoicenumber}), callback); }, + getPdf: function(invoicenumber, callback){ + t.request(utils.addParams(routes.invoices.get, {invoice_number: invoicenumber}), callback, null, { headers: { Accept: 'application/pdf' } }); + }, create: function(accountcode, details, callback){ t.request(utils.addParams(routes.invoices.create, {account_code: accountcode}), callback, new Js2xml('invoice', details).toString()); }, @@ -109,7 +112,7 @@ markFailed: function(invoicenumber, callback){ t.request(utils.addParams(routes.invoices.markFailed, {invoice_number: invoicenumber}), callback); } - } + }; this.plans = { list: function(callback, filter){ @@ -127,7 +130,7 @@ remove: function(plancode, callback){ t.request(utils.addParams(routes.plans.remove, {plan_code: plancode}), callback); } - } + }; this.planAddons = { list: function(plancode, callback, filter){ @@ -141,16 +144,16 @@ }, 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){ t.request(utils.addParams(routes.planAddons.remove, {plan_code: plancode, add_on_code: addoncode}), callback); } - } + }; this.subscriptions = { list: function(callback, filter){ @@ -181,7 +184,7 @@ postpone: function(uuid, nextRenewalDate, callback){ t.request(utils.addParams(routes.subscriptions.postpone, {uuid: uuid, next_renewal_date: nextRenewalDate}), callback); } - } + }; this.transactions = { list: function(callback, filter){ @@ -204,8 +207,8 @@ if(amount){ route = utils.addQueryParams(route, { amount_in_cents: amount }); } - t.request(route, callback) + t.request(route, callback); } - } + }; }//end class })(); diff --git a/package.json b/package.json index b0f2fbc..75ae869 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { "name" : "node-recurly" , "description" : "Library for accessing the api for the Recurly recurring billing service." , "keywords" : [ "recurly", "e-commerce", "recurring billing" ] -, "version" : "2.1.0" +, "version" : "2.2.0" , "homepage" : "https://github.com/robrighter/node-recurly" , "author" : "Rob Righter (http://github.com/robrighter)" -, "contributors" : [ +, "contributors" : [ "Iván Guardado (http://github.com/IvanGuardado)", "Rob Righter (http://github.com/robrighter)", "Dmitriy Shekhovtsov (https://github.com/valorkin)" From 2ab80033e106ee4861efe40175cce31b071b20ab Mon Sep 17 00:00:00 2001 From: Simon Escobar Benitez Date: Mon, 25 May 2015 14:36:05 -0500 Subject: [PATCH 4/7] fixing issue with pdf headers --- lib/recurly.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/recurly.js b/lib/recurly.js index 28e26bd..7eee6a7 100644 --- a/lib/recurly.js +++ b/lib/recurly.js @@ -101,7 +101,7 @@ t.request(utils.addParams(routes.invoices.get, {invoice_number: invoicenumber}), callback); }, getPdf: function(invoicenumber, callback){ - t.request(utils.addParams(routes.invoices.get, {invoice_number: invoicenumber}), callback, null, { headers: { Accept: 'application/pdf' } }); + t.request(utils.addParams(routes.invoices.get, {invoice_number: invoicenumber}), callback, null, { Accept: 'application/pdf' }); }, create: function(accountcode, details, callback){ t.request(utils.addParams(routes.invoices.create, {account_code: accountcode}), callback, new Js2xml('invoice', details).toString()); From 4d6ece4966bbfc073f23869227d92bbcf9be36f8 Mon Sep 17 00:00:00 2001 From: Simon Escobar Benitez Date: Mon, 25 May 2015 14:41:41 -0500 Subject: [PATCH 5/7] version 2.2.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 75ae869..ff658f7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name" : "node-recurly" , "description" : "Library for accessing the api for the Recurly recurring billing service." , "keywords" : [ "recurly", "e-commerce", "recurring billing" ] -, "version" : "2.2.0" +, "version" : "2.2.1" , "homepage" : "https://github.com/robrighter/node-recurly" , "author" : "Rob Righter (http://github.com/robrighter)" , "contributors" : [ From 1393aa8327fa07edcea65340cca51fef7ed45b11 Mon Sep 17 00:00:00 2001 From: Simon Escobar Benitez Date: Thu, 28 May 2015 11:49:05 -0500 Subject: [PATCH 6/7] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ff658f7..7275296 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ , "directories" : { "lib" : "./lib" } , "main" : "./lib/recurly.js" , "dependencies" : { - "xml2js": ">= 0.4.0", + "xml2js": "^0.4.5", "js2xml": "philjackson/js2xml" } , "engines" : { "node" : ">= 0.4" } From 85b2381b1980d023ac47d02bf00741ce219ad8e9 Mon Sep 17 00:00:00 2001 From: Simon Escobar Benitez Date: Thu, 28 May 2015 11:56:32 -0500 Subject: [PATCH 7/7] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7275296..5e40ddd 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ , "directories" : { "lib" : "./lib" } , "main" : "./lib/recurly.js" , "dependencies" : { - "xml2js": "^0.4.5", + "xml2js": "0.4.5", "js2xml": "philjackson/js2xml" } , "engines" : { "node" : ">= 0.4" }