ecomClient

ecomClient

Source:
TL;DR: You're probably wanting to use Store API.
Although, we have methods to run requests for almost all E-Com Plus APIs below.

Methods

(static) graphs(cfg) → {Promise.<(response|error)>}

Source:
Send HTTP GET request to E-Com Plus Graphs REST API.
Example
// TODO
Parameters:
Name Type Description
cfg object Request config options
Properties
Name Type Attributes Default Description
url string API endpoint to request or absolute URI
storeId number <optional>
_config.get('store_id') E-Com Plus Store ID number
axiosConfig object <optional>
Additional axios config settings
Returns:
Axios request promise resolved with response or rejected with error.
Type
Promise.<(response|error)>

(static) modules(cfg) → {Promise.<(response|error)>}

Source:
Send HTTP request to E-Com Plus Modules REST API.
Example
// TODO
Parameters:
Name Type Description
cfg object Request config options
Properties
Name Type Attributes Default Description
url string API endpoint to request or absolute URI
method string <optional>
'get' Request method (HTTP verb)
data object <optional>
Request body object
storeId number <optional>
_config.get('store_id') E-Com Plus Store ID number
axiosConfig object <optional>
Additional axios config settings
Returns:
Axios request promise resolved with response or rejected with error.
Type
Promise.<(response|error)>

(static) passport(cfg) → {Promise.<(response|error)>}

Source:
Send HTTP request to E-Com Plus Passport REST API with customer login authentication.
Example
// TODO
Parameters:
Name Type Description
cfg object Request config options
Properties
Name Type Attributes Default Description
url string API endpoint to request or absolute URI
customerId string <optional>
My ID for authenticated request
accessToken string <optional>
Access token for authenticated request
method string <optional>
'get' Request method (HTTP verb)
data object <optional>
Request body object
storeId number <optional>
_config.get('store_id') E-Com Plus Store ID number
axiosConfig object <optional>
Additional axios config settings
Returns:
Axios request promise resolved with response or rejected with error.
Type
Promise.<(response|error)>

(static) platform(cfg) → {Promise.<(response|error)>}

Source:
Send HTTP GET request to E-Com Plus Platform REST API.
Example
// TODO
Parameters:
Name Type Description
cfg object Request config options
Properties
Name Type Attributes Default Description
url string API endpoint to request or absolute URI
storeId number <optional>
_config.get('store_id') E-Com Plus Store ID number
axiosConfig object <optional>
Additional axios config settings
Returns:
Axios request promise resolved with response or rejected with error.
Type
Promise.<(response|error)>

(static) search(cfg) → {Promise.<(response|error)>}

Source:
Send HTTP request to E-Com Plus Search REST API.
Examples
// Simple search request (ELS URI Search)
ecomClient.search({ url: '/items.json?q=sku:123' })
  .then(response => console.log(response.data))
  .catch(error => {
    console.error(error)
    if (error.response) {
      console.log(error.response)
    }
  })
// Complex search request (ELS Request Body Search)
const data = {
  query: {
    bool: {
      must: {
        multi_match: {
          query: 'tshirt',
          fields: [ 'name', 'keywords' ]
        }
      }
    }
  }
}
ecomClient.search({ url: '/items.json', method: 'post', data })
  .then(({ data, status }) => console.log(status, data))
  .catch(error => console.error(error))
Parameters:
Name Type Description
cfg object Request config options
Properties
Name Type Attributes Default Description
url string API endpoint to request or absolute URI
method string <optional>
'get' Request method (HTTP verb)
data object <optional>
Request body object
storeId number <optional>
_config.get('store_id') E-Com Plus Store ID number
axiosConfig object <optional>
Additional axios config settings
Returns:
Axios request promise resolved with response or rejected with error.
Type
Promise.<(response|error)>

(static) store(cfg) → {Promise.<(response|error)>}

Source:
Send HTTP request to E-Com Plus Store REST API.
Examples
// Simple GET request (public)
ecomClient.store({ url: '/products.json' })
  .then(response => console.log(response.data))
  .catch(error => {
    console.error(error)
    if (error.response) {
      console.log(error.response)
    }
  })
// Authenticated request
const authenticationId = 'myAuthenticationId'
const accessToken = 'myAccessToken'
ecomClient.store({
  url: '/products.json',
  authenticationId,
  accessToken,
  method: 'post',
  data: { sku: '123', name: 'Sample Prduct 123' }
})
  .then(({ data, status }) => console.log(status, data))
  .catch(error => console.error(error))
Parameters:
Name Type Description
cfg object Request config options
Properties
Name Type Attributes Default Description
url string API endpoint to request or absolute URI
authenticationId string <optional>
My ID for authenticated request
accessToken string <optional>
Access token for authenticated request
method string <optional>
'get' Request method (HTTP verb)
data object <optional>
Request body object
storeId number <optional>
_config.get('store_id') E-Com Plus Store ID number
axiosConfig object <optional>
Additional axios config settings
Returns:
Axios request promise resolved with response or rejected with error.
Type
Promise.<(response|error)>

(static) storefront(cfg) → {Promise.<(response|error)>}

Source:
Send HTTP GET request to E-Com Plus Storefront REST API.
Example
// TODO
Parameters:
Name Type Description
cfg object Request config options
Properties
Name Type Attributes Default Description
url string API endpoint to request or absolute URI
storeId number <optional>
_config.get('store_id') E-Com Plus Store ID number
axiosConfig object <optional>
Additional axios config settings
Returns:
Axios request promise resolved with response or rejected with error.
Type
Promise.<(response|error)>