@bookinglab/booking-journey-api 2.9.0 → 2.11.0

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/dist/index.js CHANGED
@@ -365,6 +365,173 @@ var BookingLabClient = class extends ApiClient {
365
365
  }
366
366
  });
367
367
  }
368
+ /**
369
+ * Get services for a company
370
+ * @param companyId - The company ID
371
+ * @param clientToken - Client token for authentication
372
+ */
373
+ async getCompanyServices(companyId, clientToken) {
374
+ return this.get(
375
+ `/company/${companyId}/services`,
376
+ {
377
+ headers: {
378
+ "clienttoken": clientToken
379
+ }
380
+ }
381
+ );
382
+ }
383
+ /**
384
+ * Get a single service by ID for a company
385
+ * @param companyId - The company ID
386
+ * @param serviceId - The service ID
387
+ * @param clientToken - Client token for authentication
388
+ */
389
+ async getCompanyService(companyId, serviceId, clientToken) {
390
+ return this.get(
391
+ `/company/${companyId}/service/${serviceId}`,
392
+ {
393
+ headers: {
394
+ "clienttoken": clientToken
395
+ }
396
+ }
397
+ );
398
+ }
399
+ /**
400
+ * Get all companies
401
+ * @param clientToken - Client token for authentication
402
+ * @param params - Optional query params (service_id, person_id)
403
+ */
404
+ async getCompanies(clientToken, params) {
405
+ return this.get("/companies", {
406
+ headers: {
407
+ "clienttoken": clientToken
408
+ },
409
+ params
410
+ });
411
+ }
412
+ /**
413
+ * Get questions for a company by detail group ID
414
+ * @param companyId - The company ID
415
+ * @param detailGroupId - The detail group ID
416
+ * @param clientToken - Client token for authentication
417
+ */
418
+ async getCompanyQuestions(companyId, detailGroupId, clientToken) {
419
+ return this.get(
420
+ `/company/${companyId}/questions/${detailGroupId}`,
421
+ {
422
+ headers: {
423
+ "clienttoken": clientToken
424
+ }
425
+ }
426
+ );
427
+ }
428
+ /**
429
+ * Get available days for a service within a date range
430
+ * @param companyId - The company ID
431
+ * @param serviceId - The service ID
432
+ * @param fromDate - Start date (YYYY-MM-DD)
433
+ * @param toDate - End date (YYYY-MM-DD)
434
+ * @param clientToken - Client token for authentication
435
+ * @param params - Optional query params (resource_id)
436
+ */
437
+ async getDays(companyId, serviceId, fromDate, toDate, clientToken, params) {
438
+ return this.get(
439
+ `/company/${companyId}/service/${serviceId}/days/${fromDate}/${toDate}`,
440
+ {
441
+ headers: {
442
+ "clienttoken": clientToken
443
+ },
444
+ params
445
+ }
446
+ );
447
+ }
448
+ /**
449
+ * Get available times for a service within a date range
450
+ * @param companyId - The company ID
451
+ * @param serviceId - The service ID
452
+ * @param fromDate - Start date (YYYY-MM-DD)
453
+ * @param toDate - End date (YYYY-MM-DD)
454
+ * @param clientToken - Client token for authentication
455
+ * @param params - Optional query params (duration, resource_id, person_id)
456
+ */
457
+ async getTimes(companyId, serviceId, fromDate, toDate, clientToken, params) {
458
+ return this.get(
459
+ `/company/${companyId}/service/${serviceId}/times/${fromDate}/${toDate}`,
460
+ {
461
+ headers: {
462
+ "clienttoken": clientToken
463
+ },
464
+ params
465
+ }
466
+ );
467
+ }
468
+ /**
469
+ * Create a new basket (BookingLab public)
470
+ * @param request - Body with company_id
471
+ * @param headers - Required clientToken/companyId; optional authToken/memberId
472
+ */
473
+ async createBasket(request, headers) {
474
+ const reqHeaders = {
475
+ "clienttoken": headers.clientToken,
476
+ "x-company-id": String(headers.companyId)
477
+ };
478
+ if (headers.authToken) reqHeaders["authtoken"] = headers.authToken;
479
+ if (headers.memberId !== void 0) reqHeaders["x-member-id"] = String(headers.memberId);
480
+ return this.post("/basket-public", request, {
481
+ headers: reqHeaders
482
+ });
483
+ }
484
+ /**
485
+ * Add a service item to a public basket (BookingLab)
486
+ * @param basketId - The basket ID
487
+ * @param request - Service item body
488
+ * @param headers - Required clientToken/authToken/companyId
489
+ */
490
+ async addBasketServiceItem(basketId, request, headers) {
491
+ return this.post(
492
+ `/baskets/${basketId}/service_item-public`,
493
+ request,
494
+ {
495
+ headers: {
496
+ "clienttoken": headers.clientToken,
497
+ "authtoken": headers.authToken,
498
+ "x-company-id": String(headers.companyId)
499
+ }
500
+ }
501
+ );
502
+ }
503
+ /**
504
+ * Checkout a public basket (BookingLab)
505
+ * @param basketId - The basket ID
506
+ * @param request - Body with company_id and client.id
507
+ * @param headers - Required clientToken/authToken/companyId
508
+ */
509
+ async checkoutBasketPublic(basketId, request, headers) {
510
+ return this.post(
511
+ `/baskets/${basketId}/public-checkout`,
512
+ request,
513
+ {
514
+ headers: {
515
+ "clienttoken": headers.clientToken,
516
+ "authtoken": headers.authToken,
517
+ "x-company-id": String(headers.companyId)
518
+ }
519
+ }
520
+ );
521
+ }
522
+ /**
523
+ * Delete a public basket (BookingLab)
524
+ * @param headers - Required clientToken/authToken/companyId
525
+ */
526
+ async deleteBasketPublic(headers) {
527
+ return this.delete("/basket-public", {
528
+ headers: {
529
+ "clienttoken": headers.clientToken,
530
+ "authtoken": headers.authToken,
531
+ "x-company-id": String(headers.companyId)
532
+ }
533
+ });
534
+ }
368
535
  };
369
536
  function createBookingLabClient(baseUrl, authToken, appId) {
370
537
  const client = new BookingLabClient({ baseUrl });
@@ -1115,6 +1282,108 @@ function useBookingLabGetToken(request, clientToken, enabled = true) {
1115
1282
  enabled: enabled && !!request.client && !!request.company && !!clientToken
1116
1283
  });
1117
1284
  }
1285
+ function useBookingLabServices(companyId, clientToken, enabled = true) {
1286
+ const client = useBookingLabClient();
1287
+ return reactQuery.useQuery({
1288
+ queryKey: ["bookingLabServices", companyId],
1289
+ queryFn: async () => {
1290
+ const response = await client.getCompanyServices(companyId, clientToken);
1291
+ return response.data;
1292
+ },
1293
+ enabled: enabled && !!companyId && !!clientToken
1294
+ });
1295
+ }
1296
+ function useBookingLabService(companyId, serviceId, clientToken, enabled = true) {
1297
+ const client = useBookingLabClient();
1298
+ return reactQuery.useQuery({
1299
+ queryKey: ["bookingLabService", companyId, serviceId],
1300
+ queryFn: async () => {
1301
+ const response = await client.getCompanyService(companyId, serviceId, clientToken);
1302
+ return response.data;
1303
+ },
1304
+ enabled: enabled && !!companyId && !!serviceId && !!clientToken
1305
+ });
1306
+ }
1307
+ function useBookingLabCompanies(clientToken, params, enabled = true) {
1308
+ const client = useBookingLabClient();
1309
+ return reactQuery.useQuery({
1310
+ queryKey: ["bookingLabCompanies", params?.service_id, params?.person_id],
1311
+ queryFn: async () => {
1312
+ const response = await client.getCompanies(clientToken, params);
1313
+ return response.data;
1314
+ },
1315
+ enabled: enabled && !!clientToken
1316
+ });
1317
+ }
1318
+ function useBookingLabQuestions(companyId, detailGroupId, clientToken, enabled = true) {
1319
+ const client = useBookingLabClient();
1320
+ return reactQuery.useQuery({
1321
+ queryKey: ["bookingLabQuestions", companyId, detailGroupId],
1322
+ queryFn: async () => {
1323
+ const response = await client.getCompanyQuestions(companyId, detailGroupId, clientToken);
1324
+ return response.data;
1325
+ },
1326
+ enabled: enabled && !!companyId && !!detailGroupId && !!clientToken
1327
+ });
1328
+ }
1329
+ function useBookingLabDays(companyId, serviceId, fromDate, toDate, clientToken, params, enabled = true) {
1330
+ const client = useBookingLabClient();
1331
+ return reactQuery.useQuery({
1332
+ queryKey: ["bookingLabDays", companyId, serviceId, fromDate, toDate, params?.resource_id],
1333
+ queryFn: async () => {
1334
+ const response = await client.getDays(companyId, serviceId, fromDate, toDate, clientToken, params);
1335
+ return response.data;
1336
+ },
1337
+ enabled: enabled && !!companyId && !!serviceId && !!fromDate && !!toDate && !!clientToken
1338
+ });
1339
+ }
1340
+ function useBookingLabTimes(companyId, serviceId, fromDate, toDate, clientToken, params, enabled = true) {
1341
+ const client = useBookingLabClient();
1342
+ return reactQuery.useQuery({
1343
+ queryKey: ["bookingLabTimes", companyId, serviceId, fromDate, toDate, params?.resource_ids],
1344
+ queryFn: async () => {
1345
+ const response = await client.getTimes(companyId, serviceId, fromDate, toDate, clientToken, params);
1346
+ return response.data;
1347
+ },
1348
+ enabled: enabled && !!companyId && !!serviceId && !!fromDate && !!toDate && !!clientToken
1349
+ });
1350
+ }
1351
+ function useBookingLabCreateBasket() {
1352
+ const client = useBookingLabClient();
1353
+ return reactQuery.useMutation({
1354
+ mutationFn: async (input) => {
1355
+ const response = await client.createBasket(input.request, input.headers);
1356
+ return response.data;
1357
+ }
1358
+ });
1359
+ }
1360
+ function useBookingLabAddBasketServiceItem() {
1361
+ const client = useBookingLabClient();
1362
+ return reactQuery.useMutation({
1363
+ mutationFn: async (input) => {
1364
+ const response = await client.addBasketServiceItem(input.basketId, input.request, input.headers);
1365
+ return response.data;
1366
+ }
1367
+ });
1368
+ }
1369
+ function useBookingLabCheckoutBasket() {
1370
+ const client = useBookingLabClient();
1371
+ return reactQuery.useMutation({
1372
+ mutationFn: async (input) => {
1373
+ const response = await client.checkoutBasketPublic(input.basketId, input.request, input.headers);
1374
+ return response.data;
1375
+ }
1376
+ });
1377
+ }
1378
+ function useBookingLabDeleteBasket() {
1379
+ const client = useBookingLabClient();
1380
+ return reactQuery.useMutation({
1381
+ mutationFn: async (input) => {
1382
+ const response = await client.deleteBasketPublic(input.headers);
1383
+ return response.data;
1384
+ }
1385
+ });
1386
+ }
1118
1387
 
1119
1388
  exports.ApiClient = ApiClient;
1120
1389
  exports.ApiClientContext = ApiClientContext;
@@ -1130,11 +1399,21 @@ exports.createBookingLabClient = createBookingLabClient;
1130
1399
  exports.createJrniClient = createJrniClient;
1131
1400
  exports.useAddServiceItem = useAddServiceItem;
1132
1401
  exports.useApiClientContext = useApiClientContext;
1402
+ exports.useBookingLabAddBasketServiceItem = useBookingLabAddBasketServiceItem;
1403
+ exports.useBookingLabCheckoutBasket = useBookingLabCheckoutBasket;
1133
1404
  exports.useBookingLabClient = useBookingLabClient;
1405
+ exports.useBookingLabCompanies = useBookingLabCompanies;
1134
1406
  exports.useBookingLabConfig = useBookingLabConfig;
1135
1407
  exports.useBookingLabContext = useBookingLabContext;
1408
+ exports.useBookingLabCreateBasket = useBookingLabCreateBasket;
1409
+ exports.useBookingLabDays = useBookingLabDays;
1410
+ exports.useBookingLabDeleteBasket = useBookingLabDeleteBasket;
1136
1411
  exports.useBookingLabForgotPassword = useBookingLabForgotPassword;
1137
1412
  exports.useBookingLabGetToken = useBookingLabGetToken;
1413
+ exports.useBookingLabQuestions = useBookingLabQuestions;
1414
+ exports.useBookingLabService = useBookingLabService;
1415
+ exports.useBookingLabServices = useBookingLabServices;
1416
+ exports.useBookingLabTimes = useBookingLabTimes;
1138
1417
  exports.useCancelBooking = useCancelBooking;
1139
1418
  exports.useCancelMemberBooking = useCancelMemberBooking;
1140
1419
  exports.useCheckoutBasket = useCheckoutBasket;