@bookinglab/booking-journey-api 2.18.0 → 2.20.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 +26 -1
- package/dist/index.d.ts +26 -1
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -645,6 +645,44 @@ var BookingLabClient = class extends ApiClient {
|
|
|
645
645
|
throw error;
|
|
646
646
|
}
|
|
647
647
|
}
|
|
648
|
+
/**
|
|
649
|
+
* Check Ordinance Survey (OS Places) service status via POST (BookingLab).
|
|
650
|
+
* Sends the host to the absolute serviceStatus endpoint on api.bookinglab.co.uk.
|
|
651
|
+
* @param token - Value for the X-BL-TOKEN header
|
|
652
|
+
* @param request - Body containing the host to check
|
|
653
|
+
* @param production - When true, hits the production endpoint; otherwise the `-staging` variant
|
|
654
|
+
*/
|
|
655
|
+
async getOrdinanceSurveyStatus(token, request, production = false) {
|
|
656
|
+
const url = `https://api.bookinglab.co.uk/serviceStatus/osplaces${production ? "" : "-staging"}`;
|
|
657
|
+
const controller = new AbortController();
|
|
658
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
659
|
+
try {
|
|
660
|
+
const response = await fetch(url, {
|
|
661
|
+
method: "POST",
|
|
662
|
+
headers: {
|
|
663
|
+
"Content-Type": "application/json",
|
|
664
|
+
"X-BL-TOKEN": token
|
|
665
|
+
},
|
|
666
|
+
body: JSON.stringify(request),
|
|
667
|
+
signal: controller.signal
|
|
668
|
+
});
|
|
669
|
+
clearTimeout(timeoutId);
|
|
670
|
+
if (!response.ok) {
|
|
671
|
+
throw {
|
|
672
|
+
message: `HTTP ${response.status}: ${response.statusText}`,
|
|
673
|
+
status: response.status
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
const data = await response.json();
|
|
677
|
+
return { data, status: response.status, headers: response.headers };
|
|
678
|
+
} catch (error) {
|
|
679
|
+
clearTimeout(timeoutId);
|
|
680
|
+
if (error.name === "AbortError") {
|
|
681
|
+
throw { message: "Request timeout", code: "TIMEOUT" };
|
|
682
|
+
}
|
|
683
|
+
throw error;
|
|
684
|
+
}
|
|
685
|
+
}
|
|
648
686
|
};
|
|
649
687
|
function createBookingLabClient(baseUrl, authToken, appId) {
|
|
650
688
|
const client = new BookingLabClient({ baseUrl });
|
|
@@ -1550,7 +1588,19 @@ function useOsPlacesStatus(token, isStaging = false, enabled = true) {
|
|
|
1550
1588
|
enabled: enabled && !!token
|
|
1551
1589
|
});
|
|
1552
1590
|
}
|
|
1591
|
+
function useOrdinanceSurveyStatus(token, host, production = false, enabled = true) {
|
|
1592
|
+
const client = useBookingLabClient();
|
|
1593
|
+
return useQuery({
|
|
1594
|
+
queryKey: ["ordinanceSurveyStatus", host, production],
|
|
1595
|
+
queryFn: async () => {
|
|
1596
|
+
const request = { host };
|
|
1597
|
+
const response = await client.getOrdinanceSurveyStatus(token, request, production);
|
|
1598
|
+
return response.data;
|
|
1599
|
+
},
|
|
1600
|
+
enabled: enabled && !!token && !!host
|
|
1601
|
+
});
|
|
1602
|
+
}
|
|
1553
1603
|
|
|
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 };
|
|
1604
|
+
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, useOrdinanceSurveyStatus, useOrdnanceAddressLookup, useOsPlacesStatus, useQuestions, useRescheduleBooking, useResetPassword, useResources, useSendCustomEmail, useServices, useTimes, useUpdateBookinglabBooking, useUpdateClient, useUpdateMember };
|
|
1555
1605
|
//# sourceMappingURL=index.mjs.map
|
|
1556
1606
|
//# sourceMappingURL=index.mjs.map
|