Skip to content

Commit

Permalink
fix(methods): renaming request methods with prefix 'api'
Browse files Browse the repository at this point in the history
BREAKING CHANGE: old request methods will not work (renamed)
  • Loading branch information
leomp12 committed Jul 20, 2019
1 parent 1741906 commit f36f02e
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 31 deletions.
20 changes: 10 additions & 10 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

import _self from './lib/self'

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'
import apiStore from './methods/api-store'
import apiPlatform from './methods/api-platform'
import apiSearch from './methods/api-search'
import apiGraphs from './methods/api-graphs'
import apiModules from './methods/api-modules'

/**
* JS client for E-Com Plus REST APIs.
Expand All @@ -32,11 +32,11 @@ import platform from './methods/platform'

export {
_self,
store,
modules,
graphs,
search,
platform
apiStore,
apiPlatform,
apiSearch,
apiGraphs,
apiModules
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/methods/graphs.js → src/methods/api-graphs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { IS_BROWSER, API_GRAPHS } from './../lib/constants'
import request from './../lib/request'

// returns axios request promise
const graphs = (
const apiGraphs = (
url,
storeId = _config.get('store_id'),
axiosConfig
Expand All @@ -21,7 +21,7 @@ const graphs = (
/**
* @method
* @memberof ecomClient
* @name graphs
* @name apiGraphs
* @description Send HTTP GET request to
* [E-Com Plus Graphs REST API]{@link https://developers.e-com.plus/docs/api/#/graphs/}.
*
Expand All @@ -42,4 +42,4 @@ const graphs = (
*/

export default graphs
export default apiGraphs
6 changes: 3 additions & 3 deletions src/methods/modules.js → src/methods/api-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { API_MODULES } from './../lib/constants'
import request from './../lib/request'

// returns axios request promise
const modules = (
const apiModules = (
url,
method = 'get',
data,
Expand All @@ -23,7 +23,7 @@ const modules = (
/**
* @method
* @memberof ecomClient
* @name modules
* @name apiModules
* @description Send HTTP GET request to
* [E-Com Plus Modules REST API]{@link https://developers.e-com.plus/docs/api/#/modules/}.
*
Expand All @@ -44,4 +44,4 @@ const modules = (
*/

export default modules
export default apiModules
8 changes: 4 additions & 4 deletions src/methods/platform.js → src/methods/api-platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 platform = (
const apiPlatform = (
url,
storeId = _config.get('store_id'),
axiosConfig
Expand Down Expand Up @@ -34,7 +34,7 @@ const platform = (
let { status } = response
if (!status || status < 100 || status >= 500) {
// resend request with same params
return platform(
return apiPlatform(
url,
storeId,
axiosConfig
Expand All @@ -49,7 +49,7 @@ const platform = (
/**
* @method
* @memberof ecomClient
* @name platform
* @name apiPlatform
* @description Send HTTP GET request to
* [E-Com Plus Platform REST API]{@link https://developers.e-com.plus/docs/api/#/platform/}.
*
Expand All @@ -70,4 +70,4 @@ const platform = (
*/

export default platform
export default apiPlatform
10 changes: 5 additions & 5 deletions src/methods/search.js → src/methods/api-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { IS_BROWSER, API_SEARCH } from './../lib/constants'
import request from './../lib/request'

// returns axios request promise
const search = (
const apiSearch = (
url,
method = 'get',
data,
Expand All @@ -25,7 +25,7 @@ const search = (
/**
* @method
* @memberof ecomClient
* @name search
* @name apiSearch
* @description Send HTTP request to
* [E-Com Plus Search REST API]{@link https://developers.e-com.plus/docs/api/#/search/}.
*
Expand All @@ -45,7 +45,7 @@ const search = (
* @example
// Simple search request (ELS URI Search)
ecomClient.search('/items.json?q=sku:123')
ecomClient.apiSearch('/items.json?q=sku:123')
.then(response => console.log(response.data))
.catch(error => {
console.error(error)
Expand All @@ -69,10 +69,10 @@ const data = {
}
}
}
ecomClient.search('/items.json', 'post', data)
ecomClient.apiSearch('/items.json', 'post', data)
.then(({ data, status }) => console.log(status, data))
.catch(error => console.error(error))
*/

export default search
export default apiSearch
12 changes: 6 additions & 6 deletions src/methods/store.js → src/methods/api-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import request from './../lib/request'
// save Store Cache API status
let isCacheOnline = true

const store = (
const apiStore = (
url,
authenticationId,
accessToken,
Expand Down Expand Up @@ -63,7 +63,7 @@ const store = (
isCacheOnline = false
setTimeout(() => { isCacheOnline = true }, 30000)
// resend request with same params
return store(
return apiStore(
url,
authenticationId,
accessToken,
Expand All @@ -82,7 +82,7 @@ const store = (
/**
* @method
* @memberof ecomClient
* @name store
* @name apiStore
* @description Send HTTP request to
* [E-Com Plus Store REST API]{@link https://developers.e-com.plus/docs/api/#/store/}.
*
Expand All @@ -104,7 +104,7 @@ const store = (
* @example
// Simple GET request (public)
ecomClient.store('/products.json')
ecomClient.apiStore('/products.json')
.then(response => console.log(response.data))
.catch(error => {
console.error(error)
Expand All @@ -118,7 +118,7 @@ ecomClient.store('/products.json')
// Authenticated request
this.authenticationId = 'myAuthenticationId'
this.accessToken = 'myAccessToken'
ecomClient.store(
ecomClient.apiStore(
'/products.json',
this.authenticationId,
this.accessToken,
Expand All @@ -130,4 +130,4 @@ ecomClient.store(
*/

export default store
export default apiStore

0 comments on commit f36f02e

Please sign in to comment.