-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbooking.ts
More file actions
369 lines (336 loc) · 12.1 KB
/
Copy pathbooking.ts
File metadata and controls
369 lines (336 loc) · 12.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
/**
* The clean, transport-agnostic data model for Peek Pro bookings.
*
* This is the shape consumers of the package work with. It is intentionally
* decoupled from the underlying Peek GraphQL schema — the raw GraphQL types and
* the conversion logic live inside the package and are never exposed here. A
* booking is the central resource: it carries the customer, the activity and
* slot, the ticket lines, lifecycle flags, money totals, and (optionally) the
* guest list and full price breakdown.
*/
/** A ticket line within a booking (one resource option and its quantity). */
export interface Ticket {
/** Ticket (resource option) name, e.g. `"Adult"`. Falls back to `"Unknown"`. */
name: string;
/** How many of this ticket are on the booking. */
quantity: number;
/** The resource option id backing this ticket. Falls back to `"unknown"`. */
ticketId: string;
/**
* Per-unit list price of the ticket — only populated when
* `includePriceBreakdown` is requested.
*/
listPrice?: Price;
/**
* Total value for this ticket line — only populated when
* `includePriceBreakdown` is requested.
*/
totalValue?: Price;
}
/** A formatted monetary value: a human display string plus its raw amount. */
export interface Price {
/** Human-formatted amount (e.g. `"$25.00"`). */
display: string;
/** Numeric amount as a string (e.g. `"25.00"`). */
amount: string;
}
/**
* A resource pool used by a booking (e.g. a kayak or guide pool), with the
* quantity drawn from it.
*/
export interface Resource {
/** How many units of the resource the booking uses. */
quantity: number;
/** Resource pool name. */
name: string;
/** Resource pool short name. */
shortName: string;
}
/**
* A concrete resource assigned to a booking (a specific resource within a
* pool, as opposed to the pool-level {@link Resource} count).
*/
export interface ResourcePoolAssignment {
/** Assigned resource id. */
id: string;
/** Assigned resource name. */
name: string;
}
/**
* A custom question/answer captured on a booking or a guest. Location questions
* additionally carry a captured lat/long.
*/
export interface CustomQuestionAnswer {
/** The question text as shown to the customer. */
question: string;
/** The customer's answer. */
answer: string;
/** Captured latitude, present only for location questions. */
latitude?: string;
/** Captured longitude, present only for location questions. */
longitude?: string;
}
/** A custom field response captured against a {@link Guest}. */
export interface GuestMetadata {
/** Field response id. */
id: string;
/** The field's name. */
name: string;
/** The captured value (empty string when none). */
value: string;
}
/**
* A guest on a booking. Populated only when guests are requested
* (`includeGuests`); the primary guest is included and flagged via
* {@link Guest.isPrimary}.
*/
export interface Guest {
/** Unique guest id. */
id: string;
/** Guest name, or null. */
name: string | null;
/** Guest country, or null. */
country: string | null;
/** Date of birth, or null. */
dateOfBirth: Date | null;
/** Phone number, or null. */
phone: string | null;
/** Email address, or null. */
email: string | null;
/** Whether the guest is subject to GDPR handling. */
isGdpr: boolean;
/** Whether the guest is an actual participant (vs. a booker only). */
isParticipant: boolean;
/** Whether this is the booking's primary guest. */
isPrimary: boolean;
/** Whether the guest opted in to SMS. */
optinSms: boolean;
/** Whether the guest opted in to marketing. */
optinMarketing: boolean;
/** Postal code, or null. */
postalCode: string | null;
/** Custom field responses captured for this guest. */
metadata: GuestMetadata[];
}
/** A booking in Peek Pro. */
export interface Booking {
/** Stable unique booking id. */
bookingId: string;
/** Human-facing display id shown in the Peek UI (e.g. `"B-123456"`). */
displayId: string;
/**
* Normalized booking source, e.g. `"website"`, `"app"`, `"expedia"`.
* `"unknown"` when the origin can't be mapped.
*/
source: string;
/** Raw source app reported by Peek (e.g. `"WIDGET"`). `"unknown"` if absent. */
sourceApp: string;
/**
* Human-readable source description (e.g. `"Website Booking Flow"`).
* `"unknown"` when the origin can't be mapped.
*/
sourceDescription: string;
/**
* Raw source actor name reported by Peek, when present. `null` when the
* origin actor carries no name.
*/
sourceDetails: string | null;
/** Primary guest's name, or `""` when unknown. */
customerName: string | null;
/** Primary guest's email, or null. */
customerEmail: string | null;
/** Primary guest's phone, or null. */
customerPhone: string | null;
/** The activity (product) id this booking is for. `"unknown"` if absent. */
productId: string;
/** The activity (product) name. `"unknown"` if absent. */
productName: string;
/** Whether the booked product is a rental (vs. a standard activity). */
isRentalProduct: boolean;
/** The timeslot's legacy id, or null when the booking has no timeslot. */
timeslotId: string | null;
/** Total number of tickets across all ticket lines. */
totalTickets: number;
/** Human-readable ticket summary (e.g. `"2x Adult, 1x Child"`). */
ticketDescription: string;
/** The individual ticket lines on the booking. */
tickets: Ticket[];
/** Whether the booking has been canceled. */
isCanceled: boolean;
/** Whether the booking was marked a no-show. */
isNoShow: boolean;
/** Whether any guest on the booking has been checked in. */
isCheckedIn: boolean;
/** Whether the booking's rental has been returned. */
isReturned: boolean;
/** Purchase time in the account's local zone (ISO datetime), or null. */
purchasedAt: string | null;
/** Purchase time in UTC (ISO datetime), or null. */
purchasedAtUtc: string | null;
/** Activity start in the account's local zone (ISO datetime), or null. */
startsAt: string | null;
/** Activity start in UTC (ISO datetime), or null. */
startsAtUtc: string | null;
/** Activity end in the account's local zone (ISO datetime), or null. */
endsAt: string | null;
/** Activity end in UTC (ISO datetime), or null. */
endsAtUtc: string | null;
/** Activity duration in minutes (0 when start/end are unknown). */
durationMin: number;
/** The availability time id for the booked slot, or null. */
availabilityTimeId: string | null;
/** Customer booking-portal URL, or null. */
portalUrl: string | null;
/** Operator notes on the booking (`""` when none). */
notes: string;
/** Total booking value, human-formatted (e.g. `"$75.00"`). `""` if absent. */
valueDisplay: string;
/** Total booking value as a numeric string. `""` if absent. */
valueAmount: string;
/** Outstanding balance as a numeric string. `""` if absent. */
outstandingBalanceAmount: string;
/** Outstanding balance, human-formatted. `""` if absent. */
outstandingBalanceDisplay: string;
/** Redemption codes of promo codes applied to the order. */
promoCodes: string[];
/** Tips left on the booking. */
tips: Price[];
/**
* Convenience fee — only populated when `includePriceBreakdown` is requested.
*/
convenienceFee?: Price;
/** Deposit — only populated when `includePriceBreakdown` is requested. */
deposit?: Price;
/** Discount — only populated when `includePriceBreakdown` is requested. */
discount?: Price;
/**
* Price after discount — only populated when `includePriceBreakdown` is
* requested.
*/
discountedPrice?: Price;
/** Fees — only populated when `includePriceBreakdown` is requested. */
fees?: Price;
/**
* Flat partner fee — only populated when `includePriceBreakdown` is requested.
*/
flatPartnerFee?: Price;
/** Base price — only populated when `includePriceBreakdown` is requested. */
price?: Price;
/** Retail price — only populated when `includePriceBreakdown` is requested. */
retailPrice?: Price;
/** Taxes — only populated when `includePriceBreakdown` is requested. */
taxes?: Price;
/**
* Tips total in the breakdown — only populated when `includePriceBreakdown`
* is requested.
*/
tipsBreakdown?: Price;
/** Pool-level resource usage (quantity per resource pool). */
resources: Resource[];
/** Concrete resources assigned to the booking. */
resourcePoolAssignments: ResourcePoolAssignment[];
/** Reseller channel id, or null for a direct booking. */
resellerId: string | null;
/**
* Reseller display name (channel name, plus `" - <agent>"` when an agent is
* set), or null for a direct booking.
*/
resellerName: string | null;
/** The order id this booking belongs to. `""` if absent. */
orderId: string;
/**
* Deep link into the Peek Pro app for this booking, derived from the order id
* and booking id. `""` when either id is absent.
*/
peekProBookingDeepLink: string;
/** Custom question answers captured at the booking level. */
customQuestionAnswers: CustomQuestionAnswer[];
/** Custom question answers captured per guest/ticket. */
customGuestQuestionAnswers: CustomQuestionAnswer[];
/** Guests — only populated when `includeGuests` is requested. */
guests?: Guest[];
}
/** How to interpret the start/end range when searching bookings. */
export type BookingSearchBy = "purchaseDate" | "activityDate";
/** Options shared by booking reads. */
export interface BookingReadOptions {
/** Include guests in the result. */
includeGuests?: boolean;
/** Include the price breakdown fields. */
includePriceBreakdown?: boolean;
}
/** Parameters for searching bookings by a time range. */
export interface BookingTimeRangeSearch extends BookingReadOptions {
/** Range start (ISO datetime). */
start: string;
/** Range end (ISO datetime). */
end: string;
/** Whether the range matches purchase date or activity date. Default: purchaseDate. */
searchBy?: BookingSearchBy;
/** Restrict to a product/activity id. */
productId?: string;
/** Filter by primary guest email. */
email?: string;
/** Free-text search string. */
searchString?: string;
}
/** How an appended note should be applied. */
export type NoteMode = "append" | "overwrite";
/** A requested ticket (resource option) and quantity for a new booking. */
export interface CreateBookingTicket {
resourceOptionId: string;
quantity: number;
}
/** Guest details for a new booking. */
export interface CreateBookingGuest {
name: string;
email?: string;
phone?: string;
postalCode?: string;
country?: string;
optinMarketing?: boolean;
optinSms?: boolean;
}
/**
* Input for creating a booking. IDs must already be resolved — the package does
* not do free-text product/ticket/time matching (that stays in the caller).
*/
export interface CreateBookingInput {
/** Activity (product) id. */
activityId: string;
/** Availability time id for the slot. */
availabilityTimeId: string;
/** Tickets to book (each expanded to `quantity` seats). */
tickets: CreateBookingTicket[];
/** Primary guest. */
guest: CreateBookingGuest;
/** Operator notes to attach. */
operatorNotes?: string;
/** Suppress the customer confirmation email. Default: false. */
skipCustomerEmail?: boolean;
/** Clone the quote from an existing order. */
parentOrderId?: string | null;
/** Mark the booking paid after creation (requires `idempotencyKey`). */
markAsPaid?: boolean;
/** Partial payment amount when marking paid; defaults to the full balance. */
markAsPaidAmount?: string;
/** Idempotency key for the mark-paid charge. */
idempotencyKey?: string;
}
/** The result of creating a booking. */
export interface CreatedBooking {
/** The order id the new booking belongs to. */
orderId: string;
/** The new booking's id. */
bookingId: string;
/** The new booking's human-facing display id. */
displayId: string;
/** Remaining balance as a numeric string. */
balanceAmount: string;
/** 3-letter uppercase ISO currency code of the balance. */
balanceCurrency: string;
/** Balance, human-formatted (e.g. `"$75.00"`). */
balanceFormatted: string;
/** The charge transaction id — set only when the booking was marked paid. */
transactionId?: string;
}