diff --git a/src/index.js b/src/index.js index 3efc4a1..1f380b5 100644 --- a/src/index.js +++ b/src/index.js @@ -6,11 +6,11 @@ import _self from './lib/self' -import requestStoreApi from './methods/request-store-api' -import requestModulesApi from './methods/request-modules-api' -import requestSearchApi from './methods/request-search-api' -import requestGraphsApi from './methods/request-graphs-api' -import requestPlatformApi from './methods/request-platform-api' +import store from './methods/store' +import modules from './methods/modules' +import search from './methods/search' +import graphs from './methods/graphs' +import platform from './methods/platform' /** * JS client for E-Com Plus REST APIs. @@ -32,11 +32,11 @@ import requestPlatformApi from './methods/request-platform-api' export { _self, - requestStoreApi, - requestModulesApi, - requestGraphsApi, - requestSearchApi, - requestPlatformApi + store, + modules, + graphs, + search, + platform } /** diff --git a/src/methods/request-graphs-api.js b/src/methods/graphs.js similarity index 93% rename from src/methods/request-graphs-api.js rename to src/methods/graphs.js index dc16abd..6d74437 100644 --- a/src/methods/request-graphs-api.js +++ b/src/methods/graphs.js @@ -3,7 +3,7 @@ import { IS_BROWSER, API_GRAPHS } from './../lib/constants' import request from './../lib/request' // returns axios request promise -const requestGraphsApi = ( +const graphs = ( url, storeId = _config.get('store_id'), axiosConfig @@ -21,7 +21,7 @@ const requestGraphsApi = ( /** * @method * @memberof ecomClient - * @name requestGraphsApi + * @name graphs * @description Send HTTP GET request to * [E-Com Plus Graphs REST API]{@link https://developers.e-com.plus/docs/api/#/graphs/}. * @@ -42,4 +42,4 @@ const requestGraphsApi = ( */ -export default requestGraphsApi +export default graphs diff --git a/src/methods/request-modules-api.js b/src/methods/modules.js similarity index 92% rename from src/methods/request-modules-api.js rename to src/methods/modules.js index 5c2b666..70b997f 100644 --- a/src/methods/request-modules-api.js +++ b/src/methods/modules.js @@ -3,7 +3,7 @@ import { API_MODULES } from './../lib/constants' import request from './../lib/request' // returns axios request promise -const requestModulesApi = ( +const modules = ( url, method = 'get', data, @@ -23,7 +23,7 @@ const requestModulesApi = ( /** * @method * @memberof ecomClient - * @name requestModulesApi + * @name modules * @description Send HTTP GET request to * [E-Com Plus Modules REST API]{@link https://developers.e-com.plus/docs/api/#/modules/}. * @@ -44,4 +44,4 @@ const requestModulesApi = ( */ -export default requestModulesApi +export default modules diff --git a/src/methods/request-platform-api.js b/src/methods/platform.js similarity index 93% rename from src/methods/request-platform-api.js rename to src/methods/platform.js index 9b359c3..adc9039 100644 --- a/src/methods/request-platform-api.js +++ b/src/methods/platform.js @@ -2,7 +2,7 @@ import { _config } from '@ecomplus/utils' import { IS_BROWSER, API_PLATFORM, API_PLATFORM_CACHE } from './../lib/constants' import request from './../lib/request' -const requestPlatformApi = ( +const platform = ( url, storeId = _config.get('store_id'), axiosConfig @@ -34,7 +34,7 @@ const requestPlatformApi = ( let { status } = response if (!status || status < 100 || status >= 500) { // resend request with same params - return requestPlatformApi( + return platform( url, storeId, axiosConfig @@ -49,7 +49,7 @@ const requestPlatformApi = ( /** * @method * @memberof ecomClient - * @name requestPlatformApi + * @name platform * @description Send HTTP GET request to * [E-Com Plus Platform REST API]{@link https://developers.e-com.plus/docs/api/#/platform/}. * @@ -70,4 +70,4 @@ const requestPlatformApi = ( */ -export default requestPlatformApi +export default platform diff --git a/src/methods/request-search-api.js b/src/methods/search.js similarity index 90% rename from src/methods/request-search-api.js rename to src/methods/search.js index 59456f9..4d0db62 100644 --- a/src/methods/request-search-api.js +++ b/src/methods/search.js @@ -3,7 +3,7 @@ import { IS_BROWSER, API_SEARCH } from './../lib/constants' import request from './../lib/request' // returns axios request promise -const requestSearchApi = ( +const search = ( url, method = 'get', data, @@ -25,7 +25,7 @@ const requestSearchApi = ( /** * @method * @memberof ecomClient - * @name requestSearchApi + * @name search * @description Send HTTP request to * [E-Com Plus Search REST API]{@link https://developers.e-com.plus/docs/api/#/search/}. * @@ -45,7 +45,7 @@ const requestSearchApi = ( * @example // Simple search request (ELS URI Search) -ecomClient.requestSearchApi('/items.json?q=sku:123') +ecomClient.search('/items.json?q=sku:123') .then(response => console.log(response.data)) .catch(error => { console.error(error) @@ -69,10 +69,10 @@ const data = { } } } -ecomClient.requestSearchApi('/items.json', 'post', data) +ecomClient.search('/items.json', 'post', data) .then(({ data, status }) => console.log(status, data)) .catch(error => console.error(error)) */ -export default requestSearchApi +export default search diff --git a/src/methods/request-store-api.js b/src/methods/store.js similarity index 94% rename from src/methods/request-store-api.js rename to src/methods/store.js index 451e000..8c389c6 100644 --- a/src/methods/request-store-api.js +++ b/src/methods/store.js @@ -5,7 +5,7 @@ import request from './../lib/request' // save Store Cache API status let isCacheOnline = true -const requestStoreApi = ( +const store = ( url, authenticationId, accessToken, @@ -63,7 +63,7 @@ const requestStoreApi = ( isCacheOnline = false setTimeout(() => { isCacheOnline = true }, 30000) // resend request with same params - return requestStoreApi( + return store( url, authenticationId, accessToken, @@ -82,7 +82,7 @@ const requestStoreApi = ( /** * @method * @memberof ecomClient - * @name requestStoreApi + * @name store * @description Send HTTP request to * [E-Com Plus Store REST API]{@link https://developers.e-com.plus/docs/api/#/store/}. * @@ -104,7 +104,7 @@ const requestStoreApi = ( * @example // Simple GET request (public) -ecomClient.requestStoreApi('/products.json') +ecomClient.store('/products.json') .then(response => console.log(response.data)) .catch(error => { console.error(error) @@ -118,7 +118,7 @@ ecomClient.requestStoreApi('/products.json') // Authenticated request this.authenticationId = 'myAuthenticationId' this.accessToken = 'myAccessToken' -ecomClient.requestStoreApi( +ecomClient.store( '/products.json', this.authenticationId, this.accessToken, @@ -130,4 +130,4 @@ ecomClient.requestStoreApi( */ -export default requestStoreApi +export default store