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