2016-05-13 11:48:48 -03:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
angular.module('copayApp.controllers').controller('amazonController',
|
2016-06-13 15:00:17 -03:00
|
|
|
function($scope, $timeout, $ionicModal, configService, amazonService) {
|
2016-05-13 11:48:48 -03:00
|
|
|
|
|
|
|
|
this.init = function() {
|
|
|
|
|
var self = this;
|
|
|
|
|
var network = configService.getSync().amazon.testnet ? 'testnet' : 'livenet';
|
2016-06-07 21:20:13 -03:00
|
|
|
self.sandbox = network == 'testnet' ? true : false;
|
2016-05-13 11:48:48 -03:00
|
|
|
amazonService.setCredentials(network);
|
|
|
|
|
amazonService.getGiftCards(function(err, gcds) {
|
|
|
|
|
if (err) {
|
|
|
|
|
self.error = err;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
self.giftCards = gcds;
|
2016-05-19 20:20:06 -03:00
|
|
|
$timeout(function() {
|
|
|
|
|
$scope.$digest();
|
|
|
|
|
});
|
2016-05-13 11:48:48 -03:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2016-06-13 15:00:17 -03:00
|
|
|
this.openCardModal = function(card) {
|
|
|
|
|
$scope.card = card;
|
2016-05-13 11:48:48 -03:00
|
|
|
|
2016-06-13 15:00:17 -03:00
|
|
|
$ionicModal.fromTemplateUrl('views/modals/amazon-card-details.html', {
|
|
|
|
|
scope: $scope
|
|
|
|
|
}).then(function(modal) {
|
|
|
|
|
$scope.amazonCardDetailsModal = modal;
|
|
|
|
|
$scope.amazonCardDetailsModal.show();
|
2016-05-13 11:48:48 -03:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
});
|