Add API to get subscription

This commit is contained in:
Girish Ramakrishnan
2019-05-03 20:17:40 -07:00
parent f6e82e93e4
commit ccb2fcf39b
4 changed files with 35 additions and 17 deletions
+13 -1
View File
@@ -1,7 +1,8 @@
'use strict';
exports = module.exports = {
subscribeCloudron: subscribeCloudron
subscribeCloudron: subscribeCloudron,
getSubscription: getSubscription
};
var appstore = require('../appstore.js'),
@@ -25,3 +26,14 @@ function subscribeCloudron(req, res, next) {
next(new HttpSuccess(200, {}));
});
}
function getSubscription(req, res, next) {
assert.strictEqual(typeof req.body, 'object');
appstore.getSubscription(function (error, result) {
if (error && error.reason === AppstoreError.EXTERNAL_ERROR) return next(new HttpError(424, error.message));
if (error) return next(new HttpError(500, error));
next(new HttpSuccess(200, result)); // { email, subscription }
});
}