orderiom-api-package 0.3.33 → 0.3.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orderiom-api-package",
3
- "version": "0.3.33",
3
+ "version": "0.3.35",
4
4
  "description": "This package will install all necessary API calls for every orderiom restaurant",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/common.js CHANGED
@@ -1,6 +1,10 @@
1
1
  import axios from "axios";
2
2
 
3
- export const restaurantIdEnv = process.env.VUE_APP_RESTAURANT_ID ? parseInt(process.env.VUE_APP_RESTAURANT_ID) : null;
3
+ export const restaurantIdEnv = process.env.VUE_APP_RESTAURANT_ID
4
+ ? parseInt(process.env.VUE_APP_RESTAURANT_ID)
5
+ : window.dynamicData.VUE_APP_RESTAURANT_ID
6
+ ? parseInt(window.dynamicData.VUE_APP_RESTAURANT_ID)
7
+ : null;
4
8
 
5
9
  export function commonErrorCallback(unknownErrorMessage = 'Something went wrong'){
6
10
  return error => {
@@ -74,7 +78,7 @@ export function updateBasket({commit, basketId, res, restaurantId}){
74
78
  return true;
75
79
  }
76
80
 
77
- axios.defaults.baseURL = process.env.VUE_APP_BASE_API_URL;
81
+ axios.defaults.baseURL = window.dynamicData.VUE_APP_BASE_API_URL || process.env.VUE_APP_BASE_API_URL;
78
82
  axios.interceptors.request.use(config => {
79
83
  const token = localStorage.getItem("privateToken") || localStorage.getItem("publicToken");
80
84
  if (token) config.headers["Authorization"] = `Bearer ${token}`;
@@ -55,9 +55,9 @@ const actions = {
55
55
  auth({ commit }) {
56
56
  return $http
57
57
  .post("api/oauth/token", {
58
- grant_type: process.env.VUE_APP_GRANT_TYPE,
59
- client_id: process.env.VUE_APP_CLIENT_ID,
60
- client_secret: process.env.VUE_APP_CLIENT_SECRET
58
+ grant_type: window.dynamicData.VUE_APP_GRANT_TYPE || process.env.VUE_APP_GRANT_TYPE,
59
+ client_id: window.dynamicData.VUE_APP_CLIENT_ID || process.env.VUE_APP_CLIENT_ID,
60
+ client_secret: window.dynamicData.VUE_APP_CLIENT_SECRET || process.env.VUE_APP_CLIENT_SECRET
61
61
  })
62
62
  .then(res => {
63
63
  commit('setPublicToken', res.data.data.access_token)
@@ -237,20 +237,13 @@ const actions = {
237
237
  getProducts({ commit, state, rootState }, data) {
238
238
  commit("setSelectedCategory", data.category);
239
239
 
240
- let basketId = undefined;
241
- try{
242
- basketId = calculateBasketIdParameter(!!rootState.orderiomApiPackage.auth.privateToken, data.restaurantId);
243
- } catch(e) {
244
- console.error(e);
245
- return { type: 'error', msg: 'Basket not found' }
246
- }
247
-
248
- return $http.get("api/restaurant/products", {params: {
249
- categoryId: data.category.id,
250
- restaurantId: data.restaurantId,
251
- delivery_time: data.delivery_time || undefined,
252
- basketId
253
- }}).then(res => {
240
+ return $http.get("api/restaurant/products", {
241
+ params: {
242
+ categoryId: data.category.id,
243
+ restaurantId: data.restaurantId,
244
+ delivery_time: state.deliveryTime || undefined,
245
+ }
246
+ }).then(res => {
254
247
  res.data.data.forEach(productInCategory => {
255
248
  productInCategory.quantity = state.ShoppingCart
256
249
  .filter(itemInCart => Number(itemInCart.RestaurantProductId) === Number(productInCategory.id))
@@ -366,14 +359,6 @@ const actions = {
366
359
  });
367
360
  },
368
361
  getProductsFromAllCategories({ commit, state, rootState }, {categories = null, restaurantId = null}) {
369
- let basketId = undefined;
370
- try{
371
- basketId = calculateBasketIdParameter(!!rootState.orderiomApiPackage.auth.privateToken, restaurantId);
372
- } catch(e) {
373
- console.error(e);
374
- return { type: 'error', msg: 'Basket not found', data: [] }
375
- }
376
-
377
362
  const list = (categories || state.categories);
378
363
 
379
364
  // TODO: It is recommended to use a new api instead of multiple api calls inside a loop.
@@ -382,7 +367,6 @@ const actions = {
382
367
  params: {
383
368
  categoryId: category.id,
384
369
  restaurantId: restaurantId || restaurantIdEnv,
385
- basketId
386
370
  }
387
371
  })
388
372
  )).then(resArray => ({