cheddargetter
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -5,3 +5,3 @@ var https = require("https"); | ||
var ceddargetter = module.exports = function (user, pass, productCode) { | ||
var cheddargetter = module.exports = function (user, pass, productCode) { | ||
this.auth = "Basic " + new Buffer(user + ":" + pass).toString("base64"); | ||
@@ -12,3 +12,3 @@ this.pass = pass; | ||
ceddargetter.prototype.callAPI = function (data, path, callback) { | ||
cheddargetter.prototype.callAPI = function (data, path, callback) { | ||
if (typeof(path) == "function") { | ||
@@ -60,11 +60,11 @@ callback = path; | ||
ceddargetter.prototype.getAllPricingPlans = function (callback) { | ||
cheddargetter.prototype.getAllPricingPlans = function (callback) { | ||
this.callAPI("/plans/get/productCode/" + this.productCode, callback); | ||
}; | ||
ceddargetter.prototype.getPricingPlan = function (code, callback) { | ||
cheddargetter.prototype.getPricingPlan = function (code, callback) { | ||
this.callAPI("/plans/get/productCode/" + this.productCode + "/code/" + code, callback); | ||
}; | ||
ceddargetter.prototype.getAllCustomers = function (data, callback) { | ||
cheddargetter.prototype.getAllCustomers = function (data, callback) { | ||
if (!callback && typeof(data) == "function") { | ||
@@ -77,20 +77,59 @@ callback = data; | ||
ceddargetter.prototype.getCustomer = function (code, callback) { | ||
cheddargetter.prototype.getCustomer = function (code, callback) { | ||
this.callAPI("/customers/get/productCode/" + this.productCode + "/code/" + code, callback); | ||
}; | ||
ceddargetter.prototype.createCustomer = function (data, callback) { | ||
cheddargetter.prototype.createCustomer = function (data, callback) { | ||
this.callAPI(data, "/customers/new/productCode/" + this.productCode, callback); | ||
}; | ||
ceddargetter.prototype.editCustomer = function (code, data, callback) { | ||
cheddargetter.prototype.editCustomerAndSubscription = function (code, data, callback) { | ||
this.callAPI(data, "/customers/edit/productCode/" + this.productCode + "/code/" + code, callback); | ||
}; | ||
cheddargetter.prototype.editCustomer = function (code, data, callback) { | ||
this.callAPI(data, "/customers/edit-customer/productCode/" + this.productCode + "/code/" + code, callback); | ||
}; | ||
ceddargetter.prototype.editSubscription = function (code, data, callback) { | ||
cheddargetter.prototype.editSubscription = function (code, data, callback) { | ||
this.callAPI(data, "/customers/edit-subscription/productCode" + this.productCode + "/code/" + code, callback); | ||
}; | ||
ceddargetter.prototype.deleteCustomer = function (customerCode, callback) { | ||
cheddargetter.prototype.deleteCustomer = function (customerCode, callback) { | ||
this.callAPI("/customers/delete/productCode/" + this.productCode + "/code/" + customerCode, callback); | ||
}; | ||
cheddargetter.prototype.cancelSubscription = function (customerCode, callback) { | ||
this.callAPI("/customers/cancel/productCode/" + this.productCode + "/code/" + customerCode, callback); | ||
}; | ||
cheddargetter.prototype.addItem = function (customerCode, itemCode, amount, callback) { | ||
if (!callback && typeof(amount) == "function") { | ||
callback = amount; | ||
amount = null; | ||
} | ||
if (amount) { | ||
amount = {quantity: amount.toString()}; | ||
} | ||
this.callAPI(amount, "/customers/add-item-quantity/productCode/" + this.productCode + "/code/" + customerCode + "/itemCode/" + itemCode, callback); | ||
}; | ||
cheddargetter.prototype.removeItem = function (customerCode, itemCode, amount, callback) { | ||
if (!callback && typeof(amount) == "function") { | ||
callback = amount; | ||
amount = null; | ||
} | ||
if (amount) { | ||
amount = {quantity: amount.toString()}; | ||
} | ||
this.callAPI(amount, "/customers/remove-item-quantity/productCode/" + this.productCode + "/code/" + customerCode + "/itemCode/" + itemCode, callback); | ||
}; | ||
cheddargetter.prototype.setItemQuantity = function (customerCode, itemCode, amount, callback) { | ||
amount = {quantity: amount.toString()}; | ||
this.callAPI(amount, "/customers/set-item-quantity/productCode/" + this.productCode + "/code/" + customerCode + "/itemCode/" + itemCode, callback); | ||
}; |
{ | ||
"name": "cheddargetter", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"author": "Kevin Smith", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/respectTheCode/node-cheddargetter" | ||
}, | ||
"description": "Wrapper for the CheddarGetter recurring billing system APIs", | ||
"homepage": "https://github.com/respectTheCode/node-cheddargetter", | ||
"dependencies": { | ||
"async": ">=0.1.x", | ||
"async": "0.1.x", | ||
"xml2js": "0.1.x", | ||
"qs": "0.3.x", | ||
"qs": "0.3.x" | ||
}, | ||
"devDependencies": { | ||
"nodeunit": "0.6.x" | ||
@@ -11,0 +18,0 @@ }, |
@@ -0,1 +1,5 @@ | ||
# Install | ||
npm install cheddargetter | ||
# Usage | ||
@@ -2,0 +6,0 @@ |
@@ -62,3 +62,2 @@ var fs = require("fs"); | ||
}, function (result, cb) { | ||
console.log(result); | ||
cg.getAllCustomers(cb); | ||
@@ -71,2 +70,34 @@ }, function (result, cb) { | ||
test.equal(typeof(result.customer), "object", "getCustomer should return a customer object"); | ||
//cg.deleteCustomer("test", cb); | ||
cb(); | ||
}], function (err) { | ||
test.ifError(err); | ||
test.done(); | ||
}); | ||
}; | ||
module.exports.Items = function (test) { | ||
var cg = new CheddarGetter(config.user, config.pass, config.productCode); | ||
async.waterfall([function (cb) { | ||
cg.setItemQuantity("test", config.itemCode, 5, cb); | ||
}, function (result, cb) { | ||
cg.addItem("test", config.itemCode, 2, cb); | ||
}, function (result, cb) { | ||
cg.addItem("test", config.itemCode, cb); | ||
}, function (result, cb) { | ||
cg.getCustomer("test", cb); | ||
}, function (result, cb) { | ||
test.equal(result.customer.subscriptions.subscription.items.item[0].quantity, "7"); | ||
cb(null, {}); | ||
}, function (result, cb) { | ||
cg.removeItem("test", config.itemCode, 2, cb); | ||
}, function (result, cb) { | ||
cg.removeItem("test", config.itemCode, cb); | ||
}, function (result, cb) { | ||
cg.getCustomer("test", cb); | ||
}, function (result, cb) { | ||
test.equal(result.customer.subscriptions.subscription.items.item[0].quantity, "5"); | ||
cb(null, {}); | ||
}, function (result, cb) { | ||
cg.deleteCustomer("test", cb); | ||
@@ -73,0 +104,0 @@ }], function (err) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
15409
3
10
201
1
18
1
1
+ Addedasync@0.1.22(transitive)
- Removednodeunit@0.6.x
- Removedasync@3.2.6(transitive)
- Removedinherits@1.0.22.0.4(transitive)
- Removednodeunit@0.6.4(transitive)
- Removedtap-assert@0.0.11(transitive)
- Removedtap-producer@0.0.1(transitive)
- Removedtap-results@0.0.2(transitive)
- Removedyamlish@0.0.7(transitive)
Updatedasync@0.1.x