Skip to content

Commit

Permalink
fix(api-version): remove api version from storage to use normal v1
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusgnreis committed Jul 27, 2023
1 parent f64b10b commit f72dd3b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/controllers/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,9 @@ export default function () {

const id = Tab.selectedItems[done]
if (id) {
const isApiv2 = Number(window.sessionStorage.setItem('api_v', '2')) === 2
window.sessionStorage.removeItem('api_v')
// remove v2 api_v until next version to return normal request
const isApiv2 = Number(window.sessionStorage.getItem('api_v')) === 2
const apiBaseUri = isApiv2 ? 'https://ecomplus.io/v2' : 'https://api.e-com.plus/v1'
askConfirmation(
`${apiBaseUri}/${slug}/${id}.json`,
Expand Down
2 changes: 2 additions & 0 deletions src/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
<link href="https://fonts.googleapis.com/css2?family=Fira+Sans:ital,wght@0,200;0,300;0,400;0,500;0,600;0,700;1,200;1,300;1,400;1,500;1,600;1,700&display=swap" rel="stylesheet">
<link href="/assets/css/core.min.css" rel="stylesheet">
<script>
sessionStorage.removeItem('api_v')
// remove v2 api_v until next version to return normal request
if (sessionStorage.getItem('api_v') === '2') {
ECOMCLIENT_API_STORE = 'https://ecomplus.io/v2/'
}
Expand Down
2 changes: 2 additions & 0 deletions src/login/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ const getAuthState = (name, storeId, myId) => {
}
return fromStorage
}
sessionStorage.removeItem('api_v')
// remove v2 api_v until next version to return normal request
const isApiv2 = Number(getAuthState('api_v')) === 2
const apiBaseUri = isApiv2 ? 'https://ecomplus.io/v2' : 'https://api.e-com.plus/v1'

Expand Down
8 changes: 6 additions & 2 deletions src/script/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,9 @@ const { sessionStorage, localStorage, Image, $, app } = window
hideToast()
// E-Com Plus Store API
// https://ecomstore.docs.apiary.io/#
const isApiv2 = Number(sessionStorage.setItem('api_v', '2')) === 2
sessionStorage.removeItem('api_v')
// remove v2 api_v until next version to return normal request
const isApiv2 = sessionStorage.getItem('api_v') === 2
const apiBaseUri = isApiv2 ? 'https://ecomplus.io/v2' : 'https://api.e-com.plus/v1'
// API endpoint full URL
var uri = apiBaseUri + '/' + endpoint
Expand Down Expand Up @@ -314,7 +316,9 @@ const { sessionStorage, localStorage, Image, $, app } = window
var callSearchApi = function (endpoint, method, callback, bodyObject) {
// E-Com Plus Search API
// https://ecomsearch.docs.apiary.io/#
const isApiv2 = Number(sessionStorage.setItem('api_v', '2')) === 2
sessionStorage.removeItem('api_v')
// remove v2 api_v until next version to return normal request
const isApiv2 = Number(sessionStorage.getItem('api_v')) === 2
const apiBaseUri = isApiv2 ? 'https://ecomplus.io/v2/search/_els' : 'https://apx-search.e-com.plus/api/v1'
// API endpoint full URL
let uri
Expand Down

0 comments on commit f72dd3b

Please sign in to comment.