diff --git a/modules/licenses.js b/modules/licenses.js index 3d1d67d..b37cdb4 100644 --- a/modules/licenses.js +++ b/modules/licenses.js @@ -8,13 +8,13 @@ var Licenses = function(config) { /** * Add License - * The Add License function can be used to generate a new WHMCS License Key. - * @param type - License type (branding/nobranding) + * @param product - product type (starter , plus , professional or business) * @param callback */ -Licenses.prototype.addLicense = function (type, callback) { +Licenses.prototype.addLicense = function(product, callback) { var options = { action: 'addlicense', - type: type || 'branding', + product: product || 'starter', responsetype: 'xml' }; @@ -26,6 +26,74 @@ Licenses.prototype.addLicense = function (type, callback) { utils.modem(createOptions, callback, true); }; +/** + * Upgrade License - + * Upgrade or downgrade a given license to a new product. + * @param key - The license key to be upgraded/downgraded + * @param product - product type (starter , plus , professional or business) + * @param callback + */ +Licenses.prototype.upgradeLicense = function(key, product, callback) { + var options = { + key: key, + action: 'upgrade', + product: product, + responsetype: 'xml' + }; + + var createOptions = { + client: this, + body: options + }; + + utils.modem(createOptions, callback, true); +}; + +/** + * Downgrade License - + * Alias of Upgrade License. + * @param key - The license key to be upgraded/downgraded + * @param product - product type (starter , plus , professional or business) + * @param callback + */ +Licenses.prototype.downgradeLicense = function(key, product, callback) { + Licenses.prototype.upgradeLicense(key, product, callback); +}; + +/** + * Upgrade License and Reissue - + * Upgrade or downgrade a given license to a new product and reissue it ready for installation to a new location. + * @param key - The license key to be upgraded/downgraded + * @param product - product type (starter , plus , professional or business) + * @param callback + */ +Licenses.prototype.upgradeReissueLicense = function(key, product, callback) { + var options = { + key: key, + action: 'upgradeandreissue', + product: product, + responsetype: 'xml' + }; + + var createOptions = { + client: this, + body: options + }; + + utils.modem(createOptions, callback, true); +}; + +/** + * Downgrade License and Reissue - + * Alias of Upgrade License. + * @param key - The license key to be upgraded/downgraded + * @param product - product type (starter , plus , professional or business) + * @param callback + */ +Licenses.prototype.downgradeReissueLicense = function(key, product, callback) { + Licenses.prototype.upgradeReissueLicense(key, product, callback); +}; + /** * Cancel License - * This will cancel an active WHMCS License Key and prevent it from being billed @@ -33,7 +101,7 @@ again. It will terminate it immediately and not allow it to be reactivated. * @param key - License Key to be cancelled * @param callback */ -Licenses.prototype.cancelLicense = function (key, callback) { +Licenses.prototype.cancelLicense = function(key, callback) { var options = { action: 'cancel', key: key, @@ -56,7 +124,7 @@ The no branding status will be true/false. And the license status either Active, Reissued, or Suspended. Expired keys are excluded. * @param callback */ -Licenses.prototype.listLicenses = function (callback) { +Licenses.prototype.listLicenses = function(callback) { var options = { action: 'listlicenses', responsetype: 'xml' @@ -78,7 +146,7 @@ the associated installation. * @param key - License Key to be reissued. * @param callback */ -Licenses.prototype.reissueLicense = function (key, callback) { +Licenses.prototype.reissueLicense = function(key, callback) { var options = { action: 'reissue', key: key, @@ -104,17 +172,17 @@ key. * @param [opts.directory] Comma separated list of allowed directories * @param callback */ -Licenses.prototype.modifyLicense = function (key, opts, callback) { +Licenses.prototype.modifyLicense = function(key, opts, callback) { var options = { action: 'modify', key: key, responsetype: 'xml' }; - if(typeof opts === 'function'){ + if (typeof opts === 'function') { callback = opts; } else { - options = extend(options,opts); + options = extend(options, opts); } var createOptions = { @@ -130,16 +198,16 @@ Licenses.prototype.modifyLicense = function (key, opts, callback) { * The Get Pricing can be used to retrieve pricing information for your account. * @param callback */ -Licenses.prototype.getPricingLicense = function (callback) { +Licenses.prototype.getPricingLicense = function(callback) { var options = { action: 'getpricing', responsetype: 'xml' }; - if(typeof opts === 'function'){ + if (typeof opts === 'function') { callback = opts; } else { - options = extend(options,opts); + options = extend(options, opts); } var createOptions = { @@ -162,16 +230,16 @@ At least one criteria must be submitted. * @param [opts.ipaddr] (Optional) Obtain results of a specific IP address * @param callback */ -Licenses.prototype.searchLicense = function (opts, callback) { +Licenses.prototype.searchLicense = function(opts, callback) { var options = { action: 'searchlicenses', responsetype: 'xml' }; - if(typeof opts === 'function'){ + if (typeof opts === 'function') { callback = opts; } else { - options = extend(options,opts); + options = extend(options, opts); } var createOptions = { @@ -189,7 +257,7 @@ Licenses.prototype.searchLicense = function (opts, callback) { * @param key License Key * @param callback */ -Licenses.prototype.brandingLicense = function (action, key, callback) { +Licenses.prototype.brandingLicense = function(action, key, callback) { // action The function to perform [brandingenable/brandingdisable] if (action && action === true) { action = 'brandingenable';