@slotchain/sdk 1.2.4 → 1.3.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.cjs.js +36 -0
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.mts +40 -1
- package/dist/index.d.ts +40 -1
- package/dist/index.esm.js +36 -0
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/clients/booking-client.ts +51 -1
package/dist/index.cjs.js
CHANGED
|
@@ -306,6 +306,10 @@ var BookingClient = class {
|
|
|
306
306
|
/**
|
|
307
307
|
* Create a new booking (publishes booking.created event)
|
|
308
308
|
* POST /api/v1/bookings
|
|
309
|
+
*
|
|
310
|
+
* Provide either `slot_id` (explicit) or `tenant_id` (auto-resolve).
|
|
311
|
+
* When only `tenant_id` is given the API resolves the first active slot for that tenant,
|
|
312
|
+
* creating a default slot if none exists — so callers never need to manage slot IDs.
|
|
309
313
|
*/
|
|
310
314
|
async create(data) {
|
|
311
315
|
const response = await this.client.post(
|
|
@@ -314,6 +318,38 @@ var BookingClient = class {
|
|
|
314
318
|
);
|
|
315
319
|
return response.data;
|
|
316
320
|
}
|
|
321
|
+
/**
|
|
322
|
+
* Create a booking for a specific service item (job posting, class, product, etc.)
|
|
323
|
+
* without requiring the caller to supply or know a slot ID.
|
|
324
|
+
*
|
|
325
|
+
* The API resolves the correct slot for the tenant automatically, creating a
|
|
326
|
+
* default slot if none exists. This is the preferred method for application flows
|
|
327
|
+
* where slots are an internal infrastructure concern, not a user-facing concept.
|
|
328
|
+
*
|
|
329
|
+
* POST /api/v1/bookings (with tenant_id instead of slot_id)
|
|
330
|
+
*
|
|
331
|
+
* @example
|
|
332
|
+
* ```typescript
|
|
333
|
+
* const booking = await slotly.booking.createFromServiceItem({
|
|
334
|
+
* tenantId: 'tenant-123',
|
|
335
|
+
* serviceId: 'service-abc',
|
|
336
|
+
* serviceItemId: 'item-xyz',
|
|
337
|
+
* customerInfo: { name: 'Jane Smith', email: 'jane@example.com' },
|
|
338
|
+
* extraData: { kind: 'job_application', booking_moment: 'submitted' },
|
|
339
|
+
* });
|
|
340
|
+
* ```
|
|
341
|
+
*/
|
|
342
|
+
async createFromServiceItem(data) {
|
|
343
|
+
return this.create({
|
|
344
|
+
tenant_id: data.tenantId,
|
|
345
|
+
customer_info: data.customerInfo,
|
|
346
|
+
booking_data: {
|
|
347
|
+
service_id: data.serviceId,
|
|
348
|
+
service_item_id: data.serviceItemId,
|
|
349
|
+
...data.extraData
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
}
|
|
317
353
|
/**
|
|
318
354
|
* Update booking by ID
|
|
319
355
|
* PUT /api/v1/bookings/:id
|