Add AppStore.profile()

This commit is contained in:
Johannes Zellner
2016-07-26 16:00:42 +02:00
parent e8088be586
commit 642e5aceed

View File

@@ -140,5 +140,16 @@ angular.module('Application').service('AppStore', ['$http', '$base64', 'Client',
});
};
AppStore.prototype.profile = function (token, callback) {
if (Client.getConfig().apiServerOrigin === null) return callback(new AppStoreError(420, 'Enhance Your Calm'));
$http.get(Client.getConfig().apiServerOrigin + '/api/v1/profile?accessToken=' + token).success(function (data, status) {
if (status !== 200) return callback(new AppStoreError(status, data));
return callback(null, data.profile);
}).error(function (data, status) {
return callback(new AppStoreError(status, data));
});
};
return new AppStore();
}]);