Skip to content

Commit

Permalink
update getMarketSnap and getMarketsByCountry endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
GustavoFernandesTE committed Jul 8, 2024
1 parent aa3560a commit 4610131
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion tests/coverage/lcov-report/ipo.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ <h1><a href="index.html">All files</a> ipo.js</h1>
let linkAPI = 'https://api.tradingeconomics.com/ipo/';
&nbsp;
<span class="missing-if-branch" title="if path not taken" >I</span>if (ticker &amp;&amp; country) {
<span class="cstat-no" title="statement not covered" > throw new ParameterError('You cannot use both ticker and country parameters together');</span>
<span class="cstat-no" title="statement not covered" > throw new Error('You cannot use both ticker and country parameters together');</span>
}
&nbsp;
if (ticker) {
Expand Down
2 changes: 1 addition & 1 deletion tests/coverage/lcov-report/stockSplits.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ <h1><a href="index.html">All files</a> stockSplits.js</h1>
let linkAPI = 'https://api.tradingeconomics.com/splits/';
&nbsp;
<span class="missing-if-branch" title="if path not taken" >I</span>if (ticker &amp;&amp; country) {
<span class="cstat-no" title="statement not covered" > throw new ParameterError('You cannot use both ticker and country parameters together');</span>
<span class="cstat-no" title="statement not covered" > throw new Error('You cannot use both ticker and country parameters together');</span>
}
&nbsp;
if (ticker) {
Expand Down
2 changes: 1 addition & 1 deletion tradingeconomics/ipo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
20 changes: 14 additions & 6 deletions tradingeconomics/marketSnap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
*******************************************************************************************************/
Expand Down Expand Up @@ -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){
Expand Down Expand Up @@ -102,16 +101,25 @@ function getMarketSnap(){

}

//This function builds the path to get the API request:
/******************************************************************************************************
parameters:
country
example:
getMarketsByCountry(country ='nigeria');
*******************************************************************************************************/

function getMarketsByCountry(){

try {
var Data = '';
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');
Expand Down
2 changes: 1 addition & 1 deletion tradingeconomics/stockSplits.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 4610131

Please sign in to comment.