Glidera - buy/sell
This commit is contained in:
parent
4ed39a22d4
commit
e266ded1d1
10 changed files with 309 additions and 32 deletions
29
public/views/buyGlidera.html
Normal file
29
public/views/buyGlidera.html
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<div
|
||||
class="topbar-container"
|
||||
ng-include="'views/includes/topbar.html'"
|
||||
ng-init="titleSection='Buy'; goBackToState = 'glidera'">
|
||||
</div>
|
||||
|
||||
|
||||
<div class="content glidera" ng-controller="buyGlideraController as buy">
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
|
||||
<h1>Buy Bitcoin</h1>
|
||||
|
||||
<form name="form" ng-submit="buy.getSellPrice(index.glideraToken, {'qty': qty})" novalidate>
|
||||
<label>Price
|
||||
<input type="number" ng-model="qty">
|
||||
<input type="number" ng-model="fiat">
|
||||
</label>
|
||||
<input type="submit" value="Buy">
|
||||
</form>
|
||||
|
||||
<div ng-show="buyPrice">
|
||||
{{buyPrice}} --
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="extra-margin-bottom"></div>
|
||||
48
public/views/glidera.html
Normal file
48
public/views/glidera.html
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
|
||||
<div
|
||||
class="topbar-container"
|
||||
ng-include="'views/includes/topbar.html'"
|
||||
ng-init="titleSection='Glidera'; closeToHome = true">
|
||||
</div>
|
||||
|
||||
|
||||
<div class="content glidera" ng-controller="glideraController as glidera">
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
|
||||
<a href ng-if="!index.glideraToken" ng-click="$root.go('preferencesGlidera')">
|
||||
Connect to Glidera
|
||||
</a>
|
||||
|
||||
<div ng-if="index.glideraToken" ng-init="glidera.init(index.glideraToken)">
|
||||
Connected to Glidera - <a href ng-click="$root.go('preferencesGlidera')">Preferences</a>
|
||||
|
||||
<div>
|
||||
<button class="" ng-click="$root.go('buyGlidera')">Buy</button>
|
||||
<button class="" ng-click="$root.go('sellGlidera')">Sell</button>
|
||||
</div>
|
||||
|
||||
<h2>Transactions</h2>
|
||||
<ul>
|
||||
<li ng-repeat="tx in txs">
|
||||
{{tx.transactionUuid}} --
|
||||
{{tx.transactionDate}} --
|
||||
{{tx.type}} --
|
||||
{{tx.price}} --
|
||||
{{tx.subtotal}} --
|
||||
{{tx.fees}} --
|
||||
{{tx.total}} --
|
||||
{{tx.currency}} --
|
||||
{{tx.estimatedDeliveryDate}} --
|
||||
{{tx.transactionHash}} --
|
||||
{{tx.status}}<br><br>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="extra-margin-bottom"></div>
|
||||
|
|
@ -1,25 +1,28 @@
|
|||
<div
|
||||
class="topbar-container"
|
||||
ng-include="'views/includes/topbar.html'"
|
||||
ng-init="titleSection='Glidera'; goBackToState = 'preferences'">
|
||||
ng-init="titleSection='Preferences Glidera'; goBackToState = 'glidera'">
|
||||
</div>
|
||||
|
||||
<div class="content preferences p20v" ng-controller="preferencesGlideraController as glidera">
|
||||
|
||||
<div class="row" ng-init="glidera.init(index.glideraToken)">
|
||||
<div class="large-12 columns">
|
||||
<a
|
||||
class="button outline dark-gray"
|
||||
ng-click="$root.openExternalLink(glidera.authenticateUrl)">
|
||||
Get OAuth Code
|
||||
</a>
|
||||
|
||||
<form name="form" ng-submit="glidera.submit(code)" novalidate>
|
||||
<label>OAuth Code
|
||||
<input type="text" ng-model="code">
|
||||
</label>
|
||||
<input type="submit" value="Get Access Token">
|
||||
</form>
|
||||
<div ng-show="!index.glideraToken">
|
||||
<a
|
||||
class="button outline dark-gray"
|
||||
ng-click="$root.openExternalLink(glidera.authenticateUrl)">
|
||||
Get OAuth Code
|
||||
</a>
|
||||
|
||||
<form name="form" ng-submit="glidera.submit(code)" novalidate>
|
||||
<label>OAuth Code
|
||||
<input type="text" ng-model="code">
|
||||
</label>
|
||||
<input type="submit" value="Get Access Token">
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div ng-show="index.glideraToken">
|
||||
<a
|
||||
|
|
|
|||
30
public/views/sellGlidera.html
Normal file
30
public/views/sellGlidera.html
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<div
|
||||
class="topbar-container"
|
||||
ng-include="'views/includes/topbar.html'"
|
||||
ng-init="titleSection='Sell'; goBackToState = 'glidera'">
|
||||
</div>
|
||||
|
||||
|
||||
<div class="content glidera" ng-controller="sellGlideraController as sell">
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
|
||||
<h1>Sell Bitcoin</h1>
|
||||
|
||||
<form name="form" ng-submit="sell.getSellPrice(index.glideraToken, {'qty': qty, 'fiat': fiat})" novalidate>
|
||||
<label>Price
|
||||
<input type="number" ng-model="qty">
|
||||
<input type="number" ng-model="fiat">
|
||||
</label>
|
||||
<input type="submit" value="Sell">
|
||||
</form>
|
||||
|
||||
<div ng-show="sellPrice">
|
||||
{{sellPrice}} --
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="extra-margin-bottom"></div>
|
||||
|
|
@ -113,9 +113,8 @@
|
|||
</div>
|
||||
<div class="right">
|
||||
|
||||
<a ng-if="index.glideraToken"
|
||||
class="button outline round light-gray tiny preferences-icon m0"
|
||||
ng-click="$root.go('preferencesGlidera')">
|
||||
<a class="button outline round light-gray tiny m0"
|
||||
ng-click="$root.go('glidera')">
|
||||
Glidera
|
||||
</a>
|
||||
|
||||
|
|
|
|||
13
src/js/controllers/buyGlidera.js
Normal file
13
src/js/controllers/buyGlidera.js
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('buyGlideraController',
|
||||
function() {
|
||||
|
||||
this.getBuyPrice = function(token, price) {
|
||||
var self = this;
|
||||
glideraService.buyPrice(token, price, function(error, sellPrice) {
|
||||
self.sellPrice = sellPrice;
|
||||
});
|
||||
};
|
||||
|
||||
});
|
||||
13
src/js/controllers/glidera.js
Normal file
13
src/js/controllers/glidera.js
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('glideraController',
|
||||
function(glideraService) {
|
||||
|
||||
this.init = function(token) {
|
||||
var self = this;
|
||||
glideraService.getTransactions(token, function(error, txs) {
|
||||
self.txs = txs;
|
||||
});
|
||||
};
|
||||
|
||||
});
|
||||
14
src/js/controllers/sellGlidera.js
Normal file
14
src/js/controllers/sellGlidera.js
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('sellGlideraController',
|
||||
function(glideraService) {
|
||||
|
||||
this.getSellPrice = function(token, price) {
|
||||
var self = this;
|
||||
glideraService.sellPrice(token, price, function(error, sellPrice) {
|
||||
self.sellPrice = sellPrice;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
});
|
||||
|
|
@ -288,6 +288,36 @@ angular
|
|||
},
|
||||
}
|
||||
})
|
||||
.state('glidera', {
|
||||
url: '/glidera',
|
||||
walletShouldBeComplete: true,
|
||||
needProfile: true,
|
||||
views: {
|
||||
'main': {
|
||||
templateUrl: 'views/glidera.html'
|
||||
},
|
||||
}
|
||||
})
|
||||
.state('buyGlidera', {
|
||||
url: '/buy',
|
||||
walletShouldBeComplete: true,
|
||||
needProfile: true,
|
||||
views: {
|
||||
'main': {
|
||||
templateUrl: 'views/buyGlidera.html'
|
||||
},
|
||||
}
|
||||
})
|
||||
.state('sellGlidera', {
|
||||
url: '/sell',
|
||||
walletShouldBeComplete: true,
|
||||
needProfile: true,
|
||||
views: {
|
||||
'main': {
|
||||
templateUrl: 'views/sellGlidera.html'
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
.state('preferencesGlidera', {
|
||||
url: '/preferencesGlidera',
|
||||
|
|
@ -500,9 +530,12 @@ angular
|
|||
payment: -1,
|
||||
|
||||
preferences: 11,
|
||||
glidera: 11,
|
||||
preferencesColor: 12,
|
||||
backup: 12,
|
||||
preferencesAdvanced: 12,
|
||||
buyGlidera: 12,
|
||||
sellGlidera: 12,
|
||||
preferencesGlidera: 12,
|
||||
delete: 13,
|
||||
preferencesLanguage: 12,
|
||||
|
|
|
|||
|
|
@ -30,13 +30,13 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l
|
|||
client_secret: CLIENT_SECRET,
|
||||
redirect_uri: REDIRECT_URI
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$http(req).then(function(data) {
|
||||
$log.info('Authorization Access Token: SUCCESS');
|
||||
$log.info('Glidera Authorization Access Token: SUCCESS');
|
||||
return cb(null, data);
|
||||
}, function(data) {
|
||||
$log.error('Authorization Access Token: ERROR ' + data.statusText);
|
||||
$log.error('Glidera Authorization Access Token: ERROR ' + data.statusText);
|
||||
return cb(data.statusText);
|
||||
});
|
||||
};
|
||||
|
|
@ -47,10 +47,8 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l
|
|||
url: HOST + '/api/v1' + endpoint,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json'
|
||||
},
|
||||
params: {
|
||||
access_token: token
|
||||
'Accept': 'application/json',
|
||||
'Authorization': 'Bearer ' + token
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
@ -58,10 +56,10 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l
|
|||
root.getPermissions = function(token, cb) {
|
||||
if (!token) return cb('Invalid Token');
|
||||
$http(_get('/oauth/token', token)).then(function(data) {
|
||||
$log.info('Access Token Permissions: SUCCESS');
|
||||
$log.info('Glidera Access Token Permissions: SUCCESS');
|
||||
return cb(null, data.data);
|
||||
}, function(data) {
|
||||
$log.error('Access Token Permissions: ERROR ' + data.statusText);
|
||||
$log.error('Glidera Access Token Permissions: ERROR ' + data.statusText);
|
||||
return cb(data.statusText);
|
||||
});
|
||||
};
|
||||
|
|
@ -69,10 +67,10 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l
|
|||
root.getEmail = function(token, cb) {
|
||||
if (!token) return cb('Invalid Token');
|
||||
$http(_get('/user/email', token)).then(function(data) {
|
||||
$log.info('Get Email: SUCCESS');
|
||||
$log.info('Glidera Get Email: SUCCESS');
|
||||
return cb(null, data.data);
|
||||
}, function(data) {
|
||||
$log.error('Get Email: ERROR ' + data.statusText);
|
||||
$log.error('Glidera Get Email: ERROR ' + data.statusText);
|
||||
return cb(data.statusText);
|
||||
});
|
||||
};
|
||||
|
|
@ -80,10 +78,10 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l
|
|||
root.getPersonalInfo = function(token, cb) {
|
||||
if (!token) return cb('Invalid Token');
|
||||
$http(_get('/user/personalinfo', token)).then(function(data) {
|
||||
$log.info('Get Personal Info: SUCCESS');
|
||||
$log.info('Glidera Get Personal Info: SUCCESS');
|
||||
return cb(null, data.data);
|
||||
}, function(data) {
|
||||
$log.error('Get Personal Info: ERROR ' + data.statusText);
|
||||
$log.error('Glidera Get Personal Info: ERROR ' + data.statusText);
|
||||
return cb(data.statusText);
|
||||
});
|
||||
};
|
||||
|
|
@ -91,10 +89,10 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l
|
|||
root.getStatus = function(token, cb) {
|
||||
if (!token) return cb('Invalid Token');
|
||||
$http(_get('/user/status', token)).then(function(data) {
|
||||
$log.info('User Status: SUCCESS');
|
||||
$log.info('Glidera User Status: SUCCESS');
|
||||
return cb(null, data.data);
|
||||
}, function(data) {
|
||||
$log.error('User Status: ERROR ' + data.statusText);
|
||||
$log.error('Glidera User Status: ERROR ' + data.statusText);
|
||||
return cb(data.statusText);
|
||||
});
|
||||
};
|
||||
|
|
@ -102,10 +100,107 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l
|
|||
root.getLimits = function(token, cb) {
|
||||
if (!token) return cb('Invalid Token');
|
||||
$http(_get('/user/limits', token)).then(function(data) {
|
||||
$log.info('Transaction Limits: SUCCESS');
|
||||
$log.info('Glidera Transaction Limits: SUCCESS');
|
||||
return cb(null, data.data);
|
||||
}, function(data) {
|
||||
$log.error('Transaction Limits: ERROR ' + data.statusText);
|
||||
$log.error('Glidera Transaction Limits: ERROR ' + data.statusText);
|
||||
return cb(data.statusText);
|
||||
});
|
||||
};
|
||||
|
||||
root.getTransactions = function(token, cb) {
|
||||
if (!token) return cb('Invalid Token');
|
||||
$http(_get('/transaction', token)).then(function(data) {
|
||||
$log.info('Glidera Transaction: SUCCESS');
|
||||
return cb(null, data.data);
|
||||
}, function(data) {
|
||||
$log.error('Glidera Transaction: ERROR ' + data.statusText);
|
||||
return cb(data.statusText);
|
||||
});
|
||||
};
|
||||
|
||||
root.getSellAddress = function(token, cb) {
|
||||
if (!token) return cb('Invalid Token');
|
||||
$http(_get('/user/create_sell_address', token)).then(function(data) {
|
||||
$log.info('Glidera Create Sell Address: SUCCESS');
|
||||
return cb(null, data.data);
|
||||
}, function(data) {
|
||||
$log.error('Glidera Create Sell Address: ERROR ' + data.statusText);
|
||||
return cb(data.statusText);
|
||||
});
|
||||
};
|
||||
|
||||
var _post = function(endpoint, token, data) {
|
||||
return {
|
||||
method: 'POST',
|
||||
url: HOST + '/api/v1' + endpoint,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
'Authorization': 'Bearer ' + token
|
||||
},
|
||||
data: data
|
||||
};
|
||||
};
|
||||
|
||||
root.sellPrice = function(token, price, cb) {
|
||||
var data = {
|
||||
qty: price.qty,
|
||||
fiat: price.fiat
|
||||
};
|
||||
$http(_post('/prices/sell', token, data)).then(function(data) {
|
||||
$log.info('Glidera Sell Price: SUCCESS');
|
||||
return cb(null, data);
|
||||
}, function(data) {
|
||||
$log.error('Glidera Sell Price: ERROR ' + data.statusText);
|
||||
return cb(data.statusText);
|
||||
});
|
||||
};
|
||||
|
||||
root.sell = function(token, data, cb) {
|
||||
var data = {
|
||||
refundAddress: data.refundAddress,
|
||||
signedTransaction: data.signedTransaction,
|
||||
priceUuid: data.priceUuid,
|
||||
useCurrentPrice: data.useCurrentPrice,
|
||||
ip: data.ip
|
||||
};
|
||||
$http(_post('/prices/buy', token, data)).then(function(data) {
|
||||
$log.info('Glidera Buy: SUCCESS');
|
||||
return cb(null, data);
|
||||
}, function(data) {
|
||||
$log.error('Glidera Buy: ERROR ' + data.statusText);
|
||||
return cb(data.statusText);
|
||||
});
|
||||
};
|
||||
|
||||
root.buyPrice = function(token, price, cb) {
|
||||
var data = {
|
||||
qty: price.qty,
|
||||
fiat: price.fiat
|
||||
};
|
||||
$http(_post('/prices/buy', token, data)).then(function(data) {
|
||||
$log.info('Glidera Buy Price: SUCCESS');
|
||||
return cb(null, data);
|
||||
}, function(data) {
|
||||
$log.error('Glidera Buy Price: ERROR ' + data.statusText);
|
||||
return cb(data.statusText);
|
||||
});
|
||||
};
|
||||
|
||||
root.buy = function(token, data, cb) {
|
||||
var data = {
|
||||
destinationAddress: data.destinationAddress,
|
||||
qty: data.qty,
|
||||
priceUuid: data.priceUuid,
|
||||
useCurrentPrice: data.useCurrentPrice,
|
||||
ip: data.ip
|
||||
};
|
||||
$http(_post('/prices/buy', token, data)).then(function(data) {
|
||||
$log.info('Glidera Buy: SUCCESS');
|
||||
return cb(null, data);
|
||||
}, function(data) {
|
||||
$log.error('Glidera Buy: ERROR ' + data.statusText);
|
||||
return cb(data.statusText);
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue