From 4610131b6fa24979446622365d3ddb853c28091f Mon Sep 17 00:00:00 2001 From: GustavoFernandesTE <113916236+GustavoFernandesTE@users.noreply.github.com> Date: Mon, 8 Jul 2024 16:02:32 +0000 Subject: [PATCH] update getMarketSnap and getMarketsByCountry endpoint --- tests/coverage/lcov-report/ipo.js.html | 2 +- .../coverage/lcov-report/stockSplits.js.html | 2 +- tradingeconomics/ipo.js | 2 +- tradingeconomics/marketSnap.js | 20 +++++++++++++------ tradingeconomics/stockSplits.js | 2 +- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/tests/coverage/lcov-report/ipo.js.html b/tests/coverage/lcov-report/ipo.js.html index 1a68d20..ab8ebad 100644 --- a/tests/coverage/lcov-report/ipo.js.html +++ b/tests/coverage/lcov-report/ipo.js.html @@ -222,7 +222,7 @@

All files ipo.js

let linkAPI = 'https://api.tradingeconomics.com/ipo/';   Iif (ticker && country) { - throw new ParameterError('You cannot use both ticker and country parameters together'); + throw new Error('You cannot use both ticker and country parameters together'); }   if (ticker) { diff --git a/tests/coverage/lcov-report/stockSplits.js.html b/tests/coverage/lcov-report/stockSplits.js.html index f312899..7a1f8f3 100644 --- a/tests/coverage/lcov-report/stockSplits.js.html +++ b/tests/coverage/lcov-report/stockSplits.js.html @@ -222,7 +222,7 @@

All files stockSplits.js

let linkAPI = 'https://api.tradingeconomics.com/splits/';   Iif (ticker && country) { - throw new ParameterError('You cannot use both ticker and country parameters together'); + throw new Error('You cannot use both ticker and country parameters together'); }   if (ticker) { diff --git a/tradingeconomics/ipo.js b/tradingeconomics/ipo.js index d30e300..0e756d3 100644 --- a/tradingeconomics/ipo.js +++ b/tradingeconomics/ipo.js @@ -25,7 +25,7 @@ function getIpo(){ let linkAPI = 'https://api.tradingeconomics.com/ipo/'; if (ticker && country) { - throw new ParameterError('You cannot use both ticker and country parameters together'); + throw new Error('You cannot use both ticker and country parameters together'); } if (ticker) { diff --git a/tradingeconomics/marketSnap.js b/tradingeconomics/marketSnap.js index 7b52cb9..bb07bfe 100644 --- a/tradingeconomics/marketSnap.js +++ b/tradingeconomics/marketSnap.js @@ -32,9 +32,8 @@ global.cross = null; getMarketSnap(peers_symbol ='aapl:us' ); getMarketSnap(components_symbol ='psi20:ind'); getMarketSnap(country ='japan'); - getMarketSnap(cross ='eur'); - getMarketSnap(country ='united states'); - getMarketSnap(search_term ='japan', category = 'index, markets'); + getMarketSnap(country =['japan', 'portugal]); + getMarketSnap(cross ='eur'); getMarketSnap(search_term ='japan', category = 'index, markets'); *******************************************************************************************************/ @@ -73,7 +72,7 @@ function getMarketSnap(){ url = '/markets/components/' + components_symbol; } if(country != null){ - url = '/markets/country/' + country; + url = '/markets/stocks/country/' + country; } if(search_term != null){ @@ -102,6 +101,15 @@ function getMarketSnap(){ } +//This function builds the path to get the API request: +/****************************************************************************************************** + parameters: + country + + example: + getMarketsByCountry(country ='nigeria'); +*******************************************************************************************************/ + function getMarketsByCountry(){ try { @@ -109,9 +117,9 @@ function getMarketsByCountry(){ var url = ''; if(country != null){ - url = '/markets/stocks/country/' + country; + url = '/markets/country/' + country; } else { - throw new ParameterError('Missing country parameters.'); + throw new Error('Missing country parameters.'); } Data = url_base + url + '?c=' + apikey.replace (' ','%20'); diff --git a/tradingeconomics/stockSplits.js b/tradingeconomics/stockSplits.js index 90dd937..58f4586 100644 --- a/tradingeconomics/stockSplits.js +++ b/tradingeconomics/stockSplits.js @@ -25,7 +25,7 @@ function getStockSplits(){ let linkAPI = 'https://api.tradingeconomics.com/splits/'; if (ticker && country) { - throw new ParameterError('You cannot use both ticker and country parameters together'); + throw new Error('You cannot use both ticker and country parameters together'); } if (ticker) {