From 673d50c215c97a80e330f8220f916394b29206ff Mon Sep 17 00:00:00 2001 From: Johannes Zellner Date: Thu, 24 Sep 2015 13:24:22 +0200 Subject: [PATCH] Support users rest api change --- appstore.js | 9 +++++++-- test/new-user-test.js | 7 ++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/appstore.js b/appstore.js index 33f3a45..e34d178 100644 --- a/appstore.js +++ b/appstore.js @@ -24,6 +24,11 @@ AppStore.prototype.getAccessToken = function (user) { return res.body.accessToken; }; +AppStore.prototype.getProfile = function () { + var res = request.get(this._origin + '/api/v1/profile').query({ accessToken: this._credentials.accessToken }).end(); + return res.body.profile; +}; + AppStore.prototype.setCredentials = function (password, accessToken) { this._credentials = { password: password, accessToken: accessToken }; }; @@ -95,7 +100,7 @@ AppStore.prototype.restore = function (boxId, backupId) { common.verifyResponse(res, 'Could not restore cloudron'); }; -AppStore.prototype.setupBilling = function (callback) { +AppStore.prototype.setupBilling = function (user, callback) { var stripeApi = stripe(common.stripeSecret()); var that = this; @@ -117,7 +122,7 @@ AppStore.prototype.setupBilling = function (callback) { billingToken: token.id }; - var res = request.put(that._origin + '/api/v1/users').send(data).query({ accessToken: that._credentials.accessToken }).end(); + var res = request.put(that._origin + '/api/v1/users/' + user.id).send(data).query({ accessToken: that._credentials.accessToken }).end(); common.verifyResponse(res, 'Could not setup billing'); callback(null); diff --git a/test/new-user-test.js b/test/new-user-test.js index 3b2b47f..625ced0 100644 --- a/test/new-user-test.js +++ b/test/new-user-test.js @@ -38,8 +38,13 @@ describe('Appstore new user flow', function () { appStore.setCredentials(owner.password, accessToken); }); + it('can get profile', function () { + var profile = appStore.getProfile(); + owner.id = profile.id; + }); + it('can setup billing details', function (done) { - appStore.setupBilling(done); + appStore.setupBilling(owner, done); }); it('can create a cloudron', function () {