orderiom-api-package 0.4.1 → 0.4.3

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.4.1",
3
+ "version": "0.4.3",
4
4
  "description": "This package will install all necessary API calls for every orderiom restaurant",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -683,7 +683,10 @@ const actions = {
683
683
  updatePaymentStatus({ dispatch, commit }, data) {
684
684
  return $http
685
685
  .get(`api/payment/update`, {
686
- params: { paymentId: data.paymentId, status: data.status , orderId:data.orderId },
686
+ params: {
687
+ paymentId: data.paymentId, status: data.status , orderId:data.orderId,
688
+ sessionId: data.sessionId || null, sessionResult: data.sessionResult || null // adyen payment
689
+ },
687
690
  })
688
691
  .then((res) => {
689
692
  const status = res.data.data.status;
@@ -143,15 +143,23 @@ const mutations = {
143
143
  }
144
144
  };
145
145
  const actions = {
146
- getCategories({ commit, dispatch }, restaurantId) {
146
+ getCategories({ commit, dispatch, rootState }, restaurantId) {
147
+ let basketId = undefined;
148
+ try {
149
+ basketId = calculateBasketIdParameter(
150
+ !!rootState.orderiomApiPackage.auth.privateToken, restaurantId
151
+ );
152
+ } catch(e) {
153
+ console.error("getCategories: " + e);
154
+ }
147
155
  return $http
148
- .get("api/restaurant/category", { params: { restaurantId: restaurantId } })
156
+ .get("api/restaurant/category", { params: { restaurantId: restaurantId, basketId: basketId } })
149
157
  .then((res) => {
150
158
  let categories = res.data.data;
151
159
  //TODO: why calling an api write after another while we can do it together?
152
160
  //TODO: this api call returns empty on restaurant refresh
153
161
  $http
154
- .get("api/restaurant/category", { params: { restaurantId: restaurantId, extra: 1 } })
162
+ .get("api/restaurant/category", { params: { restaurantId: restaurantId, extra: 1, basketId: basketId } })
155
163
  .then((res) => {
156
164
  if (res.data.data.length) {
157
165
  categories = [...categories, ...res.data.data];
@@ -189,12 +197,21 @@ const actions = {
189
197
  },
190
198
  getProducts({ commit, state, rootState }, data) {
191
199
  commit("setSelectedCategory", data.category);
192
-
200
+ let basketId = undefined;
201
+ try {
202
+ basketId = calculateBasketIdParameter(
203
+ !!rootState.orderiomApiPackage.auth.privateToken,
204
+ data ? data.restaurantId : undefined
205
+ );
206
+ } catch(e) {
207
+ console.error("getProducts: " + e);
208
+ }
193
209
  return $http.get("api/restaurant/products", {
194
210
  params: {
195
211
  categoryId: data.category.id,
196
212
  restaurantId: data.restaurantId,
197
213
  delivery_time: state.deliveryTime || undefined,
214
+ basketId: basketId
198
215
  }
199
216
  }).then(res => {
200
217
  res.data.data.forEach(productInCategory => {
@@ -234,10 +251,19 @@ const actions = {
234
251
  commit('finishFetchingBasket')
235
252
  });
236
253
  },
237
- getAttributeItems({ commit }, data) {
254
+ getAttributeItems({ commit, state, rootState }, data) {
255
+ let basketId = undefined;
256
+ try {
257
+ basketId = calculateBasketIdParameter(
258
+ !!rootState.orderiomApiPackage.auth.privateToken,
259
+ data ? data.restaurantId : undefined
260
+ );
261
+ } catch(e) {
262
+ console.error("getAttributeItems: " + e);
263
+ }
238
264
  return $http.get('api/restaurant/category-attributes-items', {
239
265
  params: {
240
- restaurantId: data.restaurantId, categoryId: data.category.id,
266
+ restaurantId: data.restaurantId, categoryId: data.category.id, basketId: basketId
241
267
  }
242
268
  }).then((result) => {
243
269
  commit('setAttributeItems', result.data.data)
@@ -245,11 +271,21 @@ const actions = {
245
271
  commonErrorCallback()
246
272
  );
247
273
  },
248
- getPackage({ commit }, data) {
274
+ getPackage({ commit, state, rootState }, data) {
275
+ let basketId = undefined;
276
+ try {
277
+ basketId = calculateBasketIdParameter(
278
+ !!rootState.orderiomApiPackage.auth.privateToken,
279
+ data ? data.restaurantId : undefined
280
+ );
281
+ } catch(e) {
282
+ console.error("getPackage: " + e);
283
+ }
249
284
  return $http.get('api/restaurant/product-packages', {
250
285
  params: {
251
286
  productId: data.productId,
252
- restaurantId: data.restaurantId
287
+ restaurantId: data.restaurantId,
288
+ basketId: basketId
253
289
  }
254
290
  }).then((result) => {
255
291
  commit('setProductPackage', result.data.data)
@@ -313,13 +349,21 @@ const actions = {
313
349
  },
314
350
  getProductsFromAllCategories({ commit, state, rootState }, {categories = null, restaurantId = null}) {
315
351
  const list = (categories || state.categories);
316
-
352
+ let basketId = undefined;
353
+ try {
354
+ basketId = calculateBasketIdParameter(
355
+ !!rootState.orderiomApiPackage.auth.privateToken, restaurantId
356
+ );
357
+ } catch(e) {
358
+ console.error("getProductsFromAllCategories: " + e);
359
+ }
317
360
  // TODO: It is recommended to use a new api instead of multiple api calls inside a loop.
318
361
  return Promise.all(list.map(category =>
319
362
  $http.get("api/restaurant/products", {
320
363
  params: {
321
364
  categoryId: category.id,
322
365
  restaurantId: restaurantId || restaurantIdEnv,
366
+ basketId: basketId
323
367
  }
324
368
  })
325
369
  )).then(resArray => ({