arky-sdk 0.7.93 → 0.7.95
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/README.md +19 -19
- package/dist/admin.cjs +2324 -0
- package/dist/admin.cjs.map +1 -0
- package/dist/admin.d.cts +3 -0
- package/dist/admin.d.ts +3 -0
- package/dist/admin.js +2322 -0
- package/dist/admin.js.map +1 -0
- package/dist/index.cjs +518 -523
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +55 -86
- package/dist/index.d.ts +55 -86
- package/dist/index.js +518 -523
- package/dist/index.js.map +1 -1
- package/dist/storefront.cjs +1359 -0
- package/dist/storefront.cjs.map +1 -0
- package/dist/storefront.d.cts +3 -0
- package/dist/storefront.d.ts +3 -0
- package/dist/storefront.js +1356 -0
- package/dist/storefront.js.map +1 -0
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +164 -164
- package/dist/types.d.ts +164 -164
- package/dist/types.js.map +1 -1
- package/package.json +12 -5
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var nanostores = require('nanostores');
|
|
4
|
-
|
|
5
3
|
// src/types/index.ts
|
|
6
4
|
var PaymentMethodType = /* @__PURE__ */ ((PaymentMethodType2) => {
|
|
7
5
|
PaymentMethodType2["Cash"] = "cash";
|
|
@@ -158,7 +156,7 @@ var createActivityApi = (apiConfig) => ({
|
|
|
158
156
|
async track(params) {
|
|
159
157
|
try {
|
|
160
158
|
await apiConfig.httpClient.post(
|
|
161
|
-
`/v1/storefront/${apiConfig.
|
|
159
|
+
`/v1/storefront/${apiConfig.storeId}/activities/track`,
|
|
162
160
|
{ type: params.type, payload: params.payload }
|
|
163
161
|
);
|
|
164
162
|
} catch {
|
|
@@ -181,11 +179,11 @@ function groupCartToItems(cart) {
|
|
|
181
179
|
return [...groups.values()];
|
|
182
180
|
}
|
|
183
181
|
var createStorefrontApi = (apiConfig) => {
|
|
184
|
-
const base = (
|
|
182
|
+
const base = (storeId = apiConfig.storeId) => `/v1/storefront/${storeId}`;
|
|
185
183
|
let cart = [];
|
|
186
184
|
return {
|
|
187
|
-
|
|
188
|
-
|
|
185
|
+
store: {
|
|
186
|
+
getStore(options) {
|
|
189
187
|
return apiConfig.httpClient.get(base(), options);
|
|
190
188
|
},
|
|
191
189
|
location: {
|
|
@@ -217,19 +215,19 @@ var createStorefrontApi = (apiConfig) => {
|
|
|
217
215
|
cms: {
|
|
218
216
|
node: {
|
|
219
217
|
async get(params, options) {
|
|
220
|
-
const
|
|
218
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
221
219
|
let identifier;
|
|
222
220
|
if (params.id) {
|
|
223
221
|
identifier = params.id;
|
|
224
222
|
} else if (params.slug) {
|
|
225
|
-
identifier = `${
|
|
223
|
+
identifier = `${store_id}:${apiConfig.locale}:${params.slug}`;
|
|
226
224
|
} else if (params.key) {
|
|
227
|
-
identifier = `${
|
|
225
|
+
identifier = `${store_id}:${params.key}`;
|
|
228
226
|
} else {
|
|
229
227
|
throw new Error("GetNodeParams requires id, slug, or key");
|
|
230
228
|
}
|
|
231
229
|
const response = await apiConfig.httpClient.get(
|
|
232
|
-
`${base(
|
|
230
|
+
`${base(store_id)}/nodes/${identifier}`,
|
|
233
231
|
options
|
|
234
232
|
);
|
|
235
233
|
return {
|
|
@@ -247,15 +245,15 @@ var createStorefrontApi = (apiConfig) => {
|
|
|
247
245
|
};
|
|
248
246
|
},
|
|
249
247
|
find(params, options) {
|
|
250
|
-
const {
|
|
251
|
-
return apiConfig.httpClient.get(`${base(
|
|
248
|
+
const { store_id, ...queryParams } = params;
|
|
249
|
+
return apiConfig.httpClient.get(`${base(store_id)}/nodes`, {
|
|
252
250
|
...options,
|
|
253
251
|
params: queryParams
|
|
254
252
|
});
|
|
255
253
|
},
|
|
256
254
|
getChildren(params, options) {
|
|
257
|
-
const { id,
|
|
258
|
-
return apiConfig.httpClient.get(`${base(
|
|
255
|
+
const { id, store_id, ...queryParams } = params;
|
|
256
|
+
return apiConfig.httpClient.get(`${base(store_id)}/nodes/${id}/children`, {
|
|
259
257
|
...options,
|
|
260
258
|
params: queryParams
|
|
261
259
|
});
|
|
@@ -263,53 +261,53 @@ var createStorefrontApi = (apiConfig) => {
|
|
|
263
261
|
},
|
|
264
262
|
form: {
|
|
265
263
|
get(params, options) {
|
|
266
|
-
const
|
|
264
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
267
265
|
let identifier;
|
|
268
266
|
if (params.id) {
|
|
269
267
|
identifier = params.id;
|
|
270
268
|
} else if (params.key) {
|
|
271
|
-
identifier = `${
|
|
269
|
+
identifier = `${store_id}:${params.key}`;
|
|
272
270
|
} else {
|
|
273
271
|
throw new Error("GetFormParams requires id or key");
|
|
274
272
|
}
|
|
275
273
|
return apiConfig.httpClient.get(
|
|
276
|
-
`${base(
|
|
274
|
+
`${base(store_id)}/forms/${identifier}`,
|
|
277
275
|
options
|
|
278
276
|
);
|
|
279
277
|
},
|
|
280
278
|
submit(params, options) {
|
|
281
|
-
const {
|
|
282
|
-
const
|
|
279
|
+
const { store_id, form_id, ...payload } = params;
|
|
280
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
283
281
|
if (!form_id) {
|
|
284
282
|
throw new Error("SubmitFormParams requires form_id");
|
|
285
283
|
}
|
|
286
284
|
return apiConfig.httpClient.post(
|
|
287
|
-
`${base(
|
|
288
|
-
{ ...payload, form_id,
|
|
285
|
+
`${base(target_store_id)}/forms/${form_id}/submissions`,
|
|
286
|
+
{ ...payload, form_id, store_id: target_store_id },
|
|
289
287
|
options
|
|
290
288
|
);
|
|
291
289
|
}
|
|
292
290
|
},
|
|
293
291
|
taxonomy: {
|
|
294
292
|
get(params, options) {
|
|
295
|
-
const
|
|
293
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
296
294
|
let identifier;
|
|
297
295
|
if (params.id) {
|
|
298
296
|
identifier = params.id;
|
|
299
297
|
} else if (params.key) {
|
|
300
|
-
identifier = `${
|
|
298
|
+
identifier = `${store_id}:${params.key}`;
|
|
301
299
|
} else {
|
|
302
300
|
throw new Error("GetTaxonomyParams requires id or key");
|
|
303
301
|
}
|
|
304
302
|
return apiConfig.httpClient.get(
|
|
305
|
-
`${base(
|
|
303
|
+
`${base(store_id)}/taxonomies/${identifier}`,
|
|
306
304
|
options
|
|
307
305
|
);
|
|
308
306
|
},
|
|
309
307
|
getChildren(params, options) {
|
|
310
|
-
const
|
|
308
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
311
309
|
return apiConfig.httpClient.get(
|
|
312
|
-
`${base(
|
|
310
|
+
`${base(store_id)}/taxonomies/${params.id}/children`,
|
|
313
311
|
options
|
|
314
312
|
);
|
|
315
313
|
}
|
|
@@ -318,23 +316,23 @@ var createStorefrontApi = (apiConfig) => {
|
|
|
318
316
|
eshop: {
|
|
319
317
|
product: {
|
|
320
318
|
get(params, options) {
|
|
321
|
-
const
|
|
319
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
322
320
|
let identifier;
|
|
323
321
|
if (params.id) {
|
|
324
322
|
identifier = params.id;
|
|
325
323
|
} else if (params.slug) {
|
|
326
|
-
identifier = `${
|
|
324
|
+
identifier = `${store_id}:${apiConfig.locale}:${params.slug}`;
|
|
327
325
|
} else {
|
|
328
326
|
throw new Error("GetProductParams requires id or slug");
|
|
329
327
|
}
|
|
330
328
|
return apiConfig.httpClient.get(
|
|
331
|
-
`${base(
|
|
329
|
+
`${base(store_id)}/products/${identifier}`,
|
|
332
330
|
options
|
|
333
331
|
);
|
|
334
332
|
},
|
|
335
333
|
find(params, options) {
|
|
336
|
-
const {
|
|
337
|
-
return apiConfig.httpClient.get(`${base(
|
|
334
|
+
const { store_id, ...queryParams } = params;
|
|
335
|
+
return apiConfig.httpClient.get(`${base(store_id)}/products`, {
|
|
338
336
|
...options,
|
|
339
337
|
params: queryParams
|
|
340
338
|
});
|
|
@@ -342,8 +340,8 @@ var createStorefrontApi = (apiConfig) => {
|
|
|
342
340
|
},
|
|
343
341
|
order: {
|
|
344
342
|
getQuote(params, options) {
|
|
345
|
-
const
|
|
346
|
-
const { location,
|
|
343
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
344
|
+
const { location, store_id: _store_id, ...rest } = params;
|
|
347
345
|
const shipping_address = location ? {
|
|
348
346
|
country: location.country || "",
|
|
349
347
|
state: location.state || "",
|
|
@@ -354,30 +352,30 @@ var createStorefrontApi = (apiConfig) => {
|
|
|
354
352
|
street2: null
|
|
355
353
|
} : void 0;
|
|
356
354
|
return apiConfig.httpClient.post(
|
|
357
|
-
`${base(
|
|
355
|
+
`${base(store_id)}/orders/quote`,
|
|
358
356
|
{ ...rest, shipping_address, market: apiConfig.market },
|
|
359
357
|
options
|
|
360
358
|
);
|
|
361
359
|
},
|
|
362
360
|
checkout(params, options) {
|
|
363
|
-
const {
|
|
364
|
-
const target =
|
|
361
|
+
const { store_id, ...rest } = params;
|
|
362
|
+
const target = store_id || apiConfig.storeId;
|
|
365
363
|
return apiConfig.httpClient.post(
|
|
366
364
|
`${base(target)}/orders/checkout`,
|
|
367
|
-
{ ...rest,
|
|
365
|
+
{ ...rest, store_id: target, market: apiConfig.market },
|
|
368
366
|
options
|
|
369
367
|
);
|
|
370
368
|
},
|
|
371
369
|
get(params, options) {
|
|
372
|
-
const
|
|
370
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
373
371
|
return apiConfig.httpClient.get(
|
|
374
|
-
`${base(
|
|
372
|
+
`${base(store_id)}/orders/${params.id}`,
|
|
375
373
|
options
|
|
376
374
|
);
|
|
377
375
|
},
|
|
378
376
|
find(params, options) {
|
|
379
|
-
const {
|
|
380
|
-
return apiConfig.httpClient.get(`${base(
|
|
377
|
+
const { store_id, ...queryParams } = params;
|
|
378
|
+
return apiConfig.httpClient.get(`${base(store_id)}/orders`, {
|
|
381
379
|
...options,
|
|
382
380
|
params: queryParams
|
|
383
381
|
});
|
|
@@ -398,81 +396,81 @@ var createStorefrontApi = (apiConfig) => {
|
|
|
398
396
|
cart = [];
|
|
399
397
|
},
|
|
400
398
|
checkout(params, options) {
|
|
401
|
-
const {
|
|
402
|
-
const
|
|
399
|
+
const { store_id, items: paramItems, ...payload } = params || {};
|
|
400
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
403
401
|
const items = paramItems || groupCartToItems(cart);
|
|
404
402
|
return apiConfig.httpClient.post(
|
|
405
|
-
`${base(
|
|
403
|
+
`${base(target_store_id)}/bookings/checkout`,
|
|
406
404
|
{ market: "booking", ...payload, items },
|
|
407
405
|
options
|
|
408
406
|
);
|
|
409
407
|
},
|
|
410
408
|
get(params, options) {
|
|
411
|
-
const
|
|
409
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
412
410
|
return apiConfig.httpClient.get(
|
|
413
|
-
`${base(
|
|
411
|
+
`${base(store_id)}/bookings/${params.id}`,
|
|
414
412
|
options
|
|
415
413
|
);
|
|
416
414
|
},
|
|
417
415
|
find(params, options) {
|
|
418
|
-
const {
|
|
419
|
-
return apiConfig.httpClient.get(`${base(
|
|
416
|
+
const { store_id, ...queryParams } = params;
|
|
417
|
+
return apiConfig.httpClient.get(`${base(store_id)}/bookings`, {
|
|
420
418
|
...options,
|
|
421
419
|
params: queryParams
|
|
422
420
|
});
|
|
423
421
|
},
|
|
424
422
|
getQuote(params, options) {
|
|
425
|
-
const {
|
|
426
|
-
const
|
|
423
|
+
const { store_id, ...payload } = params;
|
|
424
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
427
425
|
return apiConfig.httpClient.post(
|
|
428
|
-
`${base(
|
|
426
|
+
`${base(target_store_id)}/bookings/quote`,
|
|
429
427
|
{ market: "booking", ...payload },
|
|
430
428
|
options
|
|
431
429
|
);
|
|
432
430
|
},
|
|
433
431
|
getAvailability(params, options) {
|
|
434
|
-
const {
|
|
435
|
-
const
|
|
432
|
+
const { store_id, ...queryParams } = params;
|
|
433
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
436
434
|
return apiConfig.httpClient.get(
|
|
437
|
-
`${base(
|
|
435
|
+
`${base(target_store_id)}/bookings/availability`,
|
|
438
436
|
{ ...options, params: queryParams }
|
|
439
437
|
);
|
|
440
438
|
},
|
|
441
439
|
cancelItem(params, options) {
|
|
442
|
-
const {
|
|
443
|
-
const
|
|
440
|
+
const { store_id, booking_id, item_id, ...payload } = params;
|
|
441
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
444
442
|
return apiConfig.httpClient.post(
|
|
445
|
-
`${base(
|
|
443
|
+
`${base(target_store_id)}/bookings/${booking_id}/items/${item_id}/cancel`,
|
|
446
444
|
payload,
|
|
447
445
|
options
|
|
448
446
|
);
|
|
449
447
|
},
|
|
450
448
|
service: {
|
|
451
449
|
get(params, options) {
|
|
452
|
-
const
|
|
450
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
453
451
|
let identifier;
|
|
454
452
|
if (params.id) {
|
|
455
453
|
identifier = params.id;
|
|
456
454
|
} else if (params.slug) {
|
|
457
|
-
identifier = `${
|
|
455
|
+
identifier = `${store_id}:${apiConfig.locale}:${params.slug}`;
|
|
458
456
|
} else {
|
|
459
457
|
throw new Error("GetServiceParams requires id or slug");
|
|
460
458
|
}
|
|
461
459
|
return apiConfig.httpClient.get(
|
|
462
|
-
`${base(
|
|
460
|
+
`${base(store_id)}/services/${identifier}`,
|
|
463
461
|
options
|
|
464
462
|
);
|
|
465
463
|
},
|
|
466
464
|
find(params, options) {
|
|
467
|
-
const {
|
|
468
|
-
return apiConfig.httpClient.get(`${base(
|
|
465
|
+
const { store_id, ...queryParams } = params;
|
|
466
|
+
return apiConfig.httpClient.get(`${base(store_id)}/services`, {
|
|
469
467
|
...options,
|
|
470
468
|
params: queryParams
|
|
471
469
|
});
|
|
472
470
|
},
|
|
473
471
|
findProviders(params, options) {
|
|
474
|
-
const {
|
|
475
|
-
return apiConfig.httpClient.get(`${base(
|
|
472
|
+
const { store_id, ...queryParams } = params;
|
|
473
|
+
return apiConfig.httpClient.get(`${base(store_id)}/service-providers`, {
|
|
476
474
|
...options,
|
|
477
475
|
params: queryParams
|
|
478
476
|
});
|
|
@@ -480,23 +478,23 @@ var createStorefrontApi = (apiConfig) => {
|
|
|
480
478
|
},
|
|
481
479
|
provider: {
|
|
482
480
|
get(params, options) {
|
|
483
|
-
const
|
|
481
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
484
482
|
let identifier;
|
|
485
483
|
if (params.id) {
|
|
486
484
|
identifier = params.id;
|
|
487
485
|
} else if (params.slug) {
|
|
488
|
-
identifier = `${
|
|
486
|
+
identifier = `${store_id}:${apiConfig.locale}:${params.slug}`;
|
|
489
487
|
} else {
|
|
490
488
|
throw new Error("GetProviderParams requires id or slug");
|
|
491
489
|
}
|
|
492
490
|
return apiConfig.httpClient.get(
|
|
493
|
-
`${base(
|
|
491
|
+
`${base(store_id)}/providers/${identifier}`,
|
|
494
492
|
options
|
|
495
493
|
);
|
|
496
494
|
},
|
|
497
495
|
find(params, options) {
|
|
498
|
-
const {
|
|
499
|
-
return apiConfig.httpClient.get(`${base(
|
|
496
|
+
const { store_id, ...queryParams } = params;
|
|
497
|
+
return apiConfig.httpClient.get(`${base(store_id)}/providers`, {
|
|
500
498
|
...options,
|
|
501
499
|
params: queryParams
|
|
502
500
|
});
|
|
@@ -506,10 +504,10 @@ var createStorefrontApi = (apiConfig) => {
|
|
|
506
504
|
crm: {
|
|
507
505
|
customer: {
|
|
508
506
|
async session(params, options) {
|
|
509
|
-
const
|
|
507
|
+
const store_id = params?.store_id || apiConfig.storeId;
|
|
510
508
|
const result = await apiConfig.httpClient.post(
|
|
511
|
-
`${base(
|
|
512
|
-
{
|
|
509
|
+
`${base(store_id)}/customers/session`,
|
|
510
|
+
{ store_id, market: params?.market || apiConfig.market || null },
|
|
513
511
|
options
|
|
514
512
|
);
|
|
515
513
|
if (result?.token?.access_token) {
|
|
@@ -518,10 +516,10 @@ var createStorefrontApi = (apiConfig) => {
|
|
|
518
516
|
return result;
|
|
519
517
|
},
|
|
520
518
|
async connect(params, options) {
|
|
521
|
-
const
|
|
519
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
522
520
|
const result = await apiConfig.httpClient.post(
|
|
523
|
-
`${base(
|
|
524
|
-
{ email: params.email,
|
|
521
|
+
`${base(store_id)}/customers/connect`,
|
|
522
|
+
{ email: params.email, store_id },
|
|
525
523
|
options
|
|
526
524
|
);
|
|
527
525
|
if (result?.access_token) {
|
|
@@ -530,18 +528,18 @@ var createStorefrontApi = (apiConfig) => {
|
|
|
530
528
|
return result;
|
|
531
529
|
},
|
|
532
530
|
requestCode(params, options) {
|
|
533
|
-
const
|
|
531
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
534
532
|
return apiConfig.httpClient.post(
|
|
535
|
-
`${base(
|
|
536
|
-
{ email: params.email,
|
|
533
|
+
`${base(store_id)}/customers/auth/code`,
|
|
534
|
+
{ email: params.email, store_id },
|
|
537
535
|
options
|
|
538
536
|
);
|
|
539
537
|
},
|
|
540
538
|
async verify(params, options) {
|
|
541
|
-
const
|
|
539
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
542
540
|
const result = await apiConfig.httpClient.post(
|
|
543
|
-
`${base(
|
|
544
|
-
{ email: params.email, code: params.code,
|
|
541
|
+
`${base(store_id)}/customers/auth/verify`,
|
|
542
|
+
{ email: params.email, code: params.code, store_id },
|
|
545
543
|
options
|
|
546
544
|
);
|
|
547
545
|
if (result?.access_token) {
|
|
@@ -550,9 +548,9 @@ var createStorefrontApi = (apiConfig) => {
|
|
|
550
548
|
return result;
|
|
551
549
|
},
|
|
552
550
|
async refreshToken(params, options) {
|
|
553
|
-
const
|
|
551
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
554
552
|
const result = await apiConfig.httpClient.post(
|
|
555
|
-
`${base(
|
|
553
|
+
`${base(store_id)}/customers/auth/refresh`,
|
|
556
554
|
{ refresh_token: params.refresh_token },
|
|
557
555
|
options
|
|
558
556
|
);
|
|
@@ -571,12 +569,12 @@ var createStorefrontApi = (apiConfig) => {
|
|
|
571
569
|
if (params.id) {
|
|
572
570
|
identifier = params.id;
|
|
573
571
|
} else if (params.key) {
|
|
574
|
-
identifier = `${apiConfig.
|
|
572
|
+
identifier = `${apiConfig.storeId}:${params.key}`;
|
|
575
573
|
} else {
|
|
576
574
|
throw new Error("GetAudienceParams requires id or key");
|
|
577
575
|
}
|
|
578
576
|
return apiConfig.httpClient.get(
|
|
579
|
-
`${base(apiConfig.
|
|
577
|
+
`${base(apiConfig.storeId)}/audiences/${identifier}`,
|
|
580
578
|
options
|
|
581
579
|
);
|
|
582
580
|
},
|
|
@@ -623,44 +621,44 @@ var createStorefrontApi = (apiConfig) => {
|
|
|
623
621
|
automation: {
|
|
624
622
|
agent: {
|
|
625
623
|
getAgents(params, options) {
|
|
626
|
-
const
|
|
624
|
+
const store_id = params?.store_id || apiConfig.storeId;
|
|
627
625
|
const queryParams = { ...params || {} };
|
|
628
|
-
delete queryParams.
|
|
629
|
-
return apiConfig.httpClient.get(`${base(
|
|
626
|
+
delete queryParams.store_id;
|
|
627
|
+
return apiConfig.httpClient.get(`${base(store_id)}/agents`, {
|
|
630
628
|
...options,
|
|
631
629
|
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
632
630
|
});
|
|
633
631
|
},
|
|
634
632
|
getAgent(params, options) {
|
|
635
|
-
const
|
|
633
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
636
634
|
return apiConfig.httpClient.get(
|
|
637
|
-
`${base(
|
|
635
|
+
`${base(store_id)}/agents/${params.id}`,
|
|
638
636
|
options
|
|
639
637
|
);
|
|
640
638
|
},
|
|
641
639
|
sendMessage(params, options) {
|
|
642
|
-
const
|
|
640
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
643
641
|
const body = { message: params.message };
|
|
644
642
|
if (params.chat_id) body.chat_id = params.chat_id;
|
|
645
643
|
return apiConfig.httpClient.post(
|
|
646
|
-
`${base(
|
|
644
|
+
`${base(store_id)}/agents/${params.id}/chats/messages`,
|
|
647
645
|
body,
|
|
648
646
|
options
|
|
649
647
|
);
|
|
650
648
|
},
|
|
651
649
|
getChat(params, options) {
|
|
652
|
-
const
|
|
650
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
653
651
|
return apiConfig.httpClient.get(
|
|
654
|
-
`${base(
|
|
652
|
+
`${base(store_id)}/agents/${params.id}/chats/${params.chat_id}`,
|
|
655
653
|
options
|
|
656
654
|
);
|
|
657
655
|
},
|
|
658
656
|
getChatMessages(params, options) {
|
|
659
|
-
const
|
|
657
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
660
658
|
const queryParams = {};
|
|
661
659
|
if (params.limit) queryParams.limit = String(params.limit);
|
|
662
660
|
return apiConfig.httpClient.get(
|
|
663
|
-
`${base(
|
|
661
|
+
`${base(store_id)}/agents/${params.id}/chats/${params.chat_id}/messages`,
|
|
664
662
|
{
|
|
665
663
|
...options,
|
|
666
664
|
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
@@ -668,11 +666,11 @@ var createStorefrontApi = (apiConfig) => {
|
|
|
668
666
|
);
|
|
669
667
|
},
|
|
670
668
|
rateChat(params, options) {
|
|
671
|
-
const
|
|
669
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
672
670
|
const body = { rating: params.rating };
|
|
673
671
|
if (params.comment) body.comment = params.comment;
|
|
674
672
|
return apiConfig.httpClient.post(
|
|
675
|
-
`${base(
|
|
673
|
+
`${base(store_id)}/agents/${params.id}/chats/${params.chat_id}/rate`,
|
|
676
674
|
body,
|
|
677
675
|
options
|
|
678
676
|
);
|
|
@@ -942,7 +940,7 @@ var createAccountApi = (apiConfig) => {
|
|
|
942
940
|
...options,
|
|
943
941
|
params: {
|
|
944
942
|
...params,
|
|
945
|
-
|
|
943
|
+
store_id: apiConfig.storeId
|
|
946
944
|
}
|
|
947
945
|
});
|
|
948
946
|
}
|
|
@@ -965,11 +963,11 @@ var createAuthApi = (apiConfig) => {
|
|
|
965
963
|
async refresh(params, options) {
|
|
966
964
|
return apiConfig.httpClient.post("/v1/auth/refresh", params, options);
|
|
967
965
|
},
|
|
968
|
-
async
|
|
969
|
-
return apiConfig.httpClient.post(`/v1/
|
|
966
|
+
async storeCode(storeId, params, options) {
|
|
967
|
+
return apiConfig.httpClient.post(`/v1/stores/${storeId}/auth/code`, params, options);
|
|
970
968
|
},
|
|
971
|
-
async
|
|
972
|
-
const result = await apiConfig.httpClient.post(`/v1/
|
|
969
|
+
async storeVerify(storeId, params, options) {
|
|
970
|
+
const result = await apiConfig.httpClient.post(`/v1/stores/${storeId}/auth/verify`, params, options);
|
|
973
971
|
if (result?.access_token) {
|
|
974
972
|
apiConfig.setToken({ ...result, email: params.email, is_verified: true });
|
|
975
973
|
}
|
|
@@ -981,86 +979,86 @@ var createAuthApi = (apiConfig) => {
|
|
|
981
979
|
};
|
|
982
980
|
};
|
|
983
981
|
|
|
984
|
-
// src/api/
|
|
985
|
-
var
|
|
982
|
+
// src/api/store.ts
|
|
983
|
+
var createStoreApi = (apiConfig) => {
|
|
986
984
|
return {
|
|
987
|
-
async
|
|
988
|
-
return apiConfig.httpClient.post(`/v1/
|
|
985
|
+
async createStore(params, options) {
|
|
986
|
+
return apiConfig.httpClient.post(`/v1/stores`, params, options);
|
|
989
987
|
},
|
|
990
|
-
async
|
|
988
|
+
async updateStore(params, options) {
|
|
991
989
|
return apiConfig.httpClient.put(
|
|
992
|
-
`/v1/
|
|
990
|
+
`/v1/stores/${params.id}`,
|
|
993
991
|
params,
|
|
994
992
|
options
|
|
995
993
|
);
|
|
996
994
|
},
|
|
997
|
-
async
|
|
995
|
+
async deleteStore(params, options) {
|
|
998
996
|
return apiConfig.httpClient.delete(
|
|
999
|
-
`/v1/
|
|
997
|
+
`/v1/stores/${params.id}`,
|
|
1000
998
|
options
|
|
1001
999
|
);
|
|
1002
1000
|
},
|
|
1003
|
-
async
|
|
1001
|
+
async getStore(params, options) {
|
|
1004
1002
|
return apiConfig.httpClient.get(
|
|
1005
|
-
`/v1/
|
|
1003
|
+
`/v1/stores/${apiConfig.storeId}`,
|
|
1006
1004
|
options
|
|
1007
1005
|
);
|
|
1008
1006
|
},
|
|
1009
|
-
async
|
|
1010
|
-
return apiConfig.httpClient.get(`/v1/
|
|
1007
|
+
async getStores(params, options) {
|
|
1008
|
+
return apiConfig.httpClient.get(`/v1/stores`, {
|
|
1011
1009
|
...options,
|
|
1012
1010
|
params
|
|
1013
1011
|
});
|
|
1014
1012
|
},
|
|
1015
1013
|
async getSubscriptionPlans(params, options) {
|
|
1016
|
-
return apiConfig.httpClient.get("/v1/
|
|
1014
|
+
return apiConfig.httpClient.get("/v1/stores/plans", options);
|
|
1017
1015
|
},
|
|
1018
1016
|
async subscribe(params, options) {
|
|
1019
|
-
const {
|
|
1020
|
-
const
|
|
1017
|
+
const { store_id, plan_id, success_url, cancel_url } = params;
|
|
1018
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1021
1019
|
return apiConfig.httpClient.put(
|
|
1022
|
-
`/v1/
|
|
1020
|
+
`/v1/stores/${target_store_id}/subscribe`,
|
|
1023
1021
|
{ plan_id, success_url, cancel_url },
|
|
1024
1022
|
options
|
|
1025
1023
|
);
|
|
1026
1024
|
},
|
|
1027
1025
|
async createPortalSession(params, options) {
|
|
1028
|
-
const
|
|
1026
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
1029
1027
|
return apiConfig.httpClient.post(
|
|
1030
|
-
`/v1/
|
|
1028
|
+
`/v1/stores/${store_id}/subscription/portal`,
|
|
1031
1029
|
{ return_url: params.return_url },
|
|
1032
1030
|
options
|
|
1033
1031
|
);
|
|
1034
1032
|
},
|
|
1035
1033
|
async inviteUser(params, options) {
|
|
1036
1034
|
return apiConfig.httpClient.post(
|
|
1037
|
-
`/v1/
|
|
1035
|
+
`/v1/stores/${apiConfig.storeId}/invitation`,
|
|
1038
1036
|
params,
|
|
1039
1037
|
options
|
|
1040
1038
|
);
|
|
1041
1039
|
},
|
|
1042
1040
|
async removeMember(params, options) {
|
|
1043
1041
|
return apiConfig.httpClient.delete(
|
|
1044
|
-
`/v1/
|
|
1042
|
+
`/v1/stores/${apiConfig.storeId}/members/${params.account_id}`,
|
|
1045
1043
|
options
|
|
1046
1044
|
);
|
|
1047
1045
|
},
|
|
1048
1046
|
async handleInvitation(params, options) {
|
|
1049
|
-
const {
|
|
1047
|
+
const { store_id, ...payload } = params;
|
|
1050
1048
|
return apiConfig.httpClient.put(
|
|
1051
|
-
`/v1/
|
|
1049
|
+
`/v1/stores/${store_id || apiConfig.storeId}/invitation`,
|
|
1052
1050
|
payload,
|
|
1053
1051
|
options
|
|
1054
1052
|
);
|
|
1055
1053
|
},
|
|
1056
1054
|
async testWebhook(params, options) {
|
|
1057
1055
|
return apiConfig.httpClient.post(
|
|
1058
|
-
`/v1/
|
|
1056
|
+
`/v1/stores/${apiConfig.storeId}/webhooks/test`,
|
|
1059
1057
|
params.webhook,
|
|
1060
1058
|
options
|
|
1061
1059
|
);
|
|
1062
1060
|
},
|
|
1063
|
-
async
|
|
1061
|
+
async getStoreMedia(params, options) {
|
|
1064
1062
|
const queryParams = {
|
|
1065
1063
|
limit: params.limit
|
|
1066
1064
|
};
|
|
@@ -1070,84 +1068,84 @@ var createBusinessApi = (apiConfig) => {
|
|
|
1070
1068
|
if (params.mime_type) queryParams.mime_type = params.mime_type;
|
|
1071
1069
|
if (params.sort_field) queryParams.sort_field = params.sort_field;
|
|
1072
1070
|
if (params.sort_direction) queryParams.sort_direction = params.sort_direction;
|
|
1073
|
-
return apiConfig.httpClient.get(`/v1/
|
|
1071
|
+
return apiConfig.httpClient.get(`/v1/stores/${params.id}/media`, {
|
|
1074
1072
|
...options,
|
|
1075
1073
|
params: queryParams
|
|
1076
1074
|
});
|
|
1077
1075
|
},
|
|
1078
1076
|
async oauthConnect(params, options) {
|
|
1079
1077
|
return apiConfig.httpClient.post(
|
|
1080
|
-
`/v1/
|
|
1078
|
+
`/v1/stores/${params.store_id}/oauth/connect`,
|
|
1081
1079
|
{ provider: params.provider, code: params.code, redirect_uri: params.redirect_uri },
|
|
1082
1080
|
options
|
|
1083
1081
|
);
|
|
1084
1082
|
},
|
|
1085
1083
|
async oauthDisconnect(params, options) {
|
|
1086
1084
|
return apiConfig.httpClient.post(
|
|
1087
|
-
`/v1/
|
|
1085
|
+
`/v1/stores/${params.store_id}/oauth/disconnect`,
|
|
1088
1086
|
{ provider: params.provider },
|
|
1089
1087
|
options
|
|
1090
1088
|
);
|
|
1091
1089
|
},
|
|
1092
1090
|
async listIntegrations(params, options) {
|
|
1093
1091
|
return apiConfig.httpClient.get(
|
|
1094
|
-
`/v1/
|
|
1092
|
+
`/v1/stores/${params.store_id}/integrations`,
|
|
1095
1093
|
options
|
|
1096
1094
|
);
|
|
1097
1095
|
},
|
|
1098
1096
|
async createIntegration(params, options) {
|
|
1099
|
-
const {
|
|
1097
|
+
const { store_id, ...payload } = params;
|
|
1100
1098
|
return apiConfig.httpClient.post(
|
|
1101
|
-
`/v1/
|
|
1099
|
+
`/v1/stores/${store_id}/integrations`,
|
|
1102
1100
|
payload,
|
|
1103
1101
|
options
|
|
1104
1102
|
);
|
|
1105
1103
|
},
|
|
1106
1104
|
async updateIntegration(params, options) {
|
|
1107
|
-
const {
|
|
1105
|
+
const { store_id, id, ...payload } = params;
|
|
1108
1106
|
return apiConfig.httpClient.put(
|
|
1109
|
-
`/v1/
|
|
1107
|
+
`/v1/stores/${store_id}/integrations/${id}`,
|
|
1110
1108
|
payload,
|
|
1111
1109
|
options
|
|
1112
1110
|
);
|
|
1113
1111
|
},
|
|
1114
1112
|
async deleteIntegration(params, options) {
|
|
1115
1113
|
return apiConfig.httpClient.delete(
|
|
1116
|
-
`/v1/
|
|
1114
|
+
`/v1/stores/${params.store_id}/integrations/${params.id}`,
|
|
1117
1115
|
options
|
|
1118
1116
|
);
|
|
1119
1117
|
},
|
|
1120
1118
|
async getIntegrationConfig(params, options) {
|
|
1121
1119
|
return apiConfig.httpClient.get(
|
|
1122
|
-
`/v1/
|
|
1120
|
+
`/v1/stores/${params.store_id}/integrations/config/${params.type}`,
|
|
1123
1121
|
options
|
|
1124
1122
|
);
|
|
1125
1123
|
},
|
|
1126
1124
|
async listWebhooks(params, options) {
|
|
1127
1125
|
return apiConfig.httpClient.get(
|
|
1128
|
-
`/v1/
|
|
1126
|
+
`/v1/stores/${params.store_id}/webhooks`,
|
|
1129
1127
|
options
|
|
1130
1128
|
);
|
|
1131
1129
|
},
|
|
1132
1130
|
async createWebhook(params, options) {
|
|
1133
|
-
const {
|
|
1131
|
+
const { store_id, ...payload } = params;
|
|
1134
1132
|
return apiConfig.httpClient.post(
|
|
1135
|
-
`/v1/
|
|
1133
|
+
`/v1/stores/${store_id}/webhooks`,
|
|
1136
1134
|
payload,
|
|
1137
1135
|
options
|
|
1138
1136
|
);
|
|
1139
1137
|
},
|
|
1140
1138
|
async updateWebhook(params, options) {
|
|
1141
|
-
const {
|
|
1139
|
+
const { store_id, id, ...payload } = params;
|
|
1142
1140
|
return apiConfig.httpClient.put(
|
|
1143
|
-
`/v1/
|
|
1141
|
+
`/v1/stores/${store_id}/webhooks/${id}`,
|
|
1144
1142
|
payload,
|
|
1145
1143
|
options
|
|
1146
1144
|
);
|
|
1147
1145
|
},
|
|
1148
1146
|
async deleteWebhook(params, options) {
|
|
1149
1147
|
return apiConfig.httpClient.delete(
|
|
1150
|
-
`/v1/
|
|
1148
|
+
`/v1/stores/${params.store_id}/webhooks/${params.id}`,
|
|
1151
1149
|
options
|
|
1152
1150
|
);
|
|
1153
1151
|
}
|
|
@@ -1158,16 +1156,16 @@ var createBusinessApi = (apiConfig) => {
|
|
|
1158
1156
|
var createMediaApi = (apiConfig) => {
|
|
1159
1157
|
return {
|
|
1160
1158
|
async getMedia(params, options) {
|
|
1161
|
-
const
|
|
1159
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1162
1160
|
return apiConfig.httpClient.get(
|
|
1163
|
-
`/v1/
|
|
1161
|
+
`/v1/stores/${target_store_id}/media/${params.media_id}`,
|
|
1164
1162
|
options
|
|
1165
1163
|
);
|
|
1166
1164
|
},
|
|
1167
|
-
async
|
|
1168
|
-
const {
|
|
1169
|
-
const
|
|
1170
|
-
const url = `${apiConfig.baseUrl}/v1/
|
|
1165
|
+
async uploadStoreMedia(params, options) {
|
|
1166
|
+
const { store_id, files = [], urls = [] } = params;
|
|
1167
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1168
|
+
const url = `${apiConfig.baseUrl}/v1/stores/${target_store_id}/media`;
|
|
1171
1169
|
const formData = new FormData();
|
|
1172
1170
|
files.forEach((file) => formData.append("files", file));
|
|
1173
1171
|
urls.forEach((url2) => formData.append("urls", url2));
|
|
@@ -1184,17 +1182,17 @@ var createMediaApi = (apiConfig) => {
|
|
|
1184
1182
|
}
|
|
1185
1183
|
return await response.json();
|
|
1186
1184
|
},
|
|
1187
|
-
async
|
|
1185
|
+
async deleteStoreMedia(params, options) {
|
|
1188
1186
|
const { id, media_id } = params;
|
|
1189
1187
|
return apiConfig.httpClient.delete(
|
|
1190
|
-
`/v1/
|
|
1188
|
+
`/v1/stores/${id}/media/${media_id}`,
|
|
1191
1189
|
options
|
|
1192
1190
|
);
|
|
1193
1191
|
},
|
|
1194
|
-
async
|
|
1195
|
-
const {
|
|
1196
|
-
const
|
|
1197
|
-
const url = `${apiConfig.baseUrl}/v1/
|
|
1192
|
+
async getStoreMedia(params, options) {
|
|
1193
|
+
const { store_id, cursor, limit, ids, query, mime_type, sort_field, sort_direction } = params;
|
|
1194
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1195
|
+
const url = `${apiConfig.baseUrl}/v1/stores/${target_store_id}/media`;
|
|
1198
1196
|
const queryParams = { limit: String(limit) };
|
|
1199
1197
|
if (cursor) queryParams.cursor = cursor;
|
|
1200
1198
|
if (ids && ids.length > 0) queryParams.ids = ids.join(",");
|
|
@@ -1216,10 +1214,10 @@ var createMediaApi = (apiConfig) => {
|
|
|
1216
1214
|
return await response.json();
|
|
1217
1215
|
},
|
|
1218
1216
|
async updateMedia(params, options) {
|
|
1219
|
-
const { media_id,
|
|
1220
|
-
const
|
|
1217
|
+
const { media_id, store_id, ...payload } = params;
|
|
1218
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1221
1219
|
return apiConfig.httpClient.put(
|
|
1222
|
-
`/v1/
|
|
1220
|
+
`/v1/stores/${target_store_id}/media/${media_id}`,
|
|
1223
1221
|
payload,
|
|
1224
1222
|
options
|
|
1225
1223
|
);
|
|
@@ -1250,41 +1248,41 @@ var createNotificationApi = (apiConfig) => {
|
|
|
1250
1248
|
var createPromoCodeApi = (apiConfig) => {
|
|
1251
1249
|
return {
|
|
1252
1250
|
async createPromoCode(params, options) {
|
|
1253
|
-
const {
|
|
1254
|
-
const
|
|
1251
|
+
const { store_id, ...payload } = params;
|
|
1252
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1255
1253
|
return apiConfig.httpClient.post(
|
|
1256
|
-
`/v1/
|
|
1254
|
+
`/v1/stores/${target_store_id}/promo-codes`,
|
|
1257
1255
|
payload,
|
|
1258
1256
|
options
|
|
1259
1257
|
);
|
|
1260
1258
|
},
|
|
1261
1259
|
async updatePromoCode(params, options) {
|
|
1262
|
-
const {
|
|
1263
|
-
const
|
|
1260
|
+
const { store_id, ...payload } = params;
|
|
1261
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1264
1262
|
return apiConfig.httpClient.put(
|
|
1265
|
-
`/v1/
|
|
1263
|
+
`/v1/stores/${target_store_id}/promo-codes/${params.id}`,
|
|
1266
1264
|
payload,
|
|
1267
1265
|
options
|
|
1268
1266
|
);
|
|
1269
1267
|
},
|
|
1270
1268
|
async deletePromoCode(params, options) {
|
|
1271
|
-
const
|
|
1269
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1272
1270
|
return apiConfig.httpClient.delete(
|
|
1273
|
-
`/v1/
|
|
1271
|
+
`/v1/stores/${target_store_id}/promo-codes/${params.id}`,
|
|
1274
1272
|
options
|
|
1275
1273
|
);
|
|
1276
1274
|
},
|
|
1277
1275
|
async getPromoCode(params, options) {
|
|
1278
|
-
const
|
|
1276
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1279
1277
|
return apiConfig.httpClient.get(
|
|
1280
|
-
`/v1/
|
|
1278
|
+
`/v1/stores/${target_store_id}/promo-codes/${params.id}`,
|
|
1281
1279
|
options
|
|
1282
1280
|
);
|
|
1283
1281
|
},
|
|
1284
1282
|
async getPromoCodes(params, options) {
|
|
1285
|
-
const {
|
|
1286
|
-
const
|
|
1287
|
-
return apiConfig.httpClient.get(`/v1/
|
|
1283
|
+
const { store_id, ...queryParams } = params;
|
|
1284
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1285
|
+
return apiConfig.httpClient.get(`/v1/stores/${target_store_id}/promo-codes`, {
|
|
1288
1286
|
...options,
|
|
1289
1287
|
params: queryParams
|
|
1290
1288
|
});
|
|
@@ -1296,44 +1294,44 @@ var createPromoCodeApi = (apiConfig) => {
|
|
|
1296
1294
|
var createCmsApi = (apiConfig) => {
|
|
1297
1295
|
return {
|
|
1298
1296
|
async createNode(params, options) {
|
|
1299
|
-
const {
|
|
1300
|
-
const
|
|
1297
|
+
const { store_id, ...payload } = params;
|
|
1298
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1301
1299
|
return apiConfig.httpClient.post(
|
|
1302
|
-
`/v1/
|
|
1300
|
+
`/v1/stores/${target_store_id}/nodes`,
|
|
1303
1301
|
payload,
|
|
1304
1302
|
options
|
|
1305
1303
|
);
|
|
1306
1304
|
},
|
|
1307
1305
|
async updateNode(params, options) {
|
|
1308
|
-
const {
|
|
1309
|
-
const
|
|
1306
|
+
const { store_id, ...payload } = params;
|
|
1307
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1310
1308
|
return apiConfig.httpClient.put(
|
|
1311
|
-
`/v1/
|
|
1309
|
+
`/v1/stores/${target_store_id}/nodes/${params.id}`,
|
|
1312
1310
|
payload,
|
|
1313
1311
|
options
|
|
1314
1312
|
);
|
|
1315
1313
|
},
|
|
1316
1314
|
async deleteNode(params, options) {
|
|
1317
|
-
const
|
|
1315
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1318
1316
|
return apiConfig.httpClient.delete(
|
|
1319
|
-
`/v1/
|
|
1317
|
+
`/v1/stores/${target_store_id}/nodes/${params.id}`,
|
|
1320
1318
|
options
|
|
1321
1319
|
);
|
|
1322
1320
|
},
|
|
1323
1321
|
async getNode(params, options) {
|
|
1324
|
-
const
|
|
1322
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1325
1323
|
let identifier;
|
|
1326
1324
|
if (params.id) {
|
|
1327
1325
|
identifier = params.id;
|
|
1328
1326
|
} else if (params.slug) {
|
|
1329
|
-
identifier = `${
|
|
1327
|
+
identifier = `${target_store_id}:${apiConfig.locale}:${params.slug}`;
|
|
1330
1328
|
} else if (params.key) {
|
|
1331
|
-
identifier = `${
|
|
1329
|
+
identifier = `${target_store_id}:${params.key}`;
|
|
1332
1330
|
} else {
|
|
1333
1331
|
throw new Error("GetNodeParams requires id, slug, or key");
|
|
1334
1332
|
}
|
|
1335
1333
|
const response = await apiConfig.httpClient.get(
|
|
1336
|
-
`/v1/
|
|
1334
|
+
`/v1/stores/${target_store_id}/nodes/${identifier}`,
|
|
1337
1335
|
options
|
|
1338
1336
|
);
|
|
1339
1337
|
return {
|
|
@@ -1351,10 +1349,10 @@ var createCmsApi = (apiConfig) => {
|
|
|
1351
1349
|
};
|
|
1352
1350
|
},
|
|
1353
1351
|
async getNodes(params, options) {
|
|
1354
|
-
const {
|
|
1355
|
-
const
|
|
1352
|
+
const { store_id, ...queryParams } = params;
|
|
1353
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1356
1354
|
return apiConfig.httpClient.get(
|
|
1357
|
-
`/v1/
|
|
1355
|
+
`/v1/stores/${target_store_id}/nodes`,
|
|
1358
1356
|
{
|
|
1359
1357
|
...options,
|
|
1360
1358
|
params: queryParams
|
|
@@ -1362,10 +1360,10 @@ var createCmsApi = (apiConfig) => {
|
|
|
1362
1360
|
);
|
|
1363
1361
|
},
|
|
1364
1362
|
async getNodeChildren(params, options) {
|
|
1365
|
-
const { id,
|
|
1366
|
-
const
|
|
1363
|
+
const { id, store_id, ...queryParams } = params;
|
|
1364
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1367
1365
|
return apiConfig.httpClient.get(
|
|
1368
|
-
`/v1/
|
|
1366
|
+
`/v1/stores/${target_store_id}/nodes/${id}/children`,
|
|
1369
1367
|
{
|
|
1370
1368
|
...options,
|
|
1371
1369
|
params: queryParams
|
|
@@ -1379,50 +1377,50 @@ var createCmsApi = (apiConfig) => {
|
|
|
1379
1377
|
var createEshopApi = (apiConfig) => {
|
|
1380
1378
|
return {
|
|
1381
1379
|
async createProduct(params, options) {
|
|
1382
|
-
const {
|
|
1383
|
-
const
|
|
1380
|
+
const { store_id, ...payload } = params;
|
|
1381
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1384
1382
|
return apiConfig.httpClient.post(
|
|
1385
|
-
`/v1/
|
|
1383
|
+
`/v1/stores/${target_store_id}/products`,
|
|
1386
1384
|
payload,
|
|
1387
1385
|
options
|
|
1388
1386
|
);
|
|
1389
1387
|
},
|
|
1390
1388
|
async updateProduct(params, options) {
|
|
1391
|
-
const {
|
|
1392
|
-
const
|
|
1389
|
+
const { store_id, ...payload } = params;
|
|
1390
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1393
1391
|
return apiConfig.httpClient.put(
|
|
1394
|
-
`/v1/
|
|
1392
|
+
`/v1/stores/${target_store_id}/products/${params.id}`,
|
|
1395
1393
|
payload,
|
|
1396
1394
|
options
|
|
1397
1395
|
);
|
|
1398
1396
|
},
|
|
1399
1397
|
async deleteProduct(params, options) {
|
|
1400
|
-
const
|
|
1398
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1401
1399
|
return apiConfig.httpClient.delete(
|
|
1402
|
-
`/v1/
|
|
1400
|
+
`/v1/stores/${target_store_id}/products/${params.id}`,
|
|
1403
1401
|
options
|
|
1404
1402
|
);
|
|
1405
1403
|
},
|
|
1406
1404
|
async getProduct(params, options) {
|
|
1407
|
-
const
|
|
1405
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1408
1406
|
let identifier;
|
|
1409
1407
|
if (params.id) {
|
|
1410
1408
|
identifier = params.id;
|
|
1411
1409
|
} else if (params.slug) {
|
|
1412
|
-
identifier = `${
|
|
1410
|
+
identifier = `${target_store_id}:${apiConfig.locale}:${params.slug}`;
|
|
1413
1411
|
} else {
|
|
1414
1412
|
throw new Error("GetProductParams requires id or slug");
|
|
1415
1413
|
}
|
|
1416
1414
|
return apiConfig.httpClient.get(
|
|
1417
|
-
`/v1/
|
|
1415
|
+
`/v1/stores/${target_store_id}/products/${identifier}`,
|
|
1418
1416
|
options
|
|
1419
1417
|
);
|
|
1420
1418
|
},
|
|
1421
1419
|
async getProducts(params, options) {
|
|
1422
|
-
const {
|
|
1423
|
-
const
|
|
1420
|
+
const { store_id, ...queryParams } = params;
|
|
1421
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1424
1422
|
return apiConfig.httpClient.get(
|
|
1425
|
-
`/v1/
|
|
1423
|
+
`/v1/stores/${encodeURIComponent(target_store_id)}/products`,
|
|
1426
1424
|
{
|
|
1427
1425
|
...options,
|
|
1428
1426
|
params: queryParams
|
|
@@ -1430,35 +1428,35 @@ var createEshopApi = (apiConfig) => {
|
|
|
1430
1428
|
);
|
|
1431
1429
|
},
|
|
1432
1430
|
async createOrder(params, options) {
|
|
1433
|
-
const {
|
|
1434
|
-
const
|
|
1431
|
+
const { store_id, ...payload } = params;
|
|
1432
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1435
1433
|
return apiConfig.httpClient.post(
|
|
1436
|
-
`/v1/
|
|
1434
|
+
`/v1/stores/${target_store_id}/orders`,
|
|
1437
1435
|
payload,
|
|
1438
1436
|
options
|
|
1439
1437
|
);
|
|
1440
1438
|
},
|
|
1441
1439
|
async updateOrder(params, options) {
|
|
1442
|
-
const {
|
|
1443
|
-
const
|
|
1440
|
+
const { store_id, ...payload } = params;
|
|
1441
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1444
1442
|
return apiConfig.httpClient.put(
|
|
1445
|
-
`/v1/
|
|
1443
|
+
`/v1/stores/${target_store_id}/orders/${params.id}`,
|
|
1446
1444
|
payload,
|
|
1447
1445
|
options
|
|
1448
1446
|
);
|
|
1449
1447
|
},
|
|
1450
1448
|
async getOrder(params, options) {
|
|
1451
|
-
const
|
|
1449
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1452
1450
|
return apiConfig.httpClient.get(
|
|
1453
|
-
`/v1/
|
|
1451
|
+
`/v1/stores/${target_store_id}/orders/${params.id}`,
|
|
1454
1452
|
options
|
|
1455
1453
|
);
|
|
1456
1454
|
},
|
|
1457
1455
|
async getOrders(params, options) {
|
|
1458
|
-
const {
|
|
1459
|
-
const
|
|
1456
|
+
const { store_id, ...queryParams } = params;
|
|
1457
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1460
1458
|
return apiConfig.httpClient.get(
|
|
1461
|
-
`/v1/
|
|
1459
|
+
`/v1/stores/${target_store_id}/orders`,
|
|
1462
1460
|
{
|
|
1463
1461
|
...options,
|
|
1464
1462
|
params: queryParams
|
|
@@ -1477,14 +1475,14 @@ var createEshopApi = (apiConfig) => {
|
|
|
1477
1475
|
street2: null
|
|
1478
1476
|
} : void 0;
|
|
1479
1477
|
return apiConfig.httpClient.post(
|
|
1480
|
-
`/v1/
|
|
1478
|
+
`/v1/stores/${apiConfig.storeId}/orders/quote`,
|
|
1481
1479
|
{ ...rest, shipping_address, market: apiConfig.market },
|
|
1482
1480
|
options
|
|
1483
1481
|
);
|
|
1484
1482
|
},
|
|
1485
1483
|
async processRefund(params, options) {
|
|
1486
1484
|
return apiConfig.httpClient.post(
|
|
1487
|
-
`/v1/
|
|
1485
|
+
`/v1/stores/${apiConfig.storeId}/orders/${params.id}/refund`,
|
|
1488
1486
|
{ amount: params.amount },
|
|
1489
1487
|
options
|
|
1490
1488
|
);
|
|
@@ -1509,10 +1507,10 @@ var createBookingApi = (apiConfig) => {
|
|
|
1509
1507
|
cart = [];
|
|
1510
1508
|
},
|
|
1511
1509
|
async createBooking(params, options) {
|
|
1512
|
-
const {
|
|
1513
|
-
const
|
|
1510
|
+
const { store_id, ...payload } = params;
|
|
1511
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1514
1512
|
return apiConfig.httpClient.post(
|
|
1515
|
-
`/v1/
|
|
1513
|
+
`/v1/stores/${target_store_id}/bookings`,
|
|
1516
1514
|
{ market: "booking", ...payload },
|
|
1517
1515
|
options
|
|
1518
1516
|
);
|
|
@@ -1520,23 +1518,23 @@ var createBookingApi = (apiConfig) => {
|
|
|
1520
1518
|
async updateBooking(params, options) {
|
|
1521
1519
|
const { id, ...payload } = params;
|
|
1522
1520
|
return apiConfig.httpClient.put(
|
|
1523
|
-
`/v1/
|
|
1521
|
+
`/v1/stores/${apiConfig.storeId}/bookings/${id}`,
|
|
1524
1522
|
payload,
|
|
1525
1523
|
options
|
|
1526
1524
|
);
|
|
1527
1525
|
},
|
|
1528
1526
|
async getBooking(params, options) {
|
|
1529
|
-
const
|
|
1527
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1530
1528
|
return apiConfig.httpClient.get(
|
|
1531
|
-
`/v1/
|
|
1529
|
+
`/v1/stores/${target_store_id}/bookings/${params.id}`,
|
|
1532
1530
|
options
|
|
1533
1531
|
);
|
|
1534
1532
|
},
|
|
1535
1533
|
async searchBookings(params, options) {
|
|
1536
|
-
const {
|
|
1537
|
-
const
|
|
1534
|
+
const { store_id, ...queryParams } = params;
|
|
1535
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1538
1536
|
return apiConfig.httpClient.get(
|
|
1539
|
-
`/v1/
|
|
1537
|
+
`/v1/stores/${target_store_id}/bookings`,
|
|
1540
1538
|
{
|
|
1541
1539
|
...options,
|
|
1542
1540
|
params: queryParams
|
|
@@ -1544,74 +1542,74 @@ var createBookingApi = (apiConfig) => {
|
|
|
1544
1542
|
);
|
|
1545
1543
|
},
|
|
1546
1544
|
async getQuote(params, options) {
|
|
1547
|
-
const {
|
|
1548
|
-
const
|
|
1545
|
+
const { store_id, ...payload } = params;
|
|
1546
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1549
1547
|
return apiConfig.httpClient.post(
|
|
1550
|
-
`/v1/
|
|
1548
|
+
`/v1/stores/${target_store_id}/bookings/quote`,
|
|
1551
1549
|
{ market: "booking", ...payload },
|
|
1552
1550
|
options
|
|
1553
1551
|
);
|
|
1554
1552
|
},
|
|
1555
1553
|
async processRefund(params, options) {
|
|
1556
1554
|
return apiConfig.httpClient.post(
|
|
1557
|
-
`/v1/
|
|
1555
|
+
`/v1/stores/${apiConfig.storeId}/bookings/${params.id}/refund`,
|
|
1558
1556
|
{ amount: params.amount },
|
|
1559
1557
|
options
|
|
1560
1558
|
);
|
|
1561
1559
|
},
|
|
1562
1560
|
async getAvailability(params, options) {
|
|
1563
|
-
const {
|
|
1564
|
-
const
|
|
1561
|
+
const { store_id, ...query } = params;
|
|
1562
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1565
1563
|
return apiConfig.httpClient.get(
|
|
1566
|
-
`/v1/
|
|
1564
|
+
`/v1/stores/${target_store_id}/bookings/availability`,
|
|
1567
1565
|
{ ...options, params: query }
|
|
1568
1566
|
);
|
|
1569
1567
|
},
|
|
1570
1568
|
async createService(params, options) {
|
|
1571
|
-
const {
|
|
1572
|
-
const
|
|
1569
|
+
const { store_id, ...payload } = params;
|
|
1570
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1573
1571
|
return apiConfig.httpClient.post(
|
|
1574
|
-
`/v1/
|
|
1572
|
+
`/v1/stores/${target_store_id}/services`,
|
|
1575
1573
|
payload,
|
|
1576
1574
|
options
|
|
1577
1575
|
);
|
|
1578
1576
|
},
|
|
1579
1577
|
async updateService(params, options) {
|
|
1580
|
-
const {
|
|
1581
|
-
const
|
|
1578
|
+
const { store_id, ...payload } = params;
|
|
1579
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1582
1580
|
return apiConfig.httpClient.put(
|
|
1583
|
-
`/v1/
|
|
1581
|
+
`/v1/stores/${target_store_id}/services/${params.id}`,
|
|
1584
1582
|
payload,
|
|
1585
1583
|
options
|
|
1586
1584
|
);
|
|
1587
1585
|
},
|
|
1588
1586
|
async deleteService(params, options) {
|
|
1589
|
-
const
|
|
1587
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1590
1588
|
return apiConfig.httpClient.delete(
|
|
1591
|
-
`/v1/
|
|
1589
|
+
`/v1/stores/${target_store_id}/services/${params.id}`,
|
|
1592
1590
|
options
|
|
1593
1591
|
);
|
|
1594
1592
|
},
|
|
1595
1593
|
async getService(params, options) {
|
|
1596
|
-
const
|
|
1594
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
1597
1595
|
let identifier;
|
|
1598
1596
|
if (params.id) {
|
|
1599
1597
|
identifier = params.id;
|
|
1600
1598
|
} else if (params.slug) {
|
|
1601
|
-
identifier = `${
|
|
1599
|
+
identifier = `${store_id}:${apiConfig.locale}:${params.slug}`;
|
|
1602
1600
|
} else {
|
|
1603
1601
|
throw new Error("GetServiceParams requires id or slug");
|
|
1604
1602
|
}
|
|
1605
1603
|
return apiConfig.httpClient.get(
|
|
1606
|
-
`/v1/
|
|
1604
|
+
`/v1/stores/${store_id}/services/${identifier}`,
|
|
1607
1605
|
options
|
|
1608
1606
|
);
|
|
1609
1607
|
},
|
|
1610
1608
|
async getServices(params, options) {
|
|
1611
|
-
const {
|
|
1612
|
-
const
|
|
1609
|
+
const { store_id, ...queryParams } = params;
|
|
1610
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1613
1611
|
return apiConfig.httpClient.get(
|
|
1614
|
-
`/v1/
|
|
1612
|
+
`/v1/stores/${target_store_id}/services`,
|
|
1615
1613
|
{
|
|
1616
1614
|
...options,
|
|
1617
1615
|
params: queryParams
|
|
@@ -1619,50 +1617,50 @@ var createBookingApi = (apiConfig) => {
|
|
|
1619
1617
|
);
|
|
1620
1618
|
},
|
|
1621
1619
|
async createProvider(params, options) {
|
|
1622
|
-
const {
|
|
1623
|
-
const
|
|
1620
|
+
const { store_id, ...payload } = params;
|
|
1621
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1624
1622
|
return apiConfig.httpClient.post(
|
|
1625
|
-
`/v1/
|
|
1623
|
+
`/v1/stores/${target_store_id}/providers`,
|
|
1626
1624
|
payload,
|
|
1627
1625
|
options
|
|
1628
1626
|
);
|
|
1629
1627
|
},
|
|
1630
1628
|
async updateProvider(params, options) {
|
|
1631
|
-
const {
|
|
1632
|
-
const
|
|
1629
|
+
const { store_id, ...payload } = params;
|
|
1630
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1633
1631
|
return apiConfig.httpClient.put(
|
|
1634
|
-
`/v1/
|
|
1632
|
+
`/v1/stores/${target_store_id}/providers/${params.id}`,
|
|
1635
1633
|
payload,
|
|
1636
1634
|
options
|
|
1637
1635
|
);
|
|
1638
1636
|
},
|
|
1639
1637
|
async deleteProvider(params, options) {
|
|
1640
|
-
const
|
|
1638
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1641
1639
|
return apiConfig.httpClient.delete(
|
|
1642
|
-
`/v1/
|
|
1640
|
+
`/v1/stores/${target_store_id}/providers/${params.id}`,
|
|
1643
1641
|
options
|
|
1644
1642
|
);
|
|
1645
1643
|
},
|
|
1646
1644
|
async getProvider(params, options) {
|
|
1647
|
-
const
|
|
1645
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
1648
1646
|
let identifier;
|
|
1649
1647
|
if (params.id) {
|
|
1650
1648
|
identifier = params.id;
|
|
1651
1649
|
} else if (params.slug) {
|
|
1652
|
-
identifier = `${
|
|
1650
|
+
identifier = `${store_id}:${apiConfig.locale}:${params.slug}`;
|
|
1653
1651
|
} else {
|
|
1654
1652
|
throw new Error("GetProviderParams requires id or slug");
|
|
1655
1653
|
}
|
|
1656
1654
|
return apiConfig.httpClient.get(
|
|
1657
|
-
`/v1/
|
|
1655
|
+
`/v1/stores/${store_id}/providers/${identifier}`,
|
|
1658
1656
|
options
|
|
1659
1657
|
);
|
|
1660
1658
|
},
|
|
1661
1659
|
async getProviders(params, options) {
|
|
1662
|
-
const {
|
|
1663
|
-
const
|
|
1660
|
+
const { store_id, ...queryParams } = params;
|
|
1661
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1664
1662
|
return apiConfig.httpClient.get(
|
|
1665
|
-
`/v1/
|
|
1663
|
+
`/v1/stores/${target_store_id}/providers`,
|
|
1666
1664
|
{
|
|
1667
1665
|
...options,
|
|
1668
1666
|
params: queryParams
|
|
@@ -1670,44 +1668,44 @@ var createBookingApi = (apiConfig) => {
|
|
|
1670
1668
|
);
|
|
1671
1669
|
},
|
|
1672
1670
|
async cancelBookingItem(params, options) {
|
|
1673
|
-
const {
|
|
1674
|
-
const
|
|
1671
|
+
const { store_id, booking_id, item_id, ...payload } = params;
|
|
1672
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1675
1673
|
return apiConfig.httpClient.post(
|
|
1676
|
-
`/v1/
|
|
1674
|
+
`/v1/stores/${target_store_id}/bookings/${booking_id}/items/${item_id}/cancel`,
|
|
1677
1675
|
payload,
|
|
1678
1676
|
options
|
|
1679
1677
|
);
|
|
1680
1678
|
},
|
|
1681
1679
|
async findServiceProviders(params, options) {
|
|
1682
|
-
const {
|
|
1683
|
-
const
|
|
1680
|
+
const { store_id, ...queryParams } = params;
|
|
1681
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1684
1682
|
return apiConfig.httpClient.get(
|
|
1685
|
-
`/v1/
|
|
1683
|
+
`/v1/stores/${target_store_id}/service-providers`,
|
|
1686
1684
|
{ ...options, params: queryParams }
|
|
1687
1685
|
);
|
|
1688
1686
|
},
|
|
1689
1687
|
async createServiceProvider(params, options) {
|
|
1690
|
-
const {
|
|
1691
|
-
const
|
|
1688
|
+
const { store_id, ...payload } = params;
|
|
1689
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1692
1690
|
return apiConfig.httpClient.post(
|
|
1693
|
-
`/v1/
|
|
1691
|
+
`/v1/stores/${target_store_id}/service-providers`,
|
|
1694
1692
|
payload,
|
|
1695
1693
|
options
|
|
1696
1694
|
);
|
|
1697
1695
|
},
|
|
1698
1696
|
async updateServiceProvider(params, options) {
|
|
1699
|
-
const {
|
|
1700
|
-
const
|
|
1697
|
+
const { store_id, id, ...payload } = params;
|
|
1698
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1701
1699
|
return apiConfig.httpClient.put(
|
|
1702
|
-
`/v1/
|
|
1700
|
+
`/v1/stores/${target_store_id}/service-providers/${id}`,
|
|
1703
1701
|
payload,
|
|
1704
1702
|
options
|
|
1705
1703
|
);
|
|
1706
1704
|
},
|
|
1707
1705
|
async deleteServiceProvider(params, options) {
|
|
1708
|
-
const
|
|
1706
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1709
1707
|
return apiConfig.httpClient.delete(
|
|
1710
|
-
`/v1/
|
|
1708
|
+
`/v1/stores/${target_store_id}/service-providers/${params.id}`,
|
|
1711
1709
|
options
|
|
1712
1710
|
);
|
|
1713
1711
|
}
|
|
@@ -1728,33 +1726,33 @@ var createLocationApi = (apiConfig) => {
|
|
|
1728
1726
|
},
|
|
1729
1727
|
async list(options) {
|
|
1730
1728
|
return apiConfig.httpClient.get(
|
|
1731
|
-
`/v1/
|
|
1729
|
+
`/v1/stores/${apiConfig.storeId}/locations`,
|
|
1732
1730
|
options
|
|
1733
1731
|
);
|
|
1734
1732
|
},
|
|
1735
1733
|
async get(id, options) {
|
|
1736
1734
|
return apiConfig.httpClient.get(
|
|
1737
|
-
`/v1/
|
|
1735
|
+
`/v1/stores/${apiConfig.storeId}/locations/${id}`,
|
|
1738
1736
|
options
|
|
1739
1737
|
);
|
|
1740
1738
|
},
|
|
1741
1739
|
async create(params, options) {
|
|
1742
1740
|
return apiConfig.httpClient.post(
|
|
1743
|
-
`/v1/
|
|
1744
|
-
{ ...params,
|
|
1741
|
+
`/v1/stores/${apiConfig.storeId}/locations`,
|
|
1742
|
+
{ ...params, store_id: apiConfig.storeId },
|
|
1745
1743
|
options
|
|
1746
1744
|
);
|
|
1747
1745
|
},
|
|
1748
1746
|
async update(params, options) {
|
|
1749
1747
|
return apiConfig.httpClient.put(
|
|
1750
|
-
`/v1/
|
|
1751
|
-
{ ...params,
|
|
1748
|
+
`/v1/stores/${apiConfig.storeId}/locations/${params.id}`,
|
|
1749
|
+
{ ...params, store_id: apiConfig.storeId },
|
|
1752
1750
|
options
|
|
1753
1751
|
);
|
|
1754
1752
|
},
|
|
1755
1753
|
async delete(params, options) {
|
|
1756
1754
|
return apiConfig.httpClient.delete(
|
|
1757
|
-
`/v1/
|
|
1755
|
+
`/v1/stores/${apiConfig.storeId}/locations/${params.id}`,
|
|
1758
1756
|
options
|
|
1759
1757
|
);
|
|
1760
1758
|
}
|
|
@@ -1766,33 +1764,33 @@ var createMarketApi = (apiConfig) => {
|
|
|
1766
1764
|
return {
|
|
1767
1765
|
async list(options) {
|
|
1768
1766
|
return apiConfig.httpClient.get(
|
|
1769
|
-
`/v1/
|
|
1767
|
+
`/v1/stores/${apiConfig.storeId}/markets`,
|
|
1770
1768
|
options
|
|
1771
1769
|
);
|
|
1772
1770
|
},
|
|
1773
1771
|
async get(id, options) {
|
|
1774
1772
|
return apiConfig.httpClient.get(
|
|
1775
|
-
`/v1/
|
|
1773
|
+
`/v1/stores/${apiConfig.storeId}/markets/${id}`,
|
|
1776
1774
|
options
|
|
1777
1775
|
);
|
|
1778
1776
|
},
|
|
1779
1777
|
async create(params, options) {
|
|
1780
1778
|
return apiConfig.httpClient.post(
|
|
1781
|
-
`/v1/
|
|
1782
|
-
{ ...params,
|
|
1779
|
+
`/v1/stores/${apiConfig.storeId}/markets`,
|
|
1780
|
+
{ ...params, store_id: apiConfig.storeId },
|
|
1783
1781
|
options
|
|
1784
1782
|
);
|
|
1785
1783
|
},
|
|
1786
1784
|
async update(params, options) {
|
|
1787
1785
|
return apiConfig.httpClient.put(
|
|
1788
|
-
`/v1/
|
|
1789
|
-
{ ...params,
|
|
1786
|
+
`/v1/stores/${apiConfig.storeId}/markets/${params.id}`,
|
|
1787
|
+
{ ...params, store_id: apiConfig.storeId },
|
|
1790
1788
|
options
|
|
1791
1789
|
);
|
|
1792
1790
|
},
|
|
1793
1791
|
async delete(params, options) {
|
|
1794
1792
|
return apiConfig.httpClient.delete(
|
|
1795
|
-
`/v1/
|
|
1793
|
+
`/v1/stores/${apiConfig.storeId}/markets/${params.id}`,
|
|
1796
1794
|
options
|
|
1797
1795
|
);
|
|
1798
1796
|
}
|
|
@@ -1802,12 +1800,12 @@ var createMarketApi = (apiConfig) => {
|
|
|
1802
1800
|
// src/api/crm.ts
|
|
1803
1801
|
var createActivityAdminApi = (apiConfig) => ({
|
|
1804
1802
|
async timeline(params, options) {
|
|
1805
|
-
const
|
|
1803
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
1806
1804
|
const queryParams = { customer_id: params.customer_id };
|
|
1807
1805
|
if (params.limit !== void 0) queryParams.limit = params.limit;
|
|
1808
1806
|
if (params.cursor) queryParams.cursor = params.cursor;
|
|
1809
1807
|
return apiConfig.httpClient.get(
|
|
1810
|
-
`/v1/
|
|
1808
|
+
`/v1/stores/${store_id}/activities/timeline`,
|
|
1811
1809
|
{ ...options, params: queryParams }
|
|
1812
1810
|
);
|
|
1813
1811
|
}
|
|
@@ -1815,21 +1813,21 @@ var createActivityAdminApi = (apiConfig) => ({
|
|
|
1815
1813
|
var createCustomerApi = (apiConfig) => {
|
|
1816
1814
|
return {
|
|
1817
1815
|
async create(params, options) {
|
|
1818
|
-
const {
|
|
1816
|
+
const { store_id, ...payload } = params;
|
|
1819
1817
|
return apiConfig.httpClient.post(
|
|
1820
|
-
`/v1/
|
|
1818
|
+
`/v1/stores/${store_id || apiConfig.storeId}/customers`,
|
|
1821
1819
|
payload,
|
|
1822
1820
|
options
|
|
1823
1821
|
);
|
|
1824
1822
|
},
|
|
1825
1823
|
async get(params, options) {
|
|
1826
1824
|
return apiConfig.httpClient.get(
|
|
1827
|
-
`/v1/
|
|
1825
|
+
`/v1/stores/${params.store_id || apiConfig.storeId}/customers/${params.id}`,
|
|
1828
1826
|
options
|
|
1829
1827
|
);
|
|
1830
1828
|
},
|
|
1831
1829
|
async find(params, options) {
|
|
1832
|
-
const
|
|
1830
|
+
const store_id = params?.store_id || apiConfig.storeId;
|
|
1833
1831
|
const queryParams = {};
|
|
1834
1832
|
if (params?.limit !== void 0) queryParams.limit = params.limit;
|
|
1835
1833
|
if (params?.cursor) queryParams.cursor = params.cursor;
|
|
@@ -1837,7 +1835,7 @@ var createCustomerApi = (apiConfig) => {
|
|
|
1837
1835
|
if (params?.sort_field) queryParams.sort_field = params.sort_field;
|
|
1838
1836
|
if (params?.sort_direction) queryParams.sort_direction = params.sort_direction;
|
|
1839
1837
|
return apiConfig.httpClient.get(
|
|
1840
|
-
`/v1/
|
|
1838
|
+
`/v1/stores/${store_id}/customers`,
|
|
1841
1839
|
{
|
|
1842
1840
|
...options,
|
|
1843
1841
|
params: queryParams
|
|
@@ -1845,46 +1843,46 @@ var createCustomerApi = (apiConfig) => {
|
|
|
1845
1843
|
);
|
|
1846
1844
|
},
|
|
1847
1845
|
async update(params, options) {
|
|
1848
|
-
const { id,
|
|
1846
|
+
const { id, store_id, ...body } = params;
|
|
1849
1847
|
return apiConfig.httpClient.put(
|
|
1850
|
-
`/v1/
|
|
1848
|
+
`/v1/stores/${store_id || apiConfig.storeId}/customers/${id}`,
|
|
1851
1849
|
body,
|
|
1852
1850
|
options
|
|
1853
1851
|
);
|
|
1854
1852
|
},
|
|
1855
1853
|
async merge(params, options) {
|
|
1856
|
-
const
|
|
1854
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
1857
1855
|
return apiConfig.httpClient.post(
|
|
1858
|
-
`/v1/
|
|
1859
|
-
{ source_id: params.source_id,
|
|
1856
|
+
`/v1/stores/${store_id}/customers/${params.target_id}/merge`,
|
|
1857
|
+
{ source_id: params.source_id, store_id },
|
|
1860
1858
|
options
|
|
1861
1859
|
);
|
|
1862
1860
|
},
|
|
1863
1861
|
async revokeToken(params, options) {
|
|
1864
|
-
const
|
|
1862
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
1865
1863
|
return apiConfig.httpClient.delete(
|
|
1866
|
-
`/v1/
|
|
1864
|
+
`/v1/stores/${store_id}/customers/${params.id}/sessions/${params.token_id}`,
|
|
1867
1865
|
options
|
|
1868
1866
|
);
|
|
1869
1867
|
},
|
|
1870
1868
|
async revokeAllTokens(params, options) {
|
|
1871
|
-
const
|
|
1869
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
1872
1870
|
return apiConfig.httpClient.delete(
|
|
1873
|
-
`/v1/
|
|
1871
|
+
`/v1/stores/${store_id}/customers/${params.id}/sessions`,
|
|
1874
1872
|
options
|
|
1875
1873
|
);
|
|
1876
1874
|
},
|
|
1877
1875
|
audiences: {
|
|
1878
1876
|
async create(params, options) {
|
|
1879
1877
|
return apiConfig.httpClient.post(
|
|
1880
|
-
`/v1/
|
|
1878
|
+
`/v1/stores/${apiConfig.storeId}/audiences`,
|
|
1881
1879
|
params,
|
|
1882
1880
|
options
|
|
1883
1881
|
);
|
|
1884
1882
|
},
|
|
1885
1883
|
async update(params, options) {
|
|
1886
1884
|
return apiConfig.httpClient.put(
|
|
1887
|
-
`/v1/
|
|
1885
|
+
`/v1/stores/${apiConfig.storeId}/audiences/${params.id}`,
|
|
1888
1886
|
params,
|
|
1889
1887
|
options
|
|
1890
1888
|
);
|
|
@@ -1894,24 +1892,24 @@ var createCustomerApi = (apiConfig) => {
|
|
|
1894
1892
|
if (params.id) {
|
|
1895
1893
|
identifier = params.id;
|
|
1896
1894
|
} else if (params.key) {
|
|
1897
|
-
identifier = `${apiConfig.
|
|
1895
|
+
identifier = `${apiConfig.storeId}:${params.key}`;
|
|
1898
1896
|
} else {
|
|
1899
1897
|
throw new Error("GetAudienceParams requires id or key");
|
|
1900
1898
|
}
|
|
1901
1899
|
return apiConfig.httpClient.get(
|
|
1902
|
-
`/v1/
|
|
1900
|
+
`/v1/stores/${apiConfig.storeId}/audiences/${identifier}`,
|
|
1903
1901
|
options
|
|
1904
1902
|
);
|
|
1905
1903
|
},
|
|
1906
1904
|
async find(params, options) {
|
|
1907
1905
|
return apiConfig.httpClient.get(
|
|
1908
|
-
`/v1/
|
|
1906
|
+
`/v1/stores/${apiConfig.storeId}/audiences`,
|
|
1909
1907
|
{ ...options, params }
|
|
1910
1908
|
);
|
|
1911
1909
|
},
|
|
1912
1910
|
async getSubscribers(params, options) {
|
|
1913
1911
|
return apiConfig.httpClient.get(
|
|
1914
|
-
`/v1/
|
|
1912
|
+
`/v1/stores/${apiConfig.storeId}/audiences/${params.id}/subscribers`,
|
|
1915
1913
|
{
|
|
1916
1914
|
...options,
|
|
1917
1915
|
params: { limit: params.limit, cursor: params.cursor }
|
|
@@ -1920,14 +1918,14 @@ var createCustomerApi = (apiConfig) => {
|
|
|
1920
1918
|
},
|
|
1921
1919
|
async addSubscriber(params, options) {
|
|
1922
1920
|
return apiConfig.httpClient.post(
|
|
1923
|
-
`/v1/
|
|
1921
|
+
`/v1/stores/${apiConfig.storeId}/audiences/${params.id}/subscribers`,
|
|
1924
1922
|
{ customer_id: params.customer_id },
|
|
1925
1923
|
options
|
|
1926
1924
|
);
|
|
1927
1925
|
},
|
|
1928
1926
|
async removeSubscriber(params, options) {
|
|
1929
1927
|
return apiConfig.httpClient.delete(
|
|
1930
|
-
`/v1/
|
|
1928
|
+
`/v1/stores/${apiConfig.storeId}/audiences/${params.id}/subscribers/${params.customer_id}`,
|
|
1931
1929
|
options
|
|
1932
1930
|
);
|
|
1933
1931
|
}
|
|
@@ -1940,41 +1938,41 @@ var createCustomerApi = (apiConfig) => {
|
|
|
1940
1938
|
var createWorkflowApi = (apiConfig) => {
|
|
1941
1939
|
return {
|
|
1942
1940
|
async createWorkflow(params, options) {
|
|
1943
|
-
const {
|
|
1944
|
-
const
|
|
1941
|
+
const { store_id, ...payload } = params;
|
|
1942
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1945
1943
|
return apiConfig.httpClient.post(
|
|
1946
|
-
`/v1/
|
|
1947
|
-
{ ...payload,
|
|
1944
|
+
`/v1/stores/${target_store_id}/workflows`,
|
|
1945
|
+
{ ...payload, store_id: target_store_id },
|
|
1948
1946
|
options
|
|
1949
1947
|
);
|
|
1950
1948
|
},
|
|
1951
1949
|
async updateWorkflow(params, options) {
|
|
1952
|
-
const {
|
|
1953
|
-
const
|
|
1950
|
+
const { store_id, id, ...payload } = params;
|
|
1951
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1954
1952
|
return apiConfig.httpClient.put(
|
|
1955
|
-
`/v1/
|
|
1953
|
+
`/v1/stores/${target_store_id}/workflows/${id}`,
|
|
1956
1954
|
payload,
|
|
1957
1955
|
options
|
|
1958
1956
|
);
|
|
1959
1957
|
},
|
|
1960
1958
|
async deleteWorkflow(params, options) {
|
|
1961
|
-
const
|
|
1959
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
1962
1960
|
return apiConfig.httpClient.delete(
|
|
1963
|
-
`/v1/
|
|
1961
|
+
`/v1/stores/${store_id}/workflows/${params.id}`,
|
|
1964
1962
|
options
|
|
1965
1963
|
);
|
|
1966
1964
|
},
|
|
1967
1965
|
async getWorkflow(params, options) {
|
|
1968
|
-
const
|
|
1966
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
1969
1967
|
return apiConfig.httpClient.get(
|
|
1970
|
-
`/v1/
|
|
1968
|
+
`/v1/stores/${store_id}/workflows/${params.id}`,
|
|
1971
1969
|
options
|
|
1972
1970
|
);
|
|
1973
1971
|
},
|
|
1974
1972
|
async getWorkflows(params, options) {
|
|
1975
|
-
const
|
|
1976
|
-
const {
|
|
1977
|
-
return apiConfig.httpClient.get(`/v1/
|
|
1973
|
+
const store_id = params?.store_id || apiConfig.storeId;
|
|
1974
|
+
const { store_id: _, ...queryParams } = params || {};
|
|
1975
|
+
return apiConfig.httpClient.get(`/v1/stores/${store_id}/workflows`, {
|
|
1978
1976
|
...options,
|
|
1979
1977
|
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
1980
1978
|
});
|
|
@@ -1984,10 +1982,10 @@ var createWorkflowApi = (apiConfig) => {
|
|
|
1984
1982
|
return apiConfig.httpClient.post(`/v1/workflows/trigger/${secret}`, payload, options);
|
|
1985
1983
|
},
|
|
1986
1984
|
async getWorkflowExecutions(params, options) {
|
|
1987
|
-
const
|
|
1988
|
-
const {
|
|
1985
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
1986
|
+
const { store_id: _, workflow_id, ...queryParams } = params;
|
|
1989
1987
|
return apiConfig.httpClient.get(
|
|
1990
|
-
`/v1/
|
|
1988
|
+
`/v1/stores/${store_id}/workflows/${workflow_id}/executions`,
|
|
1991
1989
|
{
|
|
1992
1990
|
...options,
|
|
1993
1991
|
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
@@ -1995,9 +1993,9 @@ var createWorkflowApi = (apiConfig) => {
|
|
|
1995
1993
|
);
|
|
1996
1994
|
},
|
|
1997
1995
|
async getWorkflowExecution(params, options) {
|
|
1998
|
-
const
|
|
1996
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
1999
1997
|
return apiConfig.httpClient.get(
|
|
2000
|
-
`/v1/
|
|
1998
|
+
`/v1/stores/${store_id}/workflows/${params.workflow_id}/executions/${params.execution_id}`,
|
|
2001
1999
|
options
|
|
2002
2000
|
);
|
|
2003
2001
|
}
|
|
@@ -2025,7 +2023,7 @@ var createShippingApi = (apiConfig) => {
|
|
|
2025
2023
|
async getRates(params, options) {
|
|
2026
2024
|
const { order_id, ...payload } = params;
|
|
2027
2025
|
return apiConfig.httpClient.post(
|
|
2028
|
-
`/v1/
|
|
2026
|
+
`/v1/stores/${apiConfig.storeId}/orders/${order_id}/shipping/rates`,
|
|
2029
2027
|
payload,
|
|
2030
2028
|
options
|
|
2031
2029
|
);
|
|
@@ -2033,7 +2031,7 @@ var createShippingApi = (apiConfig) => {
|
|
|
2033
2031
|
async ship(params, options) {
|
|
2034
2032
|
const { order_id, ...payload } = params;
|
|
2035
2033
|
return apiConfig.httpClient.post(
|
|
2036
|
-
`/v1/
|
|
2034
|
+
`/v1/stores/${apiConfig.storeId}/orders/${order_id}/ship`,
|
|
2037
2035
|
payload,
|
|
2038
2036
|
options
|
|
2039
2037
|
);
|
|
@@ -2045,63 +2043,63 @@ var createShippingApi = (apiConfig) => {
|
|
|
2045
2043
|
var createAgentApi = (apiConfig) => {
|
|
2046
2044
|
return {
|
|
2047
2045
|
async createAgent(params, options) {
|
|
2048
|
-
const {
|
|
2049
|
-
const
|
|
2046
|
+
const { store_id, ...payload } = params;
|
|
2047
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2050
2048
|
return apiConfig.httpClient.post(
|
|
2051
|
-
`/v1/
|
|
2052
|
-
{ ...payload,
|
|
2049
|
+
`/v1/stores/${target_store_id}/agents`,
|
|
2050
|
+
{ ...payload, store_id: target_store_id },
|
|
2053
2051
|
options
|
|
2054
2052
|
);
|
|
2055
2053
|
},
|
|
2056
2054
|
async updateAgent(params, options) {
|
|
2057
|
-
const {
|
|
2058
|
-
const
|
|
2055
|
+
const { store_id, id, ...payload } = params;
|
|
2056
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2059
2057
|
return apiConfig.httpClient.put(
|
|
2060
|
-
`/v1/
|
|
2058
|
+
`/v1/stores/${target_store_id}/agents/${id}`,
|
|
2061
2059
|
payload,
|
|
2062
2060
|
options
|
|
2063
2061
|
);
|
|
2064
2062
|
},
|
|
2065
2063
|
async deleteAgent(params, options) {
|
|
2066
|
-
const
|
|
2064
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
2067
2065
|
return apiConfig.httpClient.delete(
|
|
2068
|
-
`/v1/
|
|
2066
|
+
`/v1/stores/${store_id}/agents/${params.id}`,
|
|
2069
2067
|
options
|
|
2070
2068
|
);
|
|
2071
2069
|
},
|
|
2072
2070
|
async getAgent(params, options) {
|
|
2073
|
-
const
|
|
2071
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
2074
2072
|
return apiConfig.httpClient.get(
|
|
2075
|
-
`/v1/
|
|
2073
|
+
`/v1/stores/${store_id}/agents/${params.id}`,
|
|
2076
2074
|
options
|
|
2077
2075
|
);
|
|
2078
2076
|
},
|
|
2079
2077
|
async getAgents(params, options) {
|
|
2080
|
-
const
|
|
2081
|
-
const {
|
|
2082
|
-
return apiConfig.httpClient.get(`/v1/
|
|
2078
|
+
const store_id = params?.store_id || apiConfig.storeId;
|
|
2079
|
+
const { store_id: _, ...queryParams } = params || {};
|
|
2080
|
+
return apiConfig.httpClient.get(`/v1/stores/${store_id}/agents`, {
|
|
2083
2081
|
...options,
|
|
2084
2082
|
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
2085
2083
|
});
|
|
2086
2084
|
},
|
|
2087
2085
|
async sendMessage(params, options) {
|
|
2088
|
-
const
|
|
2086
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
2089
2087
|
const body = { message: params.message };
|
|
2090
2088
|
if (params.chat_id) body.chat_id = params.chat_id;
|
|
2091
2089
|
if (params.direct) body.direct = params.direct;
|
|
2092
2090
|
return apiConfig.httpClient.post(
|
|
2093
|
-
`/v1/
|
|
2091
|
+
`/v1/stores/${store_id}/agents/${params.id}/chats/messages`,
|
|
2094
2092
|
body,
|
|
2095
2093
|
options
|
|
2096
2094
|
);
|
|
2097
2095
|
},
|
|
2098
2096
|
async getChats(params, options) {
|
|
2099
|
-
const
|
|
2097
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
2100
2098
|
const queryParams = {};
|
|
2101
2099
|
if (params.limit) queryParams.limit = String(params.limit);
|
|
2102
2100
|
if (params.cursor) queryParams.cursor = params.cursor;
|
|
2103
2101
|
return apiConfig.httpClient.get(
|
|
2104
|
-
`/v1/
|
|
2102
|
+
`/v1/stores/${store_id}/agents/${params.id}/chats`,
|
|
2105
2103
|
{
|
|
2106
2104
|
...options,
|
|
2107
2105
|
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
@@ -2109,44 +2107,44 @@ var createAgentApi = (apiConfig) => {
|
|
|
2109
2107
|
);
|
|
2110
2108
|
},
|
|
2111
2109
|
async getChat(params, options) {
|
|
2112
|
-
const
|
|
2110
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
2113
2111
|
return apiConfig.httpClient.get(
|
|
2114
|
-
`/v1/
|
|
2112
|
+
`/v1/stores/${store_id}/agents/${params.id}/chats/${params.chat_id}`,
|
|
2115
2113
|
options
|
|
2116
2114
|
);
|
|
2117
2115
|
},
|
|
2118
2116
|
async updateChat(params, options) {
|
|
2119
|
-
const
|
|
2117
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
2120
2118
|
return apiConfig.httpClient.put(
|
|
2121
|
-
`/v1/
|
|
2119
|
+
`/v1/stores/${store_id}/agents/${params.id}/chats/${params.chat_id}`,
|
|
2122
2120
|
{ status: params.status },
|
|
2123
2121
|
options
|
|
2124
2122
|
);
|
|
2125
2123
|
},
|
|
2126
2124
|
async rateChat(params, options) {
|
|
2127
|
-
const
|
|
2125
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
2128
2126
|
const body = { rating: params.rating };
|
|
2129
2127
|
if (params.comment) body.comment = params.comment;
|
|
2130
2128
|
return apiConfig.httpClient.post(
|
|
2131
|
-
`/v1/
|
|
2129
|
+
`/v1/stores/${store_id}/agents/${params.id}/chats/${params.chat_id}/rate`,
|
|
2132
2130
|
body,
|
|
2133
2131
|
options
|
|
2134
2132
|
);
|
|
2135
2133
|
},
|
|
2136
|
-
async
|
|
2137
|
-
const
|
|
2138
|
-
const {
|
|
2139
|
-
return apiConfig.httpClient.get(`/v1/
|
|
2134
|
+
async getStoreChats(params, options) {
|
|
2135
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
2136
|
+
const { store_id: _, ...queryParams } = params;
|
|
2137
|
+
return apiConfig.httpClient.get(`/v1/stores/${store_id}/chats`, {
|
|
2140
2138
|
...options,
|
|
2141
2139
|
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
2142
2140
|
});
|
|
2143
2141
|
},
|
|
2144
2142
|
async getChatMessages(params, options) {
|
|
2145
|
-
const
|
|
2143
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
2146
2144
|
const queryParams = {};
|
|
2147
2145
|
if (params.limit) queryParams.limit = String(params.limit);
|
|
2148
2146
|
return apiConfig.httpClient.get(
|
|
2149
|
-
`/v1/
|
|
2147
|
+
`/v1/stores/${store_id}/agents/${params.id}/chats/${params.chat_id}/messages`,
|
|
2150
2148
|
{
|
|
2151
2149
|
...options,
|
|
2152
2150
|
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
@@ -2160,50 +2158,50 @@ var createAgentApi = (apiConfig) => {
|
|
|
2160
2158
|
var createEmailTemplateApi = (apiConfig) => {
|
|
2161
2159
|
return {
|
|
2162
2160
|
async createEmailTemplate(params, options) {
|
|
2163
|
-
const {
|
|
2164
|
-
const
|
|
2161
|
+
const { store_id, ...payload } = params;
|
|
2162
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2165
2163
|
return apiConfig.httpClient.post(
|
|
2166
|
-
`/v1/
|
|
2164
|
+
`/v1/stores/${target_store_id}/email-templates`,
|
|
2167
2165
|
payload,
|
|
2168
2166
|
options
|
|
2169
2167
|
);
|
|
2170
2168
|
},
|
|
2171
2169
|
async updateEmailTemplate(params, options) {
|
|
2172
|
-
const {
|
|
2173
|
-
const
|
|
2170
|
+
const { store_id, ...payload } = params;
|
|
2171
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2174
2172
|
return apiConfig.httpClient.put(
|
|
2175
|
-
`/v1/
|
|
2173
|
+
`/v1/stores/${target_store_id}/email-templates/${params.id}`,
|
|
2176
2174
|
payload,
|
|
2177
2175
|
options
|
|
2178
2176
|
);
|
|
2179
2177
|
},
|
|
2180
2178
|
async deleteEmailTemplate(params, options) {
|
|
2181
|
-
const
|
|
2179
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
2182
2180
|
return apiConfig.httpClient.delete(
|
|
2183
|
-
`/v1/
|
|
2181
|
+
`/v1/stores/${target_store_id}/email-templates/${params.id}`,
|
|
2184
2182
|
options
|
|
2185
2183
|
);
|
|
2186
2184
|
},
|
|
2187
2185
|
async getEmailTemplate(params, options) {
|
|
2188
|
-
const
|
|
2186
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
2189
2187
|
let identifier;
|
|
2190
2188
|
if (params.id) {
|
|
2191
2189
|
identifier = params.id;
|
|
2192
2190
|
} else if (params.key) {
|
|
2193
|
-
identifier = `${
|
|
2191
|
+
identifier = `${target_store_id}:${params.key}`;
|
|
2194
2192
|
} else {
|
|
2195
2193
|
throw new Error("GetEmailTemplateParams requires id or key");
|
|
2196
2194
|
}
|
|
2197
2195
|
return apiConfig.httpClient.get(
|
|
2198
|
-
`/v1/
|
|
2196
|
+
`/v1/stores/${target_store_id}/email-templates/${identifier}`,
|
|
2199
2197
|
options
|
|
2200
2198
|
);
|
|
2201
2199
|
},
|
|
2202
2200
|
async getEmailTemplates(params, options) {
|
|
2203
|
-
const {
|
|
2204
|
-
const
|
|
2201
|
+
const { store_id, ...queryParams } = params;
|
|
2202
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2205
2203
|
return apiConfig.httpClient.get(
|
|
2206
|
-
`/v1/
|
|
2204
|
+
`/v1/stores/${target_store_id}/email-templates`,
|
|
2207
2205
|
{
|
|
2208
2206
|
...options,
|
|
2209
2207
|
params: queryParams
|
|
@@ -2217,50 +2215,50 @@ var createEmailTemplateApi = (apiConfig) => {
|
|
|
2217
2215
|
var createFormApi = (apiConfig) => {
|
|
2218
2216
|
return {
|
|
2219
2217
|
async createForm(params, options) {
|
|
2220
|
-
const {
|
|
2221
|
-
const
|
|
2218
|
+
const { store_id, ...payload } = params;
|
|
2219
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2222
2220
|
return apiConfig.httpClient.post(
|
|
2223
|
-
`/v1/
|
|
2221
|
+
`/v1/stores/${target_store_id}/forms`,
|
|
2224
2222
|
payload,
|
|
2225
2223
|
options
|
|
2226
2224
|
);
|
|
2227
2225
|
},
|
|
2228
2226
|
async updateForm(params, options) {
|
|
2229
|
-
const {
|
|
2230
|
-
const
|
|
2227
|
+
const { store_id, ...payload } = params;
|
|
2228
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2231
2229
|
return apiConfig.httpClient.put(
|
|
2232
|
-
`/v1/
|
|
2230
|
+
`/v1/stores/${target_store_id}/forms/${params.id}`,
|
|
2233
2231
|
payload,
|
|
2234
2232
|
options
|
|
2235
2233
|
);
|
|
2236
2234
|
},
|
|
2237
2235
|
async deleteForm(params, options) {
|
|
2238
|
-
const
|
|
2236
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
2239
2237
|
return apiConfig.httpClient.delete(
|
|
2240
|
-
`/v1/
|
|
2238
|
+
`/v1/stores/${target_store_id}/forms/${params.id}`,
|
|
2241
2239
|
options
|
|
2242
2240
|
);
|
|
2243
2241
|
},
|
|
2244
2242
|
async getForm(params, options) {
|
|
2245
|
-
const
|
|
2243
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
2246
2244
|
let identifier;
|
|
2247
2245
|
if (params.id) {
|
|
2248
2246
|
identifier = params.id;
|
|
2249
2247
|
} else if (params.key) {
|
|
2250
|
-
identifier = `${
|
|
2248
|
+
identifier = `${target_store_id}:${params.key}`;
|
|
2251
2249
|
} else {
|
|
2252
2250
|
throw new Error("GetFormParams requires id or key");
|
|
2253
2251
|
}
|
|
2254
2252
|
return apiConfig.httpClient.get(
|
|
2255
|
-
`/v1/
|
|
2253
|
+
`/v1/stores/${target_store_id}/forms/${identifier}`,
|
|
2256
2254
|
options
|
|
2257
2255
|
);
|
|
2258
2256
|
},
|
|
2259
2257
|
async getForms(params, options) {
|
|
2260
|
-
const {
|
|
2261
|
-
const
|
|
2258
|
+
const { store_id, ...queryParams } = params;
|
|
2259
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2262
2260
|
return apiConfig.httpClient.get(
|
|
2263
|
-
`/v1/
|
|
2261
|
+
`/v1/stores/${target_store_id}/forms`,
|
|
2264
2262
|
{
|
|
2265
2263
|
...options,
|
|
2266
2264
|
params: queryParams
|
|
@@ -2268,38 +2266,38 @@ var createFormApi = (apiConfig) => {
|
|
|
2268
2266
|
);
|
|
2269
2267
|
},
|
|
2270
2268
|
async submit(params, options) {
|
|
2271
|
-
const {
|
|
2272
|
-
const
|
|
2269
|
+
const { store_id, form_id, ...payload } = params;
|
|
2270
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2273
2271
|
return apiConfig.httpClient.post(
|
|
2274
|
-
`/v1/
|
|
2275
|
-
{ ...payload, form_id,
|
|
2272
|
+
`/v1/stores/${target_store_id}/forms/${form_id}/submissions`,
|
|
2273
|
+
{ ...payload, form_id, store_id: target_store_id },
|
|
2276
2274
|
options
|
|
2277
2275
|
);
|
|
2278
2276
|
},
|
|
2279
2277
|
async getSubmissions(params, options) {
|
|
2280
|
-
const {
|
|
2281
|
-
const
|
|
2278
|
+
const { store_id, form_id, ...queryParams } = params;
|
|
2279
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2282
2280
|
return apiConfig.httpClient.get(
|
|
2283
|
-
`/v1/
|
|
2281
|
+
`/v1/stores/${target_store_id}/forms/${form_id}/submissions`,
|
|
2284
2282
|
{
|
|
2285
2283
|
...options,
|
|
2286
|
-
params: { ...queryParams, form_id,
|
|
2284
|
+
params: { ...queryParams, form_id, store_id: target_store_id }
|
|
2287
2285
|
}
|
|
2288
2286
|
);
|
|
2289
2287
|
},
|
|
2290
2288
|
async getSubmission(params, options) {
|
|
2291
|
-
const
|
|
2289
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
2292
2290
|
return apiConfig.httpClient.get(
|
|
2293
|
-
`/v1/
|
|
2291
|
+
`/v1/stores/${target_store_id}/forms/${params.form_id}/submissions/${params.id}`,
|
|
2294
2292
|
options
|
|
2295
2293
|
);
|
|
2296
2294
|
},
|
|
2297
2295
|
async updateSubmission(params, options) {
|
|
2298
|
-
const {
|
|
2299
|
-
const
|
|
2296
|
+
const { store_id, form_id, id, ...payload } = params;
|
|
2297
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2300
2298
|
return apiConfig.httpClient.put(
|
|
2301
|
-
`/v1/
|
|
2302
|
-
{ ...payload, form_id,
|
|
2299
|
+
`/v1/stores/${target_store_id}/forms/${form_id}/submissions/${id}`,
|
|
2300
|
+
{ ...payload, form_id, store_id: target_store_id, id },
|
|
2303
2301
|
options
|
|
2304
2302
|
);
|
|
2305
2303
|
}
|
|
@@ -2310,50 +2308,50 @@ var createFormApi = (apiConfig) => {
|
|
|
2310
2308
|
var createTaxonomyApi = (apiConfig) => {
|
|
2311
2309
|
return {
|
|
2312
2310
|
async createTaxonomy(params, options) {
|
|
2313
|
-
const {
|
|
2314
|
-
const
|
|
2311
|
+
const { store_id, ...payload } = params;
|
|
2312
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2315
2313
|
return apiConfig.httpClient.post(
|
|
2316
|
-
`/v1/
|
|
2314
|
+
`/v1/stores/${target_store_id}/taxonomies`,
|
|
2317
2315
|
payload,
|
|
2318
2316
|
options
|
|
2319
2317
|
);
|
|
2320
2318
|
},
|
|
2321
2319
|
async updateTaxonomy(params, options) {
|
|
2322
|
-
const {
|
|
2323
|
-
const
|
|
2320
|
+
const { store_id, ...payload } = params;
|
|
2321
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2324
2322
|
return apiConfig.httpClient.put(
|
|
2325
|
-
`/v1/
|
|
2323
|
+
`/v1/stores/${target_store_id}/taxonomies/${params.id}`,
|
|
2326
2324
|
payload,
|
|
2327
2325
|
options
|
|
2328
2326
|
);
|
|
2329
2327
|
},
|
|
2330
2328
|
async deleteTaxonomy(params, options) {
|
|
2331
|
-
const
|
|
2329
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
2332
2330
|
return apiConfig.httpClient.delete(
|
|
2333
|
-
`/v1/
|
|
2331
|
+
`/v1/stores/${target_store_id}/taxonomies/${params.id}`,
|
|
2334
2332
|
options
|
|
2335
2333
|
);
|
|
2336
2334
|
},
|
|
2337
2335
|
async getTaxonomy(params, options) {
|
|
2338
|
-
const
|
|
2336
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
2339
2337
|
let identifier;
|
|
2340
2338
|
if (params.id) {
|
|
2341
2339
|
identifier = params.id;
|
|
2342
2340
|
} else if (params.key) {
|
|
2343
|
-
identifier = `${
|
|
2341
|
+
identifier = `${target_store_id}:${params.key}`;
|
|
2344
2342
|
} else {
|
|
2345
2343
|
throw new Error("GetTaxonomyParams requires id or key");
|
|
2346
2344
|
}
|
|
2347
2345
|
return apiConfig.httpClient.get(
|
|
2348
|
-
`/v1/
|
|
2346
|
+
`/v1/stores/${target_store_id}/taxonomies/${identifier}`,
|
|
2349
2347
|
options
|
|
2350
2348
|
);
|
|
2351
2349
|
},
|
|
2352
2350
|
async getTaxonomies(params, options) {
|
|
2353
|
-
const {
|
|
2354
|
-
const
|
|
2351
|
+
const { store_id, ...queryParams } = params;
|
|
2352
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2355
2353
|
return apiConfig.httpClient.get(
|
|
2356
|
-
`/v1/
|
|
2354
|
+
`/v1/stores/${target_store_id}/taxonomies`,
|
|
2357
2355
|
{
|
|
2358
2356
|
...options,
|
|
2359
2357
|
params: queryParams
|
|
@@ -2361,10 +2359,10 @@ var createTaxonomyApi = (apiConfig) => {
|
|
|
2361
2359
|
);
|
|
2362
2360
|
},
|
|
2363
2361
|
async getTaxonomyChildren(params, options) {
|
|
2364
|
-
const { id,
|
|
2365
|
-
const
|
|
2362
|
+
const { id, store_id } = params;
|
|
2363
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2366
2364
|
return apiConfig.httpClient.get(
|
|
2367
|
-
`/v1/
|
|
2365
|
+
`/v1/stores/${target_store_id}/taxonomies/${id}/children`,
|
|
2368
2366
|
options
|
|
2369
2367
|
);
|
|
2370
2368
|
}
|
|
@@ -2375,9 +2373,9 @@ var createTaxonomyApi = (apiConfig) => {
|
|
|
2375
2373
|
var createAnalyticsApi = (apiConfig) => {
|
|
2376
2374
|
return {
|
|
2377
2375
|
async query(spec, options) {
|
|
2378
|
-
const
|
|
2376
|
+
const store_id = options?.store_id || apiConfig.storeId;
|
|
2379
2377
|
return apiConfig.httpClient.post(
|
|
2380
|
-
`/v1/
|
|
2378
|
+
`/v1/stores/${store_id}/analytics/query`,
|
|
2381
2379
|
spec,
|
|
2382
2380
|
options
|
|
2383
2381
|
);
|
|
@@ -2461,51 +2459,6 @@ function validatePhoneNumber(phone) {
|
|
|
2461
2459
|
}
|
|
2462
2460
|
return { isValid: true };
|
|
2463
2461
|
}
|
|
2464
|
-
function createStores() {
|
|
2465
|
-
const $customer = nanostores.atom(null);
|
|
2466
|
-
const $business = nanostores.atom(null);
|
|
2467
|
-
const $market = nanostores.atom(null);
|
|
2468
|
-
const $loading = nanostores.atom(false);
|
|
2469
|
-
const $error = nanostores.atom(null);
|
|
2470
|
-
const $isLoggedIn = nanostores.computed($customer, (c) => !!c?.emails?.length);
|
|
2471
|
-
const $currency = nanostores.computed($market, (m) => m?.currency);
|
|
2472
|
-
const $currencySymbol = nanostores.computed($market, (m) => {
|
|
2473
|
-
if (!m?.currency) return void 0;
|
|
2474
|
-
return new Intl.NumberFormat("en", {
|
|
2475
|
-
style: "currency",
|
|
2476
|
-
currency: m.currency.toUpperCase(),
|
|
2477
|
-
currencyDisplay: "narrowSymbol"
|
|
2478
|
-
}).formatToParts(0).find((p) => p.type === "currency")?.value || m.currency.toUpperCase();
|
|
2479
|
-
});
|
|
2480
|
-
const $paymentMethods = nanostores.computed($market, (m) => m?.payment_methods || []);
|
|
2481
|
-
const $paymentConfig = nanostores.computed([$business, $paymentMethods], (biz, methods) => {
|
|
2482
|
-
const payment = biz?.payment || null;
|
|
2483
|
-
const hasCreditCard = methods.some((m) => m.id === "credit_card");
|
|
2484
|
-
return {
|
|
2485
|
-
provider: payment,
|
|
2486
|
-
enabled: hasCreditCard && !!payment
|
|
2487
|
-
};
|
|
2488
|
-
});
|
|
2489
|
-
const $zones = nanostores.computed($market, (m) => m?.zones || []);
|
|
2490
|
-
return {
|
|
2491
|
-
customer: $customer,
|
|
2492
|
-
business: $business,
|
|
2493
|
-
market: $market,
|
|
2494
|
-
loading: $loading,
|
|
2495
|
-
error: $error,
|
|
2496
|
-
isLoggedIn: $isLoggedIn,
|
|
2497
|
-
currency: $currency,
|
|
2498
|
-
currencySymbol: $currencySymbol,
|
|
2499
|
-
paymentMethods: $paymentMethods,
|
|
2500
|
-
paymentConfig: $paymentConfig,
|
|
2501
|
-
zones: $zones
|
|
2502
|
-
};
|
|
2503
|
-
}
|
|
2504
|
-
function populateStores(stores, data) {
|
|
2505
|
-
stores.customer.set(data.customer);
|
|
2506
|
-
stores.business.set(data.business);
|
|
2507
|
-
stores.market.set(data.market);
|
|
2508
|
-
}
|
|
2509
2462
|
|
|
2510
2463
|
// src/utils/timezone.ts
|
|
2511
2464
|
var tzGroups = [
|
|
@@ -2680,7 +2633,7 @@ function getFirstAvailableFCId(variant, quantity = 1) {
|
|
|
2680
2633
|
}
|
|
2681
2634
|
|
|
2682
2635
|
// src/index.ts
|
|
2683
|
-
var SDK_VERSION = "0.7.
|
|
2636
|
+
var SDK_VERSION = "0.7.95";
|
|
2684
2637
|
var SUPPORTED_FRAMEWORKS = [
|
|
2685
2638
|
"astro",
|
|
2686
2639
|
"react",
|
|
@@ -2727,7 +2680,7 @@ function createUtilitySurface(apiConfig) {
|
|
|
2727
2680
|
getFirstAvailableFCId
|
|
2728
2681
|
};
|
|
2729
2682
|
}
|
|
2730
|
-
|
|
2683
|
+
function createAdmin(config) {
|
|
2731
2684
|
const locale = config.locale || "en";
|
|
2732
2685
|
const getToken = config.getToken || defaultGetToken;
|
|
2733
2686
|
const setToken = config.setToken || defaultSetToken;
|
|
@@ -2736,7 +2689,7 @@ async function createAdmin(config) {
|
|
|
2736
2689
|
const httpClient = createHttpClient({ ...config, getToken, setToken, logout });
|
|
2737
2690
|
const apiConfig = {
|
|
2738
2691
|
httpClient,
|
|
2739
|
-
|
|
2692
|
+
storeId: config.storeId,
|
|
2740
2693
|
baseUrl: config.baseUrl,
|
|
2741
2694
|
market: config.market,
|
|
2742
2695
|
locale,
|
|
@@ -2745,7 +2698,7 @@ async function createAdmin(config) {
|
|
|
2745
2698
|
};
|
|
2746
2699
|
const accountApi = createAccountApi(apiConfig);
|
|
2747
2700
|
const authApi = createAuthApi(apiConfig);
|
|
2748
|
-
const
|
|
2701
|
+
const storeApi = createStoreApi(apiConfig);
|
|
2749
2702
|
const platformApi = createPlatformApi(apiConfig);
|
|
2750
2703
|
const cmsApi = createCmsApi(apiConfig);
|
|
2751
2704
|
const eshopApi = createEshopApi(apiConfig);
|
|
@@ -2762,8 +2715,8 @@ async function createAdmin(config) {
|
|
|
2762
2715
|
const sdk = {
|
|
2763
2716
|
auth: authApi,
|
|
2764
2717
|
account: accountApi,
|
|
2765
|
-
|
|
2766
|
-
...
|
|
2718
|
+
store: {
|
|
2719
|
+
...storeApi,
|
|
2767
2720
|
location: locationApi,
|
|
2768
2721
|
market: marketApi
|
|
2769
2722
|
},
|
|
@@ -2890,7 +2843,7 @@ async function createAdmin(config) {
|
|
|
2890
2843
|
getChat: agentApi.getChat,
|
|
2891
2844
|
updateChat: agentApi.updateChat,
|
|
2892
2845
|
rateChat: agentApi.rateChat,
|
|
2893
|
-
|
|
2846
|
+
getStoreChats: agentApi.getStoreChats,
|
|
2894
2847
|
getChatMessages: agentApi.getChatMessages
|
|
2895
2848
|
},
|
|
2896
2849
|
workflow: {
|
|
@@ -2907,10 +2860,10 @@ async function createAdmin(config) {
|
|
|
2907
2860
|
analytics: {
|
|
2908
2861
|
query: analyticsApi.query
|
|
2909
2862
|
},
|
|
2910
|
-
|
|
2911
|
-
apiConfig.
|
|
2863
|
+
setStoreId: (storeId) => {
|
|
2864
|
+
apiConfig.storeId = storeId;
|
|
2912
2865
|
},
|
|
2913
|
-
|
|
2866
|
+
getStoreId: () => apiConfig.storeId,
|
|
2914
2867
|
setMarket: (market) => {
|
|
2915
2868
|
apiConfig.market = market;
|
|
2916
2869
|
},
|
|
@@ -2934,17 +2887,17 @@ function createStorefront(config) {
|
|
|
2934
2887
|
const setToken = config.setToken || defaultSetToken;
|
|
2935
2888
|
const logout = config.logout || defaultLogout;
|
|
2936
2889
|
const isAuthenticated = config.isAuthenticated || defaultIsAuthenticated;
|
|
2937
|
-
let
|
|
2890
|
+
let refresh_store_id = config.storeId;
|
|
2938
2891
|
const httpClient = createHttpClient({
|
|
2939
2892
|
...config,
|
|
2940
2893
|
getToken,
|
|
2941
2894
|
setToken,
|
|
2942
2895
|
logout,
|
|
2943
|
-
refreshPath: () => `/v1/storefront/${
|
|
2896
|
+
refreshPath: () => `/v1/storefront/${refresh_store_id}/customers/auth/refresh`
|
|
2944
2897
|
});
|
|
2945
2898
|
const apiConfig = {
|
|
2946
2899
|
httpClient,
|
|
2947
|
-
|
|
2900
|
+
storeId: config.storeId,
|
|
2948
2901
|
baseUrl: config.baseUrl,
|
|
2949
2902
|
market,
|
|
2950
2903
|
locale,
|
|
@@ -2952,77 +2905,119 @@ function createStorefront(config) {
|
|
|
2952
2905
|
getToken
|
|
2953
2906
|
};
|
|
2954
2907
|
const storefrontApi = createStorefrontApi(apiConfig);
|
|
2955
|
-
const stores = createStores();
|
|
2956
2908
|
let sessionPromise = null;
|
|
2957
|
-
let
|
|
2958
|
-
const
|
|
2959
|
-
|
|
2960
|
-
|
|
2909
|
+
let currentSession = null;
|
|
2910
|
+
const sessionListeners = /* @__PURE__ */ new Set();
|
|
2911
|
+
const customerApi = storefrontApi.crm.customer;
|
|
2912
|
+
function emitSessionChange(session2) {
|
|
2913
|
+
for (const listener of sessionListeners) {
|
|
2914
|
+
Promise.resolve().then(() => listener(session2)).catch(() => {
|
|
2915
|
+
});
|
|
2916
|
+
}
|
|
2917
|
+
}
|
|
2918
|
+
function setCurrentSessionFromResult(result) {
|
|
2919
|
+
const s = {
|
|
2920
|
+
customer: result.customer,
|
|
2921
|
+
store: result.store,
|
|
2922
|
+
market: result.market || null
|
|
2923
|
+
};
|
|
2924
|
+
currentSession = s;
|
|
2925
|
+
emitSessionChange(s);
|
|
2926
|
+
return s;
|
|
2927
|
+
}
|
|
2928
|
+
function clearSession() {
|
|
2929
|
+
sessionPromise = null;
|
|
2930
|
+
currentSession = null;
|
|
2931
|
+
emitSessionChange(null);
|
|
2932
|
+
}
|
|
2933
|
+
async function invalidateAfterAuth(promise) {
|
|
2934
|
+
const result = await promise;
|
|
2935
|
+
clearSession();
|
|
2936
|
+
return result;
|
|
2937
|
+
}
|
|
2961
2938
|
function session(market2) {
|
|
2962
2939
|
if (market2 !== void 0) apiConfig.market = market2;
|
|
2963
2940
|
if (sessionPromise) return sessionPromise;
|
|
2964
2941
|
sessionPromise = (async () => {
|
|
2965
|
-
stores.loading.set(true);
|
|
2966
|
-
stores.error.set(null);
|
|
2967
2942
|
try {
|
|
2968
|
-
const result = await
|
|
2943
|
+
const result = await customerApi.session({
|
|
2969
2944
|
market: apiConfig.market
|
|
2970
2945
|
});
|
|
2971
|
-
|
|
2972
|
-
customer: result.customer,
|
|
2973
|
-
business: result.business,
|
|
2974
|
-
market: result.market || null
|
|
2975
|
-
};
|
|
2976
|
-
populateStores(stores, s);
|
|
2977
|
-
resolveReady();
|
|
2978
|
-
return s;
|
|
2946
|
+
return setCurrentSessionFromResult(result);
|
|
2979
2947
|
} catch (err) {
|
|
2980
|
-
const status = err?.status || err?.response?.status;
|
|
2948
|
+
const status = err?.statusCode || err?.status || err?.response?.status;
|
|
2981
2949
|
if (status === 401) {
|
|
2950
|
+
currentSession = null;
|
|
2951
|
+
emitSessionChange(null);
|
|
2982
2952
|
await setToken({ access_token: "", refresh_token: "", access_expires_at: 0 });
|
|
2983
|
-
const result = await
|
|
2953
|
+
const result = await customerApi.session({
|
|
2984
2954
|
market: apiConfig.market
|
|
2985
2955
|
});
|
|
2986
|
-
|
|
2987
|
-
customer: result.customer,
|
|
2988
|
-
business: result.business,
|
|
2989
|
-
market: result.market || null
|
|
2990
|
-
};
|
|
2991
|
-
populateStores(stores, s);
|
|
2992
|
-
resolveReady();
|
|
2993
|
-
return s;
|
|
2956
|
+
return setCurrentSessionFromResult(result);
|
|
2994
2957
|
}
|
|
2995
2958
|
throw err;
|
|
2996
|
-
} finally {
|
|
2997
|
-
stores.loading.set(false);
|
|
2998
2959
|
}
|
|
2999
2960
|
})().catch((err) => {
|
|
3000
|
-
stores.error.set(err.message || "Session failed");
|
|
3001
2961
|
sessionPromise = null;
|
|
3002
2962
|
throw err;
|
|
3003
2963
|
});
|
|
3004
2964
|
return sessionPromise;
|
|
3005
2965
|
}
|
|
3006
2966
|
function setMarket(key) {
|
|
3007
|
-
|
|
3008
|
-
|
|
2967
|
+
apiConfig.market = key;
|
|
2968
|
+
clearSession();
|
|
2969
|
+
}
|
|
2970
|
+
function onSessionChange(listener) {
|
|
2971
|
+
sessionListeners.add(listener);
|
|
2972
|
+
if (currentSession) {
|
|
2973
|
+
Promise.resolve().then(() => listener(currentSession)).catch(() => {
|
|
2974
|
+
});
|
|
2975
|
+
}
|
|
2976
|
+
return () => {
|
|
2977
|
+
sessionListeners.delete(listener);
|
|
2978
|
+
};
|
|
2979
|
+
}
|
|
2980
|
+
function getSession() {
|
|
2981
|
+
return currentSession;
|
|
2982
|
+
}
|
|
2983
|
+
function logoutAndClearSession() {
|
|
2984
|
+
clearSession();
|
|
2985
|
+
return logout();
|
|
3009
2986
|
}
|
|
2987
|
+
function setTokenAndClearSession(tokens) {
|
|
2988
|
+
setToken(tokens);
|
|
2989
|
+
clearSession();
|
|
2990
|
+
}
|
|
2991
|
+
const crm = {
|
|
2992
|
+
...storefrontApi.crm,
|
|
2993
|
+
customer: {
|
|
2994
|
+
...customerApi,
|
|
2995
|
+
async session(params, options) {
|
|
2996
|
+
const result = await customerApi.session(params, options);
|
|
2997
|
+
setCurrentSessionFromResult(result);
|
|
2998
|
+
return result;
|
|
2999
|
+
},
|
|
3000
|
+
connect: (params, options) => invalidateAfterAuth(customerApi.connect(params, options)),
|
|
3001
|
+
verify: (params, options) => invalidateAfterAuth(customerApi.verify(params, options))
|
|
3002
|
+
}
|
|
3003
|
+
};
|
|
3010
3004
|
return {
|
|
3011
3005
|
session,
|
|
3012
|
-
|
|
3013
|
-
|
|
3006
|
+
getSession,
|
|
3007
|
+
onSessionChange,
|
|
3008
|
+
store: storefrontApi.store,
|
|
3014
3009
|
cms: storefrontApi.cms,
|
|
3015
3010
|
eshop: storefrontApi.eshop,
|
|
3016
3011
|
booking: storefrontApi.booking,
|
|
3017
|
-
crm
|
|
3012
|
+
crm,
|
|
3018
3013
|
activity: storefrontApi.activity,
|
|
3019
|
-
ready,
|
|
3020
3014
|
automation: storefrontApi.automation,
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
apiConfig.
|
|
3015
|
+
setStoreId: (storeId) => {
|
|
3016
|
+
refresh_store_id = storeId;
|
|
3017
|
+
apiConfig.storeId = storeId;
|
|
3018
|
+
clearSession();
|
|
3024
3019
|
},
|
|
3025
|
-
|
|
3020
|
+
getStoreId: () => apiConfig.storeId,
|
|
3026
3021
|
setMarket,
|
|
3027
3022
|
getMarket: () => apiConfig.market,
|
|
3028
3023
|
setLocale: (locale2) => {
|
|
@@ -3030,8 +3025,8 @@ function createStorefront(config) {
|
|
|
3030
3025
|
},
|
|
3031
3026
|
getLocale: () => apiConfig.locale,
|
|
3032
3027
|
isAuthenticated,
|
|
3033
|
-
logout,
|
|
3034
|
-
setToken,
|
|
3028
|
+
logout: logoutAndClearSession,
|
|
3029
|
+
setToken: setTokenAndClearSession,
|
|
3035
3030
|
extractBlockValues,
|
|
3036
3031
|
utils: createUtilitySurface(apiConfig)
|
|
3037
3032
|
};
|