Added proper services for the Bitcoin.com stuff

This commit is contained in:
magmahindenburg 2017-06-14 00:43:11 +09:00
commit c7bbaf7cce
7 changed files with 100 additions and 6 deletions

View file

@ -28,6 +28,7 @@
"_enabledExtensions": {
"coinbase": false,
"glidera": false,
"amazon": false
"amazon": false,
"bitcoincom": true,
}
}

View file

@ -0,0 +1,17 @@
'use strict';
angular.module('copayApp.controllers').controller('bitcoincomController',
function($scope, $timeout, $ionicModal, $log, $state, $ionicHistory, lodash, bitcoincomService, externalLinkService, popupService) {
$scope.openExternalLink = function(url) {
externalLinkService.open(url);
};
var initBitcoincom = function() {
};
$scope.$on("$ionicView.beforeEnter", function(event, data) {
$scope.network = bitcoincomController.getNetwork();
initBitcoincom;
});
});

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('tabHomeController',
function($rootScope, $timeout, $scope, $state, $stateParams, $ionicModal, $ionicScrollDelegate, $window, gettextCatalog, lodash, popupService, ongoingProcess, externalLinkService, latestReleaseService, profileService, walletService, configService, $log, platformInfo, storageService, txpModalService, appConfigService, startupService, addressbookService, feedbackService, bwcError, nextStepsService, buyAndSellService, homeIntegrationsService, bitpayCardService, pushNotificationsService, timeService) {
function($rootScope, $timeout, $scope, $state, $stateParams, $ionicModal, $ionicScrollDelegate, $window, gettextCatalog, lodash, popupService, ongoingProcess, externalLinkService, latestReleaseService, profileService, walletService, configService, $log, platformInfo, storageService, txpModalService, appConfigService, startupService, addressbookService, feedbackService, bwcError, nextStepsService, buyAndSellService, homeIntegrationsService, bitpayCardService, pushNotificationsService, timeService, bitcoincomService) {
var wallet;
var listeners = [];
var notifications = [];

View file

@ -1014,6 +1014,18 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
abstract: true
})
/* Explore Bitcoin.com */
.state('tabs.bitcoin-com', {
url: '/bitcoincom',
views: {
'tab-home@tabs': {
controller: 'bitcoincomController',
templateUrl: 'views/bitcoincom.html'
}
}
})
/*
*
* Amazon.com Gift Card

View file

@ -159,9 +159,9 @@ angular.module('copayApp.services').factory('amazonService', function($http, $lo
var register = function() {
storageService.getAmazonGiftCards(root.getNetwork(), function(err, giftCards) {
if (giftCards) {
homeIntegrationsService.register(homeItem);
// homeIntegrationsService.register(homeItem);
} else {
nextStepsService.register(nextStepItem);
// nextStepsService.register(nextStepItem);
}
});
};

View file

@ -0,0 +1,64 @@
'use strict';
angular.module('copayApp.services').factory('bitcoincomService', function($http, $log, lodash, moment, storageService, configService, platformInfo, nextStepsService, homeIntegrationsService) {
var root = {};
var credentials = {};
/*
* Development: 'testnet'
* Production: 'livenet'
*/
credentials.NETWORK = 'livenet';
//credentials.NETWORK = 'testnet';
if (credentials.NETWORK == 'testnet') {
credentials.BITPAY_API_URL = "https://test.bitpay.com";
} else {
credentials.BITPAY_API_URL = "https://bitpay.com";
};
var homeItem = {
name: 'bitcoincom',
title: 'Explore Bitcoin.com',
icon: 'icon-bitcoincom',
sref: 'tabs.bitcoin-com',
};
var nextStepItem = {
name: 'bitcoincom',
title: 'Explore Bitcoin.com',
icon: 'icon-bitcoincom',
sref: 'tabs.bitcoin-com',
};
var _getBitPay = function(endpoint) {
return {
method: 'GET',
url: credentials.BITPAY_API_URL + endpoint,
headers: {
'content-type': 'application/json'
}
};
};
var _postBitPay = function(endpoint, data) {
return {
method: 'POST',
url: credentials.BITPAY_API_URL + endpoint,
headers: {
'content-type': 'application/json'
},
data: data
};
};
root.getNetwork = function() {
return credentials.NETWORK;
};
var register = function() {
nextStepsService.register(nextStepItem);
};
register();
return root;
});

View file

@ -23,9 +23,9 @@ angular.module('copayApp.services').factory('buyAndSellService', function($log,
if (linkedServices.length == 0) {
nextStepsService.register({
title: 'Buy or Sell Bitcoin',
title: 'Buy Bitcoin',
name: 'buyandsell',
icon: 'icon-buy-bitcoin',
icon: 'icon-buy-bitcoin2',
sref: 'tabs.buyandsell',
});
} else {