mirror of https://github.com/BTCPrivate/copay.git
Collect email with google sheets
This commit is contained in:
parent
893fda112f
commit
ffb19e00b9
|
@ -1,9 +1,22 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('collectEmailController', function($scope, $state, $timeout, profileService, configService, walletService) {
|
||||
angular.module('copayApp.controllers').controller('collectEmailController', function($scope, $state, $log, $timeout, $http, $httpParamSerializer, profileService, configService, walletService, appConfigService) {
|
||||
|
||||
var wallet, walletId;
|
||||
$scope.data = {};
|
||||
// Get more info: https://mashe.hawksey.info/2014/07/google-sheets-as-a-database-insert-with-apps-script-using-postget-methods-with-ajax-example/
|
||||
var URL = "https://script.google.com/macros/s/AKfycbwQXvUw6-Ix0cRLMi7hBB8dlgNTCTgwfNIQRds6RypPV7dO8evW/exec";
|
||||
|
||||
var _post = function(dataSrc) {
|
||||
return {
|
||||
method: 'POST',
|
||||
url: URL,
|
||||
headers: {
|
||||
'content-type': 'application/x-www-form-urlencoded; charset=UTF-8'
|
||||
},
|
||||
data: $httpParamSerializer(dataSrc)
|
||||
};
|
||||
};
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
walletId = data.stateParams.walletId;
|
||||
|
@ -11,6 +24,21 @@ angular.module('copayApp.controllers').controller('collectEmailController', func
|
|||
$scope.data.accept = true;
|
||||
});
|
||||
|
||||
var collectEmail = function() {
|
||||
var dataSrc = {
|
||||
"App": appConfigService.nameCase,
|
||||
"Email": $scope.data.email,
|
||||
"Platform": ionic.Platform.platform(),
|
||||
"DeviceVersion": ionic.Platform.version()
|
||||
};
|
||||
|
||||
$http(_post(dataSrc)).then(function() {
|
||||
$log.info("SUCCESS: Email collected");
|
||||
}, function(err) {
|
||||
$log.error("ERROR: Could not collect email");
|
||||
});
|
||||
};
|
||||
|
||||
$scope.save = function() {
|
||||
var opts = {
|
||||
emailFor: {}
|
||||
|
@ -22,6 +50,7 @@ angular.module('copayApp.controllers').controller('collectEmailController', func
|
|||
if (err) $log.warn(err);
|
||||
configService.set(opts, function(err) {
|
||||
if (err) $log.warn(err);
|
||||
if ($scope.data.accept) collectEmail();
|
||||
$scope.goNextView();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue