Refactor buying process

This commit is contained in:
Gustavo Maximiliano Cortez 2017-01-11 19:38:05 -03:00
commit e42d09574b
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
8 changed files with 329 additions and 123 deletions

View file

@ -6,6 +6,8 @@ angular.module('copayApp.controllers').controller('coinbaseController', function
var isCordova = platformInfo.isCordova;
var init = function() {
var config = configService.getSync().wallet.settings;
$scope.currency = getCurrency(config.alternativeIsoCode);
ongoingProcess.set('connectingCoinbase', true);
coinbaseService.init(function(err, data) {
ongoingProcess.set('connectingCoinbase', false);
@ -15,6 +17,15 @@ angular.module('copayApp.controllers').controller('coinbaseController', function
}
return;
}
// Show rates
coinbaseService.buyPrice(data.accessToken, $scope.currency, function(err, b) {
$scope.buyPrice = b.data || null;
});
coinbaseService.sellPrice(data.accessToken, $scope.currency, function(err, s) {
$scope.sellPrice = s.data || null;
});
// Updating accessToken and accountId
$timeout(function() {
$scope.accessToken = data.accessToken;
@ -25,6 +36,14 @@ angular.module('copayApp.controllers').controller('coinbaseController', function
});
};
var getCurrency = function(code) {
// ONLY "USD" and "EUR"
switch(code) {
case 'EUR' : return 'EUR';
default : return 'USD'
};
};
$scope.updateTransactions = function() {
$log.debug('Getting transactions...');
$scope.pendingTransactions = { data: {} };