diff --git a/scripts/product-api.js b/scripts/product-api.js index 3dcfe099..504b9f3f 100644 --- a/scripts/product-api.js +++ b/scripts/product-api.js @@ -1,7 +1,8 @@ // This file contains all the product API endpoints +export const API_HOST = 'https://publish-p154883-e1640201.adobeaemcloud.com'; // prod -export const API_HOST = 'https://www.ingredion.com'; +// export const API_HOST = 'https://www.ingredion.com'; // stage - testing (todo: remove before go-live) // export const API_HOST = 'https://ingredion-stage65.adobecqms.net'; @@ -14,61 +15,61 @@ export const getUrlParams = () => { }; export const DEFAULT_PATHS = { - POPULATE_INGREDIENT_CATEGORY_SUBCATEGORY: (region, locale) => `/content/ingredion-com/${region}/${locale}/jcr:content/header.search.json?initialTab=`, - SEARCH_INGREDIENT_BY_CATEGORY_SUBCATEGORY: (region, locale) => `/content/ingredion-com/${region}/${locale}/ingredients/ingredient-finder/jcr:content/par/ingredientfinder.search.json`, - INGREDIENT_SEARCH_TYPEAHEAD: (region, locale) => `/content/ingredion-com/${region}/${locale}.ingredient-search-typeahead.json?initialTab=`, - PRODUCT_DETAILS: (region, locale) => `/content/ingredion-com/${region}/${locale}/search/jcr:content/searchResults.ingredients.json`, - ALL_DOCUMENTS: (region, locale) => `/content/ingredion-com/${region}/${locale}/search/jcr:content/searchResults.view.json`, - DOWNLOAD_DOCUMENTS: (region) => `/content/ingredion-com/ingredients/${region}`, - DOWNLOAD_ALL_DOCUMENTS: (region) => `/content/ingredion-com/ingredients/${region}`, - DOWNLOAD_ALL_DOCUMENTS_FROM_SEARCH: (region, locale) => `/content/ingredion-com/${region}/${locale}/search/jcr:content/searchResults.download.zip`, - SEARCH_INGREDIENTS: (region, locale) => `/content/ingredion-com/${region}/${locale}/search/jcr:content/searchResults.ingredients.json`, - SEARCH_DOCUMENTS: (region, locale) => `/content/ingredion-com/${region}/${locale}/search/jcr:content/searchResults.techDocs.json`, - SEARCH_INGREDIENTS_BY_NAME: (region, locale) => `/content/ingredion-com/${region}/${locale}/ingredients/ingredient-finder/jcr:content/par/ingredientfinder.search.json`, + POPULATE_INGREDIENT_CATEGORY_SUBCATEGORY: (region) => `/bin/ingredion-com/headeringredient/header.${region}.search.json`, + SEARCH_INGREDIENT_BY_CATEGORY_SUBCATEGORY: (region) => `/bin/ingredion-com/ingredient-finder.${region}.search.json`, + INGREDIENT_SEARCH_TYPEAHEAD: (region) => `/bin/ingredion-com/typeaheadingredient.${region}.ingredient-search-typeahead.json`, + PRODUCT_DETAILS: (region) => `/bin/ingredion-com/searchResults.${region}.ingredients.json`, + ALL_DOCUMENTS: (region) => `/bin/ingredion-com/documents.${region}.view.json`, + DOWNLOAD_DOCUMENTS: (region) => `/bin/ingredion-com/documents-download.${region}.download.zip`, + DOWNLOAD_ALL_DOCUMENTS: (region) => `/bin/ingredion-com/documents-download.${region}.download.zip`, + DOWNLOAD_ALL_DOCUMENTS_FROM_SEARCH: (region) => `/bin/ingredion-com/documents-download.${region}.download.zip`, + SEARCH_INGREDIENTS: (region) => `/bin/ingredion-com/searchResults.${region}.ingredients.json`, + SEARCH_DOCUMENTS: (region) => `/bin/ingredion-com/tech-documents.${region}.techDocs.json`, + SEARCH_INGREDIENTS_BY_NAME: (region) => `/bin/ingredion-com/ingredient-finder.${region}.search.json`, }; export const API_PATH_OVERRIDES = { SEARCH_INGREDIENT_BY_CATEGORY_SUBCATEGORY: { - 'na-es-mx': '/content/ingredion-com/na/es-mx/ingredientes/buscador-de-ingredientes/jcr:content/par/ingredientfinder.search.json', - 'na-kerr': '/content/ingredion-com/na/kerr/ingredient-finder/jcr:content/par/ingredientfinder.search.json', - 'sa-pt-br': '/content/ingredion-com/sa/pt-br/ingredientes/busque-o-ingrediente/jcr:content/par/ingredientfinder.search.json', - 'sa-es-co': '/content/ingredion-com/sa/es-co/nuestros-ingredientes/busca-el-ingrediente/jcr:content/par/ingredientfinder.search.json', - 'sa-es-ar': '/content/ingredion-com/sa/es-ar/nuestros-ingredientes/buscador-de-ingredientes/jcr:content/par/ingredientfinder.search.json', + 'na-es-mx': '/bin/ingredion-com/ingredient-finder.na.search.json', + 'na-kerr': '/bin/ingredion-com/ingredient-finder.na.search.json', + 'sa-pt-br': '/bin/ingredion-com/ingredient-finder.sa.search.json', + 'sa-es-co': '/bin/ingredion-com/ingredient-finder.sa.search.json', + 'sa-es-ar': '/bin/ingredion-com/ingredient-finder.sa.search.json', }, PRODUCT_DETAILS: { - 'na-es-mx': '/content/ingredion-com/na/es-mx/buscar/jcr:content/searchResults.ingredients.json', - 'sa-pt-br': '/content/ingredion-com/sa/pt-br/buscar/jcr:content/searchResults.ingredients.json', + 'na-es-mx': '/bin/ingredion-com/searchResults.na.ingredients.json', + 'sa-pt-br': '/bin/ingredion-com/searchResults.sa.ingredients.json', }, ALL_DOCUMENTS: { - 'na-es-mx': '/content/ingredion-com/na/es-mx/buscar/jcr:content/searchResults.view.json', - 'sa-pt-br': '/content/ingredion-com/sa/pt-br/buscar/jcr:content/searchResults.ingredients.json', + 'na-es-mx': '/bin/ingredion-com/documents.na.view.json', + 'sa-pt-br': '/bin/ingredion-com/documents.sa.view.json', }, DOWNLOAD_DOCUMENTS: { - 'na-es-mx': '/content/ingredion-com/ingredients/es-mx', - 'na-kerr': '/content/ingredion-com/ingredients/kerr', + 'na-es-mx': '/bin/ingredion-com/documents-download.na.download.zip', + 'na-kerr': '/bin/ingredion-com/documents-download.na.download.zip', }, DOWNLOAD_ALL_DOCUMENTS: { - 'na-es-mx': '/content/ingredion-com/ingredients/es-mx', - 'na-kerr': '/content/ingredion-com/ingredients/kerr', + 'na-es-mx': '/bin/ingredion-com/documents-download.na.download.zip', + 'na-kerr': '/bin/ingredion-com/documents-download.na.download.zip', }, DOWNLOAD_ALL_DOCUMENTS_FROM_SEARCH: { - 'na-es-mx': '/content/ingredion-com/na/es-mx/buscar/jcr:content/searchResults.download.zip', - 'na-kerr': '/content/ingredion-com/na/kerr/buscar/jcr:content/searchResults.download.zip', + 'na-es-mx': '/bin/ingredion-com/documents-download.na.download.zip', + 'na-kerr': '/bin/ingredion-com/documents-download.na.download.zip', }, SEARCH_INGREDIENTS: { - 'na-es-mx': '/content/ingredion-com/na/es-mx/buscar/jcr:content/searchResults.ingredients.json', - 'sa-pt-br': '/content/ingredion-com/sa/pt-br/buscar/jcr:content/searchResults.ingredients.json', + 'na-es-mx': '/bin/ingredion-com/searchResults.na.ingredients.json', + 'sa-pt-br': '/bin/ingredion-com/searchResults.sa.ingredients.json', }, SEARCH_DOCUMENTS: { - 'na-es-mx': '/content/ingredion-com/na/es-mx/buscar/jcr:content/searchResults.techDocs.json', - 'sa-pt-br': '/content/ingredion-com/sa/pt-br/buscar/jcr:content/searchResults.techDocs.json', + 'na-es-mx': '/bin/ingredion-com/tech-documents.na.techDocs.json', + 'sa-pt-br': '/bin/ingredion-com/tech-documents.na.techDocs.json', }, SEARCH_INGREDIENTS_BY_NAME: { - 'na-es-mx': '/content/ingredion-com/na/es-mx/ingredientes/buscador-de-ingredientes/jcr:content/par/ingredientfinder.search.json', - 'na-kerr': '/content/ingredion-com/na/kerr/ingredient-finder/jcr:content/par/ingredientfinder.search.json', - 'sa-pt-br': '/content/ingredion-com/sa/pt-br/ingredientes/busque-o-ingrediente/jcr:content/par/ingredientfinder.search.json', - 'sa-es-co': '/content/ingredion-com/sa/es-co/nuestros-ingredientes/busca-el-ingrediente/jcr:content/par/ingredientfinder.search.json', - 'sa-es-ar': '/content/ingredion-com/sa/es-ar/nuestros-ingredientes/buscador-de-ingredientes/jcr:content/par/ingredientfinder.search.json', + 'na-es-mx': '/bin/ingredion-com/ingredient-finder.na.search.json', + 'na-kerr': '/bin/ingredion-com/ingredient-finder.na.search.json', + 'sa-pt-br': '/bin/ingredion-com/ingredient-finder.sa.search.json', + 'sa-es-co': '/bin/ingredion-com/ingredient-finder.sa.search.json', + 'sa-es-ar': '/bin/ingredion-com/ingredient-finder.sa.search.json', }, }; @@ -80,6 +81,7 @@ const resolveApiPath = (apiKey, region, locale) => { const defaultBuilder = DEFAULT_PATHS[apiKey]; if (defaultBuilder) return defaultBuilder(region, locale); + // eslint-disable-next-line no-console console.warn(`No path defined for ${apiKey}`); return ''; }; @@ -90,8 +92,8 @@ export const API_PRODUCT = { INGREDIENT_SEARCH_TYPEAHEAD: (region, locale) => `${API_HOST}${resolveApiPath('INGREDIENT_SEARCH_TYPEAHEAD', region, locale)}`, PRODUCT_DETAILS: (region, locale, productName) => `${API_HOST}${resolveApiPath('PRODUCT_DETAILS', region, locale)}?initialTab=&q=${productName}`, ALL_DOCUMENTS: (region, locale, productId) => `${API_HOST}${resolveApiPath('ALL_DOCUMENTS', region, locale, productId)}?productId=${productId}`, - DOWNLOAD_DOCUMENTS: (region, locale, productName) => `${API_HOST}${resolveApiPath('DOWNLOAD_DOCUMENTS', region, locale, productName)}/${productName}/jcr:content.download.zip`, - DOWNLOAD_ALL_DOCUMENTS: (region, locale, productName, productId) => `${API_HOST}${resolveApiPath('DOWNLOAD_ALL_DOCUMENTS', region, locale, productName, productId)}/${productName}/jcr:content.download.zip?productId=${productId}&documentType=all`, + DOWNLOAD_DOCUMENTS: (region, locale, productName) => `${API_HOST}${resolveApiPath('DOWNLOAD_DOCUMENTS', region, locale, productName)}`, + DOWNLOAD_ALL_DOCUMENTS: (region, locale, productName, productId) => `${API_HOST}${resolveApiPath('DOWNLOAD_ALL_DOCUMENTS', region, locale, productName, productId)}?productId=${productId}&documentType=all`, DOWNLOAD_ALL_DOCUMENTS_FROM_SEARCH: (region, locale, productId) => `${API_HOST}${resolveApiPath('DOWNLOAD_ALL_DOCUMENTS_FROM_SEARCH', region, locale, productId)}?productId=${productId}&documentType=all`, SEARCH_INGREDIENTS: (region, locale) => `${API_HOST}${resolveApiPath('SEARCH_INGREDIENTS', region, locale)}`, SEARCH_DOCUMENTS: (region, locale) => `${API_HOST}${resolveApiPath('SEARCH_DOCUMENTS', region, locale)}`,