Skip to content

Commit

Permalink
feat(method): new 'requestModulesApi' method
Browse files Browse the repository at this point in the history
  • Loading branch information
leomp12 committed Jul 11, 2019
1 parent 761e278 commit ae12547
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
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'
Expand All @@ -32,6 +33,7 @@ import requestPlatformApi from './methods/request-platform-api'
export {
_self,
requestStoreApi,
requestModulesApi,
requestGraphsApi,
requestSearchApi,
requestPlatformApi
Expand Down
47 changes: 47 additions & 0 deletions src/methods/request-modules-api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { _config } from '@ecomplus/utils'
import { API_MODULES } from './../lib/constants'
import request from './../lib/request'

// returns axios request promise
const requestModulesApi = (
url,
method = 'get',
data,
storeId = _config.get('store_id'),
axiosConfig
) => request({
data,
...axiosConfig,
url,
baseURL: API_MODULES,
method,
headers: {
'X-Store-ID': storeId
}
})

/**
* @method
* @memberof ecomClient
* @name requestModulesApi
* @description Send HTTP GET request to
* [E-Com Plus Modules REST API]{@link https://developers.e-com.plus/docs/api/#/modules/}.
*
* @param {string} url - API endpoint to request or absolute URI
* @param {number} [storeId=_config.get('store_id')] - E-Com Plus Store ID number
* @param {object} [axiosConfig] - Additional
* [axios config]{@link https://github.com/axios/axios#request-config} settings
*
* @returns {Promise<response|error>}
* Axios request promise resolved with
* [response]{@link https://github.com/axios/axios#response-schema}
* or rejected with
* [error]{@link https://github.com/axios/axios#handling-errors}.
*
* @example
// TODO
*/

export default requestModulesApi

0 comments on commit ae12547

Please sign in to comment.