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