/**
* Gets API url
* @param {string} type - 'search' or 'suggestion'
* @returns {string} - The API url
*/
const getApiUrl = (type) => {
var url = boostPFSConfig.api.filterUrl;
switch (type) {
case 'search':
url = boostPFSConfig.api.searchUrl;
break;
case 'suggestion':
url = boostPFSConfig.api.suggestionUrl;
break;
case 'analytics':
url = boostPFSConfig.api.analyticsUrl;
break;
}
return url;
};
/**
* Set the locale param for our api
* @param {Object} params - The request params
*/
const setApiLocaleParams = (params) => {
/* If this store has the multi-language feature */
if (Settings.general.hasOwnProperty('published_locales')
&& Object.keys(Settings.general.published_locales).length > 1
&& typeof Settings.general.current_locale != 'undefined') {
/* Pass the locale param to our api. */
params.locale = Settings.getSettingValue('general.current_locale');
}
return params;
}
/**
* Helper functions for API
*/
const Api = {
getApiUrl: getApiUrl,
setApiLocaleParams: setApiLocaleParams
}
export default Api;