Unify the translation service
This commit is contained in:
parent
a397e83cf0
commit
71e530f535
1 changed files with 8 additions and 8 deletions
|
|
@ -6,7 +6,7 @@ angular
|
||||||
.module('bitcoincom.services')
|
.module('bitcoincom.services')
|
||||||
.factory('shapeshiftService', shapeshiftService);
|
.factory('shapeshiftService', shapeshiftService);
|
||||||
|
|
||||||
function shapeshiftService(shapeshiftApiService, gettext) {
|
function shapeshiftService(shapeshiftApiService, gettextCatalog) {
|
||||||
|
|
||||||
var service = {
|
var service = {
|
||||||
// Variables
|
// Variables
|
||||||
|
|
@ -45,7 +45,7 @@ angular
|
||||||
.marketInfo(service.coinIn, service.coinOut)
|
.marketInfo(service.coinIn, service.coinOut)
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
if (!response || response.error) {
|
if (!response || response.error) {
|
||||||
handleError(response, 'Invalid response', cb);
|
handleError(response, 'Invalid response from Shapeshift', cb);
|
||||||
} else {
|
} else {
|
||||||
service.marketData = response;
|
service.marketData = response;
|
||||||
service.rateString = service.marketData.rate.toString() + ' ' + coinOut.toUpperCase() + '/' + coinIn.toUpperCase();
|
service.rateString = service.marketData.rate.toString() + ' ' + coinOut.toUpperCase() + '/' + coinIn.toUpperCase();
|
||||||
|
|
@ -57,11 +57,11 @@ angular
|
||||||
function shiftIt(coinIn, coinOut, withdrawalAddress, returnAddress, amount, cb) {
|
function shiftIt(coinIn, coinOut, withdrawalAddress, returnAddress, amount, cb) {
|
||||||
// Test if the amount is correct depending on the min and max
|
// Test if the amount is correct depending on the min and max
|
||||||
if (!amount || typeof amount !== 'number') {
|
if (!amount || typeof amount !== 'number') {
|
||||||
cb(new Error(gettext('Amount is not defined'))));
|
cb(new Error(gettextCatalog.getString('Amount is not defined'))));
|
||||||
} else if (amount < service.marketData.minimum) {
|
} else if (amount < service.marketData.minimum) {
|
||||||
cb(new Error(gettext('Amount is below the minimun')));
|
cb(new Error(gettextCatalog.getString('Amount is below the minimun')));
|
||||||
} else if (amount > service.marketData.maxLimit) {
|
} else if (amount > service.marketData.maxLimit) {
|
||||||
cb(new Error(gettext('Amount is above the limit')));
|
cb(new Error(gettextCatalog.getString('Amount is above the limit')));
|
||||||
} else {
|
} else {
|
||||||
// Init service data
|
// Init service data
|
||||||
service.withdrawalAddress = withdrawalAddress;
|
service.withdrawalAddress = withdrawalAddress;
|
||||||
|
|
@ -79,13 +79,13 @@ angular
|
||||||
shapeshiftApiService.NormalTx(service).then(function onResponse(response) {
|
shapeshiftApiService.NormalTx(service).then(function onResponse(response) {
|
||||||
// If error, return it
|
// If error, return it
|
||||||
if (!response || response.error) {
|
if (!response || response.error) {
|
||||||
handleError(response, gettext('Invalid response from Shapeshift'), cb);
|
handleError(response, gettextCatalog.getString('Invalid response from Shapeshift'), cb);
|
||||||
} else {
|
} else {
|
||||||
var txData = response;
|
var txData = response;
|
||||||
|
|
||||||
// If the content is not that it was expected, get back an error
|
// If the content is not that it was expected, get back an error
|
||||||
if (!txData || !txData.orderId || !txData.deposit) {
|
if (!txData || !txData.orderId || !txData.deposit) {
|
||||||
cb(new Error(gettext('Invalid response from Shapeshift')));
|
cb(new Error(gettextCatalog.getString('Invalid response from Shapeshift')));
|
||||||
} else {
|
} else {
|
||||||
// Get back the data
|
// Get back the data
|
||||||
service.depositInfo = txData;
|
service.depositInfo = txData;
|
||||||
|
|
@ -103,7 +103,7 @@ angular
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
cb(new Error(gettext('Invalid address')));
|
cb(new Error(gettextCatalog.getString('Invalid address')));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue