@explorins/pers-sdk 2.2.0-alpha.1 → 2.2.0-alpha.2
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/booking/api/booking-api.d.ts +71 -0
- package/dist/booking/api/booking-api.d.ts.map +1 -0
- package/dist/booking/index.d.ts +9 -0
- package/dist/booking/index.d.ts.map +1 -0
- package/dist/booking/services/booking-service.d.ts +79 -0
- package/dist/booking/services/booking-service.d.ts.map +1 -0
- package/dist/chunks/{pers-sdk-CBRtrG03.js → pers-sdk-C01Z2nmP.js} +468 -3
- package/dist/chunks/pers-sdk-C01Z2nmP.js.map +1 -0
- package/dist/chunks/{pers-sdk-DcNDMx1Y.cjs → pers-sdk-DQ6uC3h0.cjs} +470 -2
- package/dist/chunks/pers-sdk-DQ6uC3h0.cjs.map +1 -0
- package/dist/core/pers-api-client.d.ts.map +1 -1
- package/dist/core/pers-config.d.ts +30 -0
- package/dist/core/pers-config.d.ts.map +1 -1
- package/dist/core.cjs +2 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.js +1 -1
- package/dist/index.cjs +4 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/managers/booking-manager.d.ts +188 -0
- package/dist/managers/booking-manager.d.ts.map +1 -0
- package/dist/managers/index.d.ts +1 -0
- package/dist/managers/index.d.ts.map +1 -1
- package/dist/node.cjs +1 -1
- package/dist/node.js +1 -1
- package/dist/package.json +2 -2
- package/dist/pers-sdk.d.ts +38 -1
- package/dist/pers-sdk.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/chunks/pers-sdk-CBRtrG03.js.map +0 -1
- package/dist/chunks/pers-sdk-DcNDMx1Y.cjs.map +0 -1
|
@@ -1587,7 +1587,7 @@ class DefaultAuthProvider {
|
|
|
1587
1587
|
/** SDK package name */
|
|
1588
1588
|
const SDK_NAME = "@explorins/pers-sdk";
|
|
1589
1589
|
/** SDK version - injected from package.json at build time */
|
|
1590
|
-
const SDK_VERSION = "2.2.0-alpha.
|
|
1590
|
+
const SDK_VERSION = "2.2.0-alpha.2";
|
|
1591
1591
|
/** Full SDK identifier for headers */
|
|
1592
1592
|
const SDK_USER_AGENT = `${SDK_NAME}/${SDK_VERSION}`;
|
|
1593
1593
|
|
|
@@ -1923,6 +1923,24 @@ class PersApiClient {
|
|
|
1923
1923
|
else if (this.mergedConfig.apiProjectKey) {
|
|
1924
1924
|
headers['x-project-key'] = this.mergedConfig.apiProjectKey;
|
|
1925
1925
|
}
|
|
1926
|
+
// Add data source tracking headers
|
|
1927
|
+
const dataSource = this.mergedConfig.dataSource;
|
|
1928
|
+
if (dataSource) {
|
|
1929
|
+
headers['x-source-channel'] = dataSource.channel;
|
|
1930
|
+
if (dataSource.medium) {
|
|
1931
|
+
headers['x-source-medium'] = dataSource.medium;
|
|
1932
|
+
}
|
|
1933
|
+
if (dataSource.campaign) {
|
|
1934
|
+
headers['x-source-campaign'] = dataSource.campaign;
|
|
1935
|
+
}
|
|
1936
|
+
if (dataSource.source) {
|
|
1937
|
+
headers['x-source'] = dataSource.source;
|
|
1938
|
+
}
|
|
1939
|
+
// Note: referrer is typically set by browser, but can be overridden
|
|
1940
|
+
if (dataSource.referrer) {
|
|
1941
|
+
headers['Referer'] = dataSource.referrer;
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1926
1944
|
return headers;
|
|
1927
1945
|
}
|
|
1928
1946
|
// ==========================================
|
|
@@ -10531,6 +10549,412 @@ class CustomFieldDefinitionManager {
|
|
|
10531
10549
|
}
|
|
10532
10550
|
}
|
|
10533
10551
|
|
|
10552
|
+
/**
|
|
10553
|
+
* Low-level API for booking operations
|
|
10554
|
+
*
|
|
10555
|
+
* Provides direct HTTP calls to the booking endpoints.
|
|
10556
|
+
* For most use cases, prefer using BookingManager or BookingService.
|
|
10557
|
+
*
|
|
10558
|
+
* @internal
|
|
10559
|
+
*/
|
|
10560
|
+
class BookingApi {
|
|
10561
|
+
constructor(apiClient) {
|
|
10562
|
+
this.apiClient = apiClient;
|
|
10563
|
+
this.basePath = '/bookings';
|
|
10564
|
+
}
|
|
10565
|
+
/**
|
|
10566
|
+
* List all bookings with optional filters
|
|
10567
|
+
*
|
|
10568
|
+
* @param options - Filter options (userId, businessId, status)
|
|
10569
|
+
* @returns Promise resolving to array of bookings
|
|
10570
|
+
*/
|
|
10571
|
+
async getAll(options) {
|
|
10572
|
+
const params = new URLSearchParams();
|
|
10573
|
+
if (options?.userId) {
|
|
10574
|
+
params.append('userId', options.userId);
|
|
10575
|
+
}
|
|
10576
|
+
if (options?.businessId) {
|
|
10577
|
+
params.append('businessId', options.businessId);
|
|
10578
|
+
}
|
|
10579
|
+
if (options?.status) {
|
|
10580
|
+
params.append('status', options.status);
|
|
10581
|
+
}
|
|
10582
|
+
const queryString = params.toString();
|
|
10583
|
+
const url = queryString ? `${this.basePath}?${queryString}` : this.basePath;
|
|
10584
|
+
return this.apiClient.get(url);
|
|
10585
|
+
}
|
|
10586
|
+
/**
|
|
10587
|
+
* Get a single booking by ID
|
|
10588
|
+
*
|
|
10589
|
+
* @param id - Booking UUID
|
|
10590
|
+
* @returns Promise resolving to booking data
|
|
10591
|
+
*/
|
|
10592
|
+
async getById(id) {
|
|
10593
|
+
return this.apiClient.get(`${this.basePath}/${id}`);
|
|
10594
|
+
}
|
|
10595
|
+
/**
|
|
10596
|
+
* Create a new booking
|
|
10597
|
+
*
|
|
10598
|
+
* @param data - Booking creation data
|
|
10599
|
+
* @returns Promise resolving to created booking
|
|
10600
|
+
*/
|
|
10601
|
+
async create(data) {
|
|
10602
|
+
return this.apiClient.post(this.basePath, data);
|
|
10603
|
+
}
|
|
10604
|
+
/**
|
|
10605
|
+
* Update an existing booking
|
|
10606
|
+
*
|
|
10607
|
+
* @param id - Booking UUID
|
|
10608
|
+
* @param data - Booking update data
|
|
10609
|
+
* @returns Promise resolving to updated booking
|
|
10610
|
+
*/
|
|
10611
|
+
async update(id, data) {
|
|
10612
|
+
return this.apiClient.put(`${this.basePath}/${id}`, data);
|
|
10613
|
+
}
|
|
10614
|
+
/**
|
|
10615
|
+
* Delete a booking
|
|
10616
|
+
*
|
|
10617
|
+
* @param id - Booking UUID
|
|
10618
|
+
* @returns Promise resolving to success status
|
|
10619
|
+
*/
|
|
10620
|
+
async delete(id) {
|
|
10621
|
+
return this.apiClient.delete(`${this.basePath}/${id}`);
|
|
10622
|
+
}
|
|
10623
|
+
}
|
|
10624
|
+
|
|
10625
|
+
/**
|
|
10626
|
+
* Booking Service - Business logic layer for booking operations
|
|
10627
|
+
*
|
|
10628
|
+
* Provides booking management functionality with validation and
|
|
10629
|
+
* business rule enforcement.
|
|
10630
|
+
*
|
|
10631
|
+
* @internal
|
|
10632
|
+
*/
|
|
10633
|
+
class BookingService {
|
|
10634
|
+
constructor(bookingApi) {
|
|
10635
|
+
this.bookingApi = bookingApi;
|
|
10636
|
+
}
|
|
10637
|
+
/**
|
|
10638
|
+
* Get all bookings with optional filters
|
|
10639
|
+
*
|
|
10640
|
+
* @param options - Filter options
|
|
10641
|
+
* @returns Promise resolving to array of bookings
|
|
10642
|
+
*/
|
|
10643
|
+
async getAll(options) {
|
|
10644
|
+
return this.bookingApi.getAll(options);
|
|
10645
|
+
}
|
|
10646
|
+
/**
|
|
10647
|
+
* Get bookings for a specific user
|
|
10648
|
+
*
|
|
10649
|
+
* @param userId - User ID to filter by
|
|
10650
|
+
* @param status - Optional status filter
|
|
10651
|
+
* @returns Promise resolving to user's bookings
|
|
10652
|
+
*/
|
|
10653
|
+
async getByUser(userId, status) {
|
|
10654
|
+
return this.bookingApi.getAll({ userId, status });
|
|
10655
|
+
}
|
|
10656
|
+
/**
|
|
10657
|
+
* Get bookings for a specific business
|
|
10658
|
+
*
|
|
10659
|
+
* @param businessId - Business ID to filter by
|
|
10660
|
+
* @param status - Optional status filter
|
|
10661
|
+
* @returns Promise resolving to business's bookings
|
|
10662
|
+
*/
|
|
10663
|
+
async getByBusiness(businessId, status) {
|
|
10664
|
+
return this.bookingApi.getAll({ businessId, status });
|
|
10665
|
+
}
|
|
10666
|
+
/**
|
|
10667
|
+
* Get a single booking by ID
|
|
10668
|
+
*
|
|
10669
|
+
* @param id - Booking UUID
|
|
10670
|
+
* @returns Promise resolving to booking data
|
|
10671
|
+
*/
|
|
10672
|
+
async getById(id) {
|
|
10673
|
+
return this.bookingApi.getById(id);
|
|
10674
|
+
}
|
|
10675
|
+
/**
|
|
10676
|
+
* Create a new booking
|
|
10677
|
+
*
|
|
10678
|
+
* @param data - Booking creation data
|
|
10679
|
+
* @returns Promise resolving to created booking
|
|
10680
|
+
*/
|
|
10681
|
+
async create(data) {
|
|
10682
|
+
// Validate check-out is after check-in
|
|
10683
|
+
if (data.checkInDate && data.checkOutDate) {
|
|
10684
|
+
const checkIn = new Date(data.checkInDate);
|
|
10685
|
+
const checkOut = new Date(data.checkOutDate);
|
|
10686
|
+
if (checkOut <= checkIn) {
|
|
10687
|
+
throw new Error('Check-out date must be after check-in date');
|
|
10688
|
+
}
|
|
10689
|
+
}
|
|
10690
|
+
return this.bookingApi.create(data);
|
|
10691
|
+
}
|
|
10692
|
+
/**
|
|
10693
|
+
* Update an existing booking
|
|
10694
|
+
*
|
|
10695
|
+
* @param id - Booking UUID
|
|
10696
|
+
* @param data - Booking update data
|
|
10697
|
+
* @returns Promise resolving to updated booking
|
|
10698
|
+
*/
|
|
10699
|
+
async update(id, data) {
|
|
10700
|
+
// Validate dates if both provided
|
|
10701
|
+
if (data.checkInDate && data.checkOutDate) {
|
|
10702
|
+
const checkIn = new Date(data.checkInDate);
|
|
10703
|
+
const checkOut = new Date(data.checkOutDate);
|
|
10704
|
+
if (checkOut <= checkIn) {
|
|
10705
|
+
throw new Error('Check-out date must be after check-in date');
|
|
10706
|
+
}
|
|
10707
|
+
}
|
|
10708
|
+
return this.bookingApi.update(id, data);
|
|
10709
|
+
}
|
|
10710
|
+
/**
|
|
10711
|
+
* Delete a booking
|
|
10712
|
+
*
|
|
10713
|
+
* @param id - Booking UUID
|
|
10714
|
+
* @returns Promise resolving to success status
|
|
10715
|
+
*/
|
|
10716
|
+
async delete(id) {
|
|
10717
|
+
return this.bookingApi.delete(id);
|
|
10718
|
+
}
|
|
10719
|
+
/**
|
|
10720
|
+
* Check if a user has an active or future booking
|
|
10721
|
+
*
|
|
10722
|
+
* Useful for eligibility checks on redemptions.
|
|
10723
|
+
*
|
|
10724
|
+
* @param userId - User ID to check
|
|
10725
|
+
* @param options - Validation options (status filter, business filter)
|
|
10726
|
+
* @returns Promise resolving to true if user has valid booking
|
|
10727
|
+
*/
|
|
10728
|
+
async hasValidBooking(userId, options) {
|
|
10729
|
+
const queryOptions = {
|
|
10730
|
+
userId,
|
|
10731
|
+
businessId: options?.businessId
|
|
10732
|
+
};
|
|
10733
|
+
// If a specific status is requested, use it
|
|
10734
|
+
if (options?.status && options.status !== 'active_future') {
|
|
10735
|
+
queryOptions.status = options.status === 'any' ? undefined : options.status;
|
|
10736
|
+
const bookings = await this.bookingApi.getAll(queryOptions);
|
|
10737
|
+
return bookings.length > 0;
|
|
10738
|
+
}
|
|
10739
|
+
// Default: check active+future (active_future or undefined)
|
|
10740
|
+
const activeBookings = await this.bookingApi.getAll({ ...queryOptions, status: 'active' });
|
|
10741
|
+
if (activeBookings.length > 0)
|
|
10742
|
+
return true;
|
|
10743
|
+
const futureBookings = await this.bookingApi.getAll({ ...queryOptions, status: 'future' });
|
|
10744
|
+
return futureBookings.length > 0;
|
|
10745
|
+
}
|
|
10746
|
+
}
|
|
10747
|
+
|
|
10748
|
+
/**
|
|
10749
|
+
* Booking Manager - High-level interface for booking operations
|
|
10750
|
+
*
|
|
10751
|
+
* Provides a simplified API for managing bookings (hotel stays, reservations, etc.)
|
|
10752
|
+
* Used for tracking user stays and eligibility checks on redemptions.
|
|
10753
|
+
*
|
|
10754
|
+
* @group Managers
|
|
10755
|
+
* @category Booking Management
|
|
10756
|
+
*
|
|
10757
|
+
* @example List Bookings
|
|
10758
|
+
* ```typescript
|
|
10759
|
+
* // Get all bookings
|
|
10760
|
+
* const allBookings = await sdk.bookings.getAll();
|
|
10761
|
+
*
|
|
10762
|
+
* // Filter by user
|
|
10763
|
+
* const userBookings = await sdk.bookings.getAll({ userId: 'user-123' });
|
|
10764
|
+
*
|
|
10765
|
+
* // Filter by status
|
|
10766
|
+
* const activeBookings = await sdk.bookings.getAll({ status: 'active' });
|
|
10767
|
+
* ```
|
|
10768
|
+
*
|
|
10769
|
+
* @example Create Booking
|
|
10770
|
+
* ```typescript
|
|
10771
|
+
* const booking = await sdk.bookings.create({
|
|
10772
|
+
* userId: 'user-123',
|
|
10773
|
+
* locationName: 'Grand Hotel',
|
|
10774
|
+
* checkInDate: '2026-06-01',
|
|
10775
|
+
* checkOutDate: '2026-06-05',
|
|
10776
|
+
* guests: 2
|
|
10777
|
+
* });
|
|
10778
|
+
* ```
|
|
10779
|
+
*
|
|
10780
|
+
* @example Check Eligibility
|
|
10781
|
+
* ```typescript
|
|
10782
|
+
* // Check if user has valid (active or future) booking
|
|
10783
|
+
* const hasBooking = await sdk.bookings.hasValidBooking('user-123');
|
|
10784
|
+
* if (hasBooking) {
|
|
10785
|
+
* // User is eligible for booking-required redemption
|
|
10786
|
+
* }
|
|
10787
|
+
* ```
|
|
10788
|
+
*/
|
|
10789
|
+
class BookingManager {
|
|
10790
|
+
constructor(apiClient, events) {
|
|
10791
|
+
this.apiClient = apiClient;
|
|
10792
|
+
this.events = events;
|
|
10793
|
+
const bookingApi = new BookingApi(apiClient);
|
|
10794
|
+
this.bookingService = new BookingService(bookingApi);
|
|
10795
|
+
}
|
|
10796
|
+
/**
|
|
10797
|
+
* Get all bookings with optional filters
|
|
10798
|
+
*
|
|
10799
|
+
* @param options - Filter options (userId, businessId, status)
|
|
10800
|
+
* @returns Promise resolving to array of bookings
|
|
10801
|
+
*
|
|
10802
|
+
* @example Basic Usage
|
|
10803
|
+
* ```typescript
|
|
10804
|
+
* // All bookings
|
|
10805
|
+
* const bookings = await sdk.bookings.getAll();
|
|
10806
|
+
*
|
|
10807
|
+
* // Filter by user
|
|
10808
|
+
* const userBookings = await sdk.bookings.getAll({ userId: 'user-123' });
|
|
10809
|
+
*
|
|
10810
|
+
* // Filter by status
|
|
10811
|
+
* const activeBookings = await sdk.bookings.getAll({ status: 'active' });
|
|
10812
|
+
* const futureBookings = await sdk.bookings.getAll({ status: 'future' });
|
|
10813
|
+
* const pastBookings = await sdk.bookings.getAll({ status: 'past' });
|
|
10814
|
+
* ```
|
|
10815
|
+
*/
|
|
10816
|
+
async getAll(options) {
|
|
10817
|
+
return this.bookingService.getAll(options);
|
|
10818
|
+
}
|
|
10819
|
+
/**
|
|
10820
|
+
* Get bookings for a specific user
|
|
10821
|
+
*
|
|
10822
|
+
* Convenience method for filtering bookings by user ID.
|
|
10823
|
+
*
|
|
10824
|
+
* @param userId - User ID to filter by
|
|
10825
|
+
* @param status - Optional status filter
|
|
10826
|
+
* @returns Promise resolving to user's bookings
|
|
10827
|
+
*/
|
|
10828
|
+
async getByUser(userId, status) {
|
|
10829
|
+
return this.bookingService.getByUser(userId, status);
|
|
10830
|
+
}
|
|
10831
|
+
/**
|
|
10832
|
+
* Get bookings for a specific business
|
|
10833
|
+
*
|
|
10834
|
+
* Convenience method for filtering bookings by business ID.
|
|
10835
|
+
*
|
|
10836
|
+
* @param businessId - Business ID to filter by
|
|
10837
|
+
* @param status - Optional status filter
|
|
10838
|
+
* @returns Promise resolving to business's bookings
|
|
10839
|
+
*/
|
|
10840
|
+
async getByBusiness(businessId, status) {
|
|
10841
|
+
return this.bookingService.getByBusiness(businessId, status);
|
|
10842
|
+
}
|
|
10843
|
+
/**
|
|
10844
|
+
* Get a single booking by ID
|
|
10845
|
+
*
|
|
10846
|
+
* @param id - Booking UUID
|
|
10847
|
+
* @returns Promise resolving to booking data
|
|
10848
|
+
* @throws {PersApiError} When booking not found
|
|
10849
|
+
*/
|
|
10850
|
+
async getById(id) {
|
|
10851
|
+
return this.bookingService.getById(id);
|
|
10852
|
+
}
|
|
10853
|
+
/**
|
|
10854
|
+
* Create a new booking
|
|
10855
|
+
*
|
|
10856
|
+
* Creates a booking for a user at a specific location. Used for tracking
|
|
10857
|
+
* hotel stays, reservations, etc. for eligibility checks.
|
|
10858
|
+
*
|
|
10859
|
+
* @param data - Booking creation data
|
|
10860
|
+
* @returns Promise resolving to created booking
|
|
10861
|
+
* @throws {Error} When check-out date is not after check-in date
|
|
10862
|
+
*
|
|
10863
|
+
* @example Create Hotel Booking
|
|
10864
|
+
* ```typescript
|
|
10865
|
+
* const booking = await sdk.bookings.create({
|
|
10866
|
+
* userId: 'user-123',
|
|
10867
|
+
* locationName: 'Grand Hotel',
|
|
10868
|
+
* locationType: 'hotel',
|
|
10869
|
+
* checkInDate: '2026-06-01',
|
|
10870
|
+
* checkOutDate: '2026-06-05',
|
|
10871
|
+
* confirmationNumber: 'CONF123',
|
|
10872
|
+
* guests: 2,
|
|
10873
|
+
* notes: 'Ocean view room'
|
|
10874
|
+
* });
|
|
10875
|
+
* ```
|
|
10876
|
+
*/
|
|
10877
|
+
async create(data) {
|
|
10878
|
+
const result = await this.bookingService.create(data);
|
|
10879
|
+
// TODO: Add event emission when 'booking' domain is added to pers-shared
|
|
10880
|
+
// this.events?.emitSuccess({ domain: 'booking', type: 'booking_created', ... });
|
|
10881
|
+
return result;
|
|
10882
|
+
}
|
|
10883
|
+
/**
|
|
10884
|
+
* Update an existing booking
|
|
10885
|
+
*
|
|
10886
|
+
* @param id - Booking UUID
|
|
10887
|
+
* @param data - Booking update data (partial update supported)
|
|
10888
|
+
* @returns Promise resolving to updated booking
|
|
10889
|
+
* @throws {PersApiError} When booking not found
|
|
10890
|
+
* @throws {Error} When check-out date is not after check-in date
|
|
10891
|
+
*
|
|
10892
|
+
* @example Update Booking Dates
|
|
10893
|
+
* ```typescript
|
|
10894
|
+
* const updated = await sdk.bookings.update('booking-123', {
|
|
10895
|
+
* checkInDate: '2026-06-02',
|
|
10896
|
+
* checkOutDate: '2026-06-07'
|
|
10897
|
+
* });
|
|
10898
|
+
* ```
|
|
10899
|
+
*/
|
|
10900
|
+
async update(id, data) {
|
|
10901
|
+
const result = await this.bookingService.update(id, data);
|
|
10902
|
+
// TODO: Add event emission when 'booking' domain is added to pers-shared
|
|
10903
|
+
// this.events?.emitSuccess({ domain: 'booking', type: 'booking_updated', ... });
|
|
10904
|
+
return result;
|
|
10905
|
+
}
|
|
10906
|
+
/**
|
|
10907
|
+
* Delete a booking
|
|
10908
|
+
*
|
|
10909
|
+
* @param id - Booking UUID
|
|
10910
|
+
* @returns Promise resolving to success status
|
|
10911
|
+
* @throws {PersApiError} When booking not found
|
|
10912
|
+
*/
|
|
10913
|
+
async delete(id) {
|
|
10914
|
+
const result = await this.bookingService.delete(id);
|
|
10915
|
+
// TODO: Add event emission when 'booking' domain is added to pers-shared
|
|
10916
|
+
// this.events?.emitSuccess({ domain: 'booking', type: 'booking_deleted', ... });
|
|
10917
|
+
return result;
|
|
10918
|
+
}
|
|
10919
|
+
/**
|
|
10920
|
+
* Check if a user has a valid (active or future) booking
|
|
10921
|
+
*
|
|
10922
|
+
* Useful for eligibility checks on redemptions that require a valid booking.
|
|
10923
|
+
*
|
|
10924
|
+
* @param userId - User ID to check
|
|
10925
|
+
* @param options - Validation options (status filter, business filter)
|
|
10926
|
+
* @returns Promise resolving to true if user has valid booking
|
|
10927
|
+
*
|
|
10928
|
+
* @example Eligibility Check
|
|
10929
|
+
* ```typescript
|
|
10930
|
+
* const hasBooking = await sdk.bookings.hasValidBooking('user-123');
|
|
10931
|
+
*
|
|
10932
|
+
* if (!hasBooking) {
|
|
10933
|
+
* console.log('User must have an active or upcoming booking');
|
|
10934
|
+
* }
|
|
10935
|
+
*
|
|
10936
|
+
* // Check for active booking only
|
|
10937
|
+
* const hasActive = await sdk.bookings.hasValidBooking('user-123', { status: 'active' });
|
|
10938
|
+
*
|
|
10939
|
+
* // Check for booking at specific business
|
|
10940
|
+
* const hasHotelBooking = await sdk.bookings.hasValidBooking('user-123', {
|
|
10941
|
+
* businessId: 'hotel-123'
|
|
10942
|
+
* });
|
|
10943
|
+
* ```
|
|
10944
|
+
*/
|
|
10945
|
+
async hasValidBooking(userId, options) {
|
|
10946
|
+
return this.bookingService.hasValidBooking(userId, options);
|
|
10947
|
+
}
|
|
10948
|
+
/**
|
|
10949
|
+
* Get the booking service for advanced operations
|
|
10950
|
+
*
|
|
10951
|
+
* @returns BookingService instance with full API access
|
|
10952
|
+
*/
|
|
10953
|
+
getBookingService() {
|
|
10954
|
+
return this.bookingService;
|
|
10955
|
+
}
|
|
10956
|
+
}
|
|
10957
|
+
|
|
10534
10958
|
/**
|
|
10535
10959
|
* @fileoverview PERS SDK - Platform-agnostic TypeScript SDK with High-Level Managers
|
|
10536
10960
|
*
|
|
@@ -11250,6 +11674,47 @@ class PersSDK {
|
|
|
11250
11674
|
}
|
|
11251
11675
|
return this._customFields;
|
|
11252
11676
|
}
|
|
11677
|
+
/**
|
|
11678
|
+
* Booking manager - High-level booking operations
|
|
11679
|
+
*
|
|
11680
|
+
* Provides methods for managing user bookings (hotel stays, reservations, etc.)
|
|
11681
|
+
* Used for eligibility checks on redemptions that require valid bookings.
|
|
11682
|
+
*
|
|
11683
|
+
* @returns BookingManager instance
|
|
11684
|
+
*
|
|
11685
|
+
* @example List User Bookings
|
|
11686
|
+
* ```typescript
|
|
11687
|
+
* // Get all bookings for a user
|
|
11688
|
+
* const bookings = await sdk.bookings.getByUser('user-123');
|
|
11689
|
+
*
|
|
11690
|
+
* // Filter by status
|
|
11691
|
+
* const activeBookings = await sdk.bookings.getAll({ status: 'active' });
|
|
11692
|
+
* ```
|
|
11693
|
+
*
|
|
11694
|
+
* @example Create Booking
|
|
11695
|
+
* ```typescript
|
|
11696
|
+
* const booking = await sdk.bookings.create({
|
|
11697
|
+
* userId: 'user-123',
|
|
11698
|
+
* locationName: 'Grand Hotel',
|
|
11699
|
+
* checkInDate: '2026-06-01',
|
|
11700
|
+
* checkOutDate: '2026-06-05'
|
|
11701
|
+
* });
|
|
11702
|
+
* ```
|
|
11703
|
+
*
|
|
11704
|
+
* @example Eligibility Check
|
|
11705
|
+
* ```typescript
|
|
11706
|
+
* const hasBooking = await sdk.bookings.hasValidBooking('user-123');
|
|
11707
|
+
* if (hasBooking) {
|
|
11708
|
+
* // User is eligible for booking-required redemption
|
|
11709
|
+
* }
|
|
11710
|
+
* ```
|
|
11711
|
+
*/
|
|
11712
|
+
get bookings() {
|
|
11713
|
+
if (!this._bookings) {
|
|
11714
|
+
this._bookings = new BookingManager(this.apiClient, this._events);
|
|
11715
|
+
}
|
|
11716
|
+
return this._bookings;
|
|
11717
|
+
}
|
|
11253
11718
|
/**
|
|
11254
11719
|
* Wallet Events Manager - Real-time blockchain events for user's wallets
|
|
11255
11720
|
*
|
|
@@ -11364,6 +11829,9 @@ exports.AuthApi = AuthApi;
|
|
|
11364
11829
|
exports.AuthManager = AuthManager;
|
|
11365
11830
|
exports.AuthService = AuthService;
|
|
11366
11831
|
exports.AuthTokenManager = AuthTokenManager;
|
|
11832
|
+
exports.BookingApi = BookingApi;
|
|
11833
|
+
exports.BookingManager = BookingManager;
|
|
11834
|
+
exports.BookingService = BookingService;
|
|
11367
11835
|
exports.BusinessManager = BusinessManager;
|
|
11368
11836
|
exports.CampaignManager = CampaignManager;
|
|
11369
11837
|
exports.CustomFieldDefinitionManager = CustomFieldDefinitionManager;
|
|
@@ -11405,4 +11873,4 @@ exports.createPersEventsClient = createPersEventsClient;
|
|
|
11405
11873
|
exports.createPersSDK = createPersSDK;
|
|
11406
11874
|
exports.isFatalAuthErrorInMessage = isFatalAuthErrorInMessage;
|
|
11407
11875
|
exports.mergeWithDefaults = mergeWithDefaults;
|
|
11408
|
-
//# sourceMappingURL=pers-sdk-
|
|
11876
|
+
//# sourceMappingURL=pers-sdk-DQ6uC3h0.cjs.map
|