Enable cache for bitpay card

This commit is contained in:
Gustavo Maximiliano Cortez 2016-09-28 21:09:41 -03:00
commit 104209de5d
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
7 changed files with 91 additions and 45 deletions

View file

@ -187,8 +187,38 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http,
});
};
root.getCacheData = function(cb) {
_setCredentials();
storageService.getBitpayCardCache(credentials.NETWORK, function(err, data) {
if (err) return cb(err);
if (lodash.isString(data)) {
data = JSON.parse(data);
}
data = data || {};
return cb(null, data);
});
};
root.setCacheData = function(data, cb) {
_setCredentials();
data = JSON.stringify(data);
storageService.setBitpayCardCache(credentials.NETWORK, data, function(err) {
if (err) return cb(err);
return cb();
});
};
root.removeCacheData = function(cb) {
_setCredentials();
storageService.removeBitpayCardCache(credentials.NETWORK, function(err) {
if (err) return cb(err);
return cb();
});
};
root.logout = function(cb) {
_setCredentials();
root.removeCacheData(function() {});
storageService.removeBitpayCard(credentials.NETWORK, function(err) {
$http(_getBitPay('/visa-api/logout')).then(function(data) {
$log.info('BitPay Logout: SUCCESS');