From e33e78be8243282fe1f7fd17f48369b3f11d815d Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Tue, 7 Jun 2016 16:04:15 -0700 Subject: [PATCH] allow installing using version --- cloudron.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cloudron.js b/cloudron.js index 4712df2..94dd766 100644 --- a/cloudron.js +++ b/cloudron.js @@ -163,12 +163,21 @@ Cloudron.prototype.setCredentials = function (password, accessToken) { }; }; -Cloudron.prototype.installApp = function (location, manifest, portBindings) { +Cloudron.prototype.installApp = function (location, manifestOrAppstoreId, portBindings) { portBindings = portBindings || null; // null binds nothing + var data = { + manifest: typeof manifestOrAppstoreId === 'object' ? manifestOrAppstoreId : null, + appStoreId: typeof manifestOrAppstoreId === 'string' ? manifestOrAppstoreId : null, + location: location, + accessRestriction: null, + oauthProxy: false, + portBindings: portBindings + }; + var res = request.post(this._origin + '/api/v1/apps/install') .query({ access_token: this._credentials.accessToken }) - .send({ manifest: manifest, appStoreId: '', location: location, accessRestriction: null, oauthProxy: false, portBindings: portBindings }) + .send(data) .end(); common.verifyResponse2xx(res, 'Cannot install app'); debug('App installed at %s'.green, location);