Merge branch 'feat/bitpay-accounts' of https://github.com/ajp8164/copay into feat/bitpay-accounts

This commit is contained in:
Andy Phillipson 2017-02-07 13:12:56 -05:00
commit 14aa806267

View file

@ -380,7 +380,7 @@ angular.module('copayApp.services')
bitpayAccounts = bitpayAccounts || {};
bitpayAccounts[data.email] = bitpayAccounts[data.email] || {};
bitpayAccounts[data.email]['bitpayDebitCards-' + network] = data.cards;
storage.set('bitpayAccounts-v2-' + network, JSON.stringify(bitpayAccounts), cb);
storage.set('bitpayAccounts-v3-' + network, JSON.stringify(bitpayAccounts), cb);
});
};
@ -539,6 +539,28 @@ angular.module('copayApp.services')
});
};
// account: {
// email: account email
// apiContext: the context needed for making future api calls
// bitpayDebitCards: an array of cards
// }
root.removeBitpayAccount = function(network, account, cb) {
if (lodash.isString(account)) {
account = JSON.parse(account);
}
account = account || {};
if (lodash.isEmpty(account)) return cb('No account to remove');
storage.get('bitpayAccounts-v3-' + network, function(err, bitpayAccounts) {
if (err) cb(err);
if (lodash.isString(bitpayAccounts)) {
bitpayAccounts = JSON.parse(bitpayAccounts);
}
bitpayAccounts = bitpayAccounts || {};
delete bitpayAccounts[account.email];
storage.set('bitpayAccounts-v3-' + network, JSON.stringify(bitpayAccounts), cb);
});
};
root.setAppIdentity = function(network, data, cb) {
storage.set('appIdentity-' + network, data, cb);
};