Support users rest api change

This commit is contained in:
Johannes Zellner 2015-09-24 13:24:22 +02:00
parent 23bcd75d8c
commit 673d50c215
2 changed files with 13 additions and 3 deletions

View File

@ -24,6 +24,11 @@ AppStore.prototype.getAccessToken = function (user) {
return res.body.accessToken; 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) { AppStore.prototype.setCredentials = function (password, accessToken) {
this._credentials = { password: password, accessToken: accessToken }; this._credentials = { password: password, accessToken: accessToken };
}; };
@ -95,7 +100,7 @@ AppStore.prototype.restore = function (boxId, backupId) {
common.verifyResponse(res, 'Could not restore cloudron'); common.verifyResponse(res, 'Could not restore cloudron');
}; };
AppStore.prototype.setupBilling = function (callback) { AppStore.prototype.setupBilling = function (user, callback) {
var stripeApi = stripe(common.stripeSecret()); var stripeApi = stripe(common.stripeSecret());
var that = this; var that = this;
@ -117,7 +122,7 @@ AppStore.prototype.setupBilling = function (callback) {
billingToken: token.id 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'); common.verifyResponse(res, 'Could not setup billing');
callback(null); callback(null);

View File

@ -38,8 +38,13 @@ describe('Appstore new user flow', function () {
appStore.setCredentials(owner.password, accessToken); 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) { it('can setup billing details', function (done) {
appStore.setupBilling(done); appStore.setupBilling(owner, done);
}); });
it('can create a cloudron', function () { it('can create a cloudron', function () {