forked from apis-is/apis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code cleanup. First set of doc changes
- Loading branch information
1 parent
db186cc
commit f290fdd
Showing
15 changed files
with
125 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,38 @@ | ||
var parseString = require('xml2js').parseString; | ||
exports.setup = function(){ | ||
server.get({path: '/currency/lb', version: '1.0.0'}, getCurrencies); | ||
}; | ||
|
||
var getCurrencies = function(req, res, next){ | ||
res.charSet = 'utf8'; | ||
res.charSet = 'utf8'; | ||
|
||
// A = Almennt gengi, S = Seðlagengi | ||
var type = req.params['type'] || 'A'; | ||
// A = Almennt gengi, S = Seðlagengi | ||
var type = req.params['type'] || 'A'; | ||
|
||
request.get({ | ||
url: 'http://www.landsbankinn.is/modules/markets/services/XMLGengi.asmx/NyjastaGengiByType?strTegund=' + type | ||
}, function(err, response, xml) { | ||
if (err) { | ||
res.json(500, { error: 'Something went wrong' }); | ||
return next(); | ||
} | ||
request.get({ | ||
url: 'http://www.landsbankinn.is/modules/markets/services/XMLGengi.asmx/NyjastaGengiByType?strTegund=' + type | ||
}, function(err, response, xml) { | ||
if (err) { | ||
res.json(500, { error: 'Something went wrong' }); | ||
return next(); | ||
} | ||
|
||
var currencies = []; | ||
parseString(xml, { explicitRoot: false }, function(err, result) { | ||
var arr = result.GjaldmidillRow; | ||
for (var i = 0, currency; currency = arr[i]; i++) { | ||
currencies.push({ | ||
shortName: currency.Mynt[0], | ||
longName: currency.Heiti[0], | ||
value: parseFloat(currency.Midgengi), | ||
askValue: parseFloat(currency.Kaup), | ||
bidValue: parseFloat(currency.Sala), | ||
changeCur: parseFloat(currency.Breyting[0]), | ||
changePer: parseFloat((parseFloat(currency.Breyting) / parseFloat(currency.Midgengi)).toFixed(2)) | ||
}); | ||
} | ||
res.json(200, { results: currencies }); | ||
next(); | ||
}); | ||
}); | ||
}; | ||
|
||
exports.setup = function(){ | ||
server.get({path: '/currency/lb', version: '1.0.0'}, getCurrencies); | ||
var currencies = []; | ||
parseString(xml, { explicitRoot: false }, function(err, result) { | ||
var arr = result.GjaldmidillRow; | ||
for (var i = 0, currency; currency = arr[i]; i++) { | ||
currencies.push({ | ||
shortName: currency.Mynt[0], | ||
longName: currency.Heiti[0], | ||
value: parseFloat(currency.Midgengi), | ||
askValue: parseFloat(currency.Kaup), | ||
bidValue: parseFloat(currency.Sala), | ||
changeCur: parseFloat(currency.Breyting[0]), | ||
changePer: parseFloat((parseFloat(currency.Breyting) / parseFloat(currency.Midgengi)).toFixed(2)) | ||
}); | ||
} | ||
res.json(200, { results: currencies }); | ||
return next(); | ||
}); | ||
} | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.