Adds next step for external services
This commit is contained in:
parent
72fa77dbef
commit
c3188d7d17
12 changed files with 156 additions and 101 deletions
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('tabHomeController',
|
||||
function($rootScope, $timeout, $scope, $state, lodash, profileService, walletService, configService, txFormatService, $ionicModal, $log, platformInfo) {
|
||||
function($rootScope, $timeout, $scope, $state, lodash, profileService, walletService, configService, txFormatService, $ionicModal, $log, platformInfo, storageService) {
|
||||
|
||||
var setNotifications = function(notifications) {
|
||||
var n = walletService.processNotifications(notifications, 5);
|
||||
|
|
@ -68,7 +68,14 @@ console.log('[tab-home.js.39]', wallet.name, n); //TODO
|
|||
});
|
||||
};
|
||||
|
||||
|
||||
$scope.externalServices = {};
|
||||
$scope.nextStep = function() {
|
||||
lodash.each(['AmazonGiftCards', 'BitpayCard', 'BuyAndSell'], function(service) {
|
||||
storageService.getNextStep(service, function(err, value) {
|
||||
$scope.externalServices[service] = value ? true : false;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.bitpayCardEnabled = true; // TODO
|
||||
|
||||
|
|
|
|||
|
|
@ -105,7 +105,10 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
templateUrl: 'views/starting.html'
|
||||
})
|
||||
|
||||
|
||||
.state('buyandsell', {
|
||||
url: '/buyandsell',
|
||||
templateUrl: 'views/buyandsell.html'
|
||||
})
|
||||
|
||||
/*
|
||||
*
|
||||
|
|
|
|||
|
|
@ -68,6 +68,9 @@ angular.module('copayApp.services').factory('amazonService', function($http, $lo
|
|||
return cb(err);
|
||||
});
|
||||
});
|
||||
|
||||
// Show pending task from the UI
|
||||
storageService.setNextStep('AmazonGiftCards', true, function(err) {});
|
||||
};
|
||||
|
||||
root.getPendingGiftCards = function(cb) {
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http,
|
|||
storageService.setBitpayCard(credentials.NETWORK, user, function(err) {
|
||||
return cb(err);
|
||||
});
|
||||
// Show pending task from the UI
|
||||
storageService.setNextStep('BitpayCard', true, function(err) {});
|
||||
};
|
||||
|
||||
var _getSession = function(cb) {
|
||||
|
|
|
|||
|
|
@ -41,9 +41,9 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
|
|||
};
|
||||
|
||||
root.getOauthCodeUrl = function() {
|
||||
return credentials.HOST
|
||||
+ '/oauth/authorize?response_type=code&client_id='
|
||||
+ credentials.CLIENT_ID
|
||||
return credentials.HOST
|
||||
+ '/oauth/authorize?response_type=code&client_id='
|
||||
+ credentials.CLIENT_ID
|
||||
+ '&redirect_uri='
|
||||
+ credentials.REDIRECT_URI
|
||||
+ '&state=SECURE_RANDOM&scope='
|
||||
|
|
@ -59,7 +59,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
|
|||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json'
|
||||
},
|
||||
data: {
|
||||
data: {
|
||||
grant_type : 'authorization_code',
|
||||
code: code,
|
||||
client_id : credentials.CLIENT_ID,
|
||||
|
|
@ -70,7 +70,9 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
|
|||
|
||||
$http(req).then(function(data) {
|
||||
$log.info('Coinbase Authorization Access Token: SUCCESS');
|
||||
return cb(null, data.data);
|
||||
// Show pending task from the UI
|
||||
storageService.setNextStep('BuyAndSell', true, function(err) {});
|
||||
return cb(null, data.data);
|
||||
}, function(data) {
|
||||
$log.error('Coinbase Authorization Access Token: ERROR ' + data.statusText);
|
||||
return cb(data.data);
|
||||
|
|
@ -85,18 +87,18 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
|
|||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json'
|
||||
},
|
||||
data: {
|
||||
data: {
|
||||
grant_type : 'refresh_token',
|
||||
client_id : credentials.CLIENT_ID,
|
||||
client_secret: credentials.CLIENT_SECRET,
|
||||
redirect_uri: credentials.REDIRECT_URI,
|
||||
refresh_token: refreshToken
|
||||
refresh_token: refreshToken
|
||||
}
|
||||
};
|
||||
|
||||
$http(req).then(function(data) {
|
||||
$log.info('Coinbase Refresh Access Token: SUCCESS');
|
||||
return cb(null, data.data);
|
||||
return cb(null, data.data);
|
||||
}, function(data) {
|
||||
$log.error('Coinbase Refresh Access Token: ERROR ' + data.statusText);
|
||||
return cb(data.data);
|
||||
|
|
@ -195,17 +197,17 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
|
|||
root.sellPrice = function(token, currency, cb) {
|
||||
$http(_get('/prices/sell?currency=' + currency, token)).then(function(data) {
|
||||
$log.info('Coinbase Sell Price: SUCCESS');
|
||||
return cb(null, data.data);
|
||||
return cb(null, data.data);
|
||||
}, function(data) {
|
||||
$log.error('Coinbase Sell Price: ERROR ' + data.statusText);
|
||||
return cb(data.data);
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
root.buyPrice = function(token, currency, cb) {
|
||||
$http(_get('/prices/buy?currency=' + currency, token)).then(function(data) {
|
||||
$log.info('Coinbase Buy Price: SUCCESS');
|
||||
return cb(null, data.data);
|
||||
return cb(null, data.data);
|
||||
}, function(data) {
|
||||
$log.error('Coinbase Buy Price: ERROR ' + data.statusText);
|
||||
return cb(data.data);
|
||||
|
|
@ -215,7 +217,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
|
|||
root.getPaymentMethods = function(token, cb) {
|
||||
$http(_get('/payment-methods', token)).then(function(data) {
|
||||
$log.info('Coinbase Get Payment Methods: SUCCESS');
|
||||
return cb(null, data.data);
|
||||
return cb(null, data.data);
|
||||
}, function(data) {
|
||||
$log.error('Coinbase Get Payment Methods: ERROR ' + data.statusText);
|
||||
return cb(data.data);
|
||||
|
|
@ -225,7 +227,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
|
|||
root.getPaymentMethod = function(token, paymentMethodId, cb) {
|
||||
$http(_get('/payment-methods/' + paymentMethodId, token)).then(function(data) {
|
||||
$log.info('Coinbase Get Payment Method: SUCCESS');
|
||||
return cb(null, data.data);
|
||||
return cb(null, data.data);
|
||||
}, function(data) {
|
||||
$log.error('Coinbase Get Payment Method: ERROR ' + data.statusText);
|
||||
return cb(data.data);
|
||||
|
|
@ -243,7 +245,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
|
|||
},
|
||||
data: data
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
root.sellRequest = function(token, accountId, data, cb) {
|
||||
var data = {
|
||||
|
|
@ -254,7 +256,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
|
|||
};
|
||||
$http(_post('/accounts/' + accountId + '/sells', token, data)).then(function(data) {
|
||||
$log.info('Coinbase Sell Request: SUCCESS');
|
||||
return cb(null, data.data);
|
||||
return cb(null, data.data);
|
||||
}, function(data) {
|
||||
$log.error('Coinbase Sell Request: ERROR ' + data.statusText);
|
||||
return cb(data.data);
|
||||
|
|
@ -264,12 +266,12 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
|
|||
root.sellCommit = function(token, accountId, sellId, cb) {
|
||||
$http(_post('/accounts/' + accountId + '/sells/' + sellId + '/commit', token)).then(function(data) {
|
||||
$log.info('Coinbase Sell Commit: SUCCESS');
|
||||
return cb(null, data.data);
|
||||
return cb(null, data.data);
|
||||
}, function(data) {
|
||||
$log.error('Coinbase Sell Commit: ERROR ' + data.statusText);
|
||||
return cb(data.data);
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
root.buyRequest = function(token, accountId, data, cb) {
|
||||
var data = {
|
||||
|
|
@ -280,7 +282,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
|
|||
};
|
||||
$http(_post('/accounts/' + accountId + '/buys', token, data)).then(function(data) {
|
||||
$log.info('Coinbase Buy Request: SUCCESS');
|
||||
return cb(null, data.data);
|
||||
return cb(null, data.data);
|
||||
}, function(data) {
|
||||
$log.error('Coinbase Buy Request: ERROR ' + data.statusText);
|
||||
return cb(data.data);
|
||||
|
|
@ -290,7 +292,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
|
|||
root.buyCommit = function(token, accountId, buyId, cb) {
|
||||
$http(_post('/accounts/' + accountId + '/buys/' + buyId + '/commit', token)).then(function(data) {
|
||||
$log.info('Coinbase Buy Commit: SUCCESS');
|
||||
return cb(null, data.data);
|
||||
return cb(null, data.data);
|
||||
}, function(data) {
|
||||
$log.error('Coinbase Buy Commit: ERROR ' + data.statusText);
|
||||
return cb(data.data);
|
||||
|
|
@ -303,7 +305,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
|
|||
};
|
||||
$http(_post('/accounts/' + accountId + '/addresses', token, data)).then(function(data) {
|
||||
$log.info('Coinbase Create Address: SUCCESS');
|
||||
return cb(null, data.data);
|
||||
return cb(null, data.data);
|
||||
}, function(data) {
|
||||
$log.error('Coinbase Create Address: ERROR ' + data.statusText);
|
||||
return cb(data.data);
|
||||
|
|
@ -320,7 +322,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
|
|||
};
|
||||
$http(_post('/accounts/' + accountId + '/transactions', token, data)).then(function(data) {
|
||||
$log.info('Coinbase Create Address: SUCCESS');
|
||||
return cb(null, data.data);
|
||||
return cb(null, data.data);
|
||||
}, function(data) {
|
||||
$log.error('Coinbase Create Address: ERROR ' + data.statusText);
|
||||
return cb(data.data);
|
||||
|
|
@ -328,7 +330,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
|
|||
};
|
||||
|
||||
// Pending transactions
|
||||
|
||||
|
||||
root.savePendingTransaction = function(ctx, opts, cb) {
|
||||
var network = configService.getSync().coinbase.testnet ? 'testnet' : 'livenet';
|
||||
storageService.getCoinbaseTxs(network, function(err, oldTxs) {
|
||||
|
|
|
|||
|
|
@ -74,6 +74,8 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l
|
|||
|
||||
$http(req).then(function(data) {
|
||||
$log.info('Glidera Authorization Access Token: SUCCESS');
|
||||
// Show pending task from the UI
|
||||
storageService.setNextStep('BuyAndSell', true, function(err) {});
|
||||
return cb(null, data.data);
|
||||
}, function(data) {
|
||||
$log.error('Glidera Authorization Access Token: ERROR ' + data.statusText);
|
||||
|
|
|
|||
|
|
@ -264,6 +264,18 @@ angular.module('copayApp.services')
|
|||
storage.remove('addressbook-' + network, cb);
|
||||
};
|
||||
|
||||
root.setNextStep = function(service, status, cb) {
|
||||
storage.set('nextStep-' + service, status, cb);
|
||||
};
|
||||
|
||||
root.getNextStep = function(service, cb) {
|
||||
storage.get('nextStep-' + service, cb);
|
||||
};
|
||||
|
||||
root.removeNextStep = function(service, cb) {
|
||||
storage.remove('nextStep-' + service, cb);
|
||||
};
|
||||
|
||||
|
||||
root.checkQuota = function() {
|
||||
var block = '';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue