@bookinglab/booking-journey-api 2.16.0 → 2.18.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.d.cts +102 -7
- package/dist/index.d.ts +102 -7
- package/dist/index.js +95 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +94 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -367,15 +367,16 @@ var BookingLabClient = class extends ApiClient {
|
|
|
367
367
|
* Get services for a company
|
|
368
368
|
* @param companyId - The company ID
|
|
369
369
|
* @param clientToken - Client token for authentication
|
|
370
|
+
* @param bypassCacheToken - Optional. When provided, sent as `X-Bypass-Cache` header
|
|
370
371
|
*/
|
|
371
|
-
async getCompanyServices(companyId, clientToken) {
|
|
372
|
+
async getCompanyServices(companyId, clientToken, bypassCacheToken) {
|
|
373
|
+
const headers = {
|
|
374
|
+
"clienttoken": clientToken
|
|
375
|
+
};
|
|
376
|
+
if (bypassCacheToken) headers["X-Bypass-Cache"] = bypassCacheToken;
|
|
372
377
|
return this.get(
|
|
373
378
|
`/company/${companyId}/services`,
|
|
374
|
-
{
|
|
375
|
-
headers: {
|
|
376
|
-
"clienttoken": clientToken
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
+
{ headers }
|
|
379
380
|
);
|
|
380
381
|
}
|
|
381
382
|
/**
|
|
@@ -567,18 +568,40 @@ var BookingLabClient = class extends ApiClient {
|
|
|
567
568
|
* List bookings for a company
|
|
568
569
|
* @param companyId - The company ID
|
|
569
570
|
* @param clientToken - Client token for authentication
|
|
570
|
-
* @param params - Optional query params (client_id, member_id)
|
|
571
|
+
* @param params - Optional query params (client_id, member_id, start_date, end_date)
|
|
572
|
+
* @param bypassCacheToken - Optional. When provided, sent as `X-Bypass-Cache` header
|
|
571
573
|
*/
|
|
572
|
-
async listBookinglabBookings(companyId, clientToken, params) {
|
|
574
|
+
async listBookinglabBookings(companyId, clientToken, params, bypassCacheToken) {
|
|
573
575
|
const queryParams = {};
|
|
574
576
|
if (params?.client_id !== void 0) queryParams.client_id = params.client_id;
|
|
575
577
|
if (params?.member_id !== void 0) queryParams.member_id = params.member_id;
|
|
576
578
|
if (params?.start_date !== void 0) queryParams.start_date = params.start_date;
|
|
577
579
|
if (params?.end_date !== void 0) queryParams.end_date = params.end_date;
|
|
580
|
+
const headers = {
|
|
581
|
+
"clienttoken": clientToken,
|
|
582
|
+
"x-company-id": String(companyId)
|
|
583
|
+
};
|
|
584
|
+
if (bypassCacheToken) headers["X-Bypass-Cache"] = bypassCacheToken;
|
|
578
585
|
return this.get(
|
|
579
586
|
`/company/${companyId}/bookings`,
|
|
580
587
|
{
|
|
581
588
|
params: Object.keys(queryParams).length ? queryParams : void 0,
|
|
589
|
+
headers
|
|
590
|
+
}
|
|
591
|
+
);
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Update a booking for a company
|
|
595
|
+
* @param companyId - The company ID
|
|
596
|
+
* @param bookingId - The booking ID
|
|
597
|
+
* @param request - Booking update body (all fields optional)
|
|
598
|
+
* @param clientToken - Client token for authentication
|
|
599
|
+
*/
|
|
600
|
+
async updateBookinglabBooking(companyId, bookingId, request, clientToken) {
|
|
601
|
+
return this.put(
|
|
602
|
+
`/company/${companyId}/booking/${bookingId}`,
|
|
603
|
+
request,
|
|
604
|
+
{
|
|
582
605
|
headers: {
|
|
583
606
|
"clienttoken": clientToken,
|
|
584
607
|
"x-company-id": String(companyId)
|
|
@@ -586,6 +609,42 @@ var BookingLabClient = class extends ApiClient {
|
|
|
586
609
|
}
|
|
587
610
|
);
|
|
588
611
|
}
|
|
612
|
+
/**
|
|
613
|
+
* Get OS Places service status (BookingLab).
|
|
614
|
+
* Calls the absolute serviceStatus endpoint on staging.bookinglab.co.uk.
|
|
615
|
+
* @param token - Value for the X-BL-TOKEN header
|
|
616
|
+
* @param isStaging - When true, hits the `osplaces-staging` variant
|
|
617
|
+
*/
|
|
618
|
+
async getOsPlacesStatus(token, isStaging = false) {
|
|
619
|
+
const url = `https://staging.bookinglab.co.uk/serviceStatus/osplaces${isStaging ? "-staging" : ""}`;
|
|
620
|
+
const controller = new AbortController();
|
|
621
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
622
|
+
try {
|
|
623
|
+
const response = await fetch(url, {
|
|
624
|
+
method: "GET",
|
|
625
|
+
headers: {
|
|
626
|
+
"Content-Type": "application/json",
|
|
627
|
+
"X-BL-TOKEN": token
|
|
628
|
+
},
|
|
629
|
+
signal: controller.signal
|
|
630
|
+
});
|
|
631
|
+
clearTimeout(timeoutId);
|
|
632
|
+
if (!response.ok) {
|
|
633
|
+
throw {
|
|
634
|
+
message: `HTTP ${response.status}: ${response.statusText}`,
|
|
635
|
+
status: response.status
|
|
636
|
+
};
|
|
637
|
+
}
|
|
638
|
+
const data = await response.json();
|
|
639
|
+
return { data, status: response.status, headers: response.headers };
|
|
640
|
+
} catch (error) {
|
|
641
|
+
clearTimeout(timeoutId);
|
|
642
|
+
if (error.name === "AbortError") {
|
|
643
|
+
throw { message: "Request timeout", code: "TIMEOUT" };
|
|
644
|
+
}
|
|
645
|
+
throw error;
|
|
646
|
+
}
|
|
647
|
+
}
|
|
589
648
|
};
|
|
590
649
|
function createBookingLabClient(baseUrl, authToken, appId) {
|
|
591
650
|
const client = new BookingLabClient({ baseUrl });
|
|
@@ -1336,12 +1395,12 @@ function useBookingLabGetToken(request, clientToken, enabled = true) {
|
|
|
1336
1395
|
enabled: enabled && !!request.client && !!request.company && !!clientToken
|
|
1337
1396
|
});
|
|
1338
1397
|
}
|
|
1339
|
-
function useBookingLabServices(companyId, clientToken, enabled = true) {
|
|
1398
|
+
function useBookingLabServices(companyId, clientToken, enabled = true, bypassCacheToken) {
|
|
1340
1399
|
const client = useBookingLabClient();
|
|
1341
1400
|
return useQuery({
|
|
1342
|
-
queryKey: ["bookingLabServices", companyId],
|
|
1401
|
+
queryKey: ["bookingLabServices", companyId, bypassCacheToken],
|
|
1343
1402
|
queryFn: async () => {
|
|
1344
|
-
const response = await client.getCompanyServices(companyId, clientToken);
|
|
1403
|
+
const response = await client.getCompanyServices(companyId, clientToken, bypassCacheToken);
|
|
1345
1404
|
return response.data;
|
|
1346
1405
|
},
|
|
1347
1406
|
enabled: enabled && !!companyId && !!clientToken
|
|
@@ -1449,12 +1508,12 @@ function useOrdnanceAddressLookup(postcode, clientToken, enabled = true) {
|
|
|
1449
1508
|
enabled: enabled && !!postcode && !!clientToken
|
|
1450
1509
|
});
|
|
1451
1510
|
}
|
|
1452
|
-
function useListBookinglabBookings(companyId, clientToken, params, enabled = true) {
|
|
1511
|
+
function useListBookinglabBookings(companyId, clientToken, params, enabled = true, bypassCacheToken) {
|
|
1453
1512
|
const client = useBookingLabClient();
|
|
1454
1513
|
return useQuery({
|
|
1455
|
-
queryKey: ["bookingLabListBookings", companyId, params?.client_id, params?.member_id, params?.start_date, params?.end_date],
|
|
1514
|
+
queryKey: ["bookingLabListBookings", companyId, params?.client_id, params?.member_id, params?.start_date, params?.end_date, bypassCacheToken],
|
|
1456
1515
|
queryFn: async () => {
|
|
1457
|
-
const response = await client.listBookinglabBookings(companyId, clientToken, params);
|
|
1516
|
+
const response = await client.listBookinglabBookings(companyId, clientToken, params, bypassCacheToken);
|
|
1458
1517
|
return response.data;
|
|
1459
1518
|
},
|
|
1460
1519
|
enabled: enabled && !!companyId && !!clientToken
|
|
@@ -1471,7 +1530,27 @@ function useGetPurchase(companyId, serviceId, purchaseId, clientToken, enabled =
|
|
|
1471
1530
|
enabled: enabled && !!companyId && !!serviceId && !!purchaseId && !!clientToken
|
|
1472
1531
|
});
|
|
1473
1532
|
}
|
|
1533
|
+
function useUpdateBookinglabBooking(companyId, bookingId, clientToken) {
|
|
1534
|
+
const client = useBookingLabClient();
|
|
1535
|
+
return useMutation({
|
|
1536
|
+
mutationFn: async (request) => {
|
|
1537
|
+
const response = await client.updateBookinglabBooking(companyId, bookingId, request, clientToken);
|
|
1538
|
+
return response.data;
|
|
1539
|
+
}
|
|
1540
|
+
});
|
|
1541
|
+
}
|
|
1542
|
+
function useOsPlacesStatus(token, isStaging = false, enabled = true) {
|
|
1543
|
+
const client = useBookingLabClient();
|
|
1544
|
+
return useQuery({
|
|
1545
|
+
queryKey: ["osPlacesStatus", isStaging],
|
|
1546
|
+
queryFn: async () => {
|
|
1547
|
+
const response = await client.getOsPlacesStatus(token, isStaging);
|
|
1548
|
+
return response.data;
|
|
1549
|
+
},
|
|
1550
|
+
enabled: enabled && !!token
|
|
1551
|
+
});
|
|
1552
|
+
}
|
|
1474
1553
|
|
|
1475
|
-
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, useGetPurchase, useJrniClient, useJrniContext, useListBookinglabBookings, useListBookings, useLogin, useOrdnanceAddressLookup, useQuestions, useRescheduleBooking, useResetPassword, useResources, useSendCustomEmail, useServices, useTimes, useUpdateClient, useUpdateMember };
|
|
1554
|
+
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, useGetPurchase, useJrniClient, useJrniContext, useListBookinglabBookings, useListBookings, useLogin, useOrdnanceAddressLookup, useOsPlacesStatus, useQuestions, useRescheduleBooking, useResetPassword, useResources, useSendCustomEmail, useServices, useTimes, useUpdateBookinglabBooking, useUpdateClient, useUpdateMember };
|
|
1476
1555
|
//# sourceMappingURL=index.mjs.map
|
|
1477
1556
|
//# sourceMappingURL=index.mjs.map
|