@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
|
@@ -113,9 +113,14 @@ export class BookingClient {
|
|
|
113
113
|
/**
|
|
114
114
|
* Create a new booking (publishes booking.created event)
|
|
115
115
|
* POST /api/v1/bookings
|
|
116
|
+
*
|
|
117
|
+
* Provide either `slot_id` (explicit) or `tenant_id` (auto-resolve).
|
|
118
|
+
* When only `tenant_id` is given the API resolves the first active slot for that tenant,
|
|
119
|
+
* creating a default slot if none exists — so callers never need to manage slot IDs.
|
|
116
120
|
*/
|
|
117
121
|
async create(data: {
|
|
118
|
-
slot_id
|
|
122
|
+
slot_id?: string;
|
|
123
|
+
tenant_id?: string;
|
|
119
124
|
customer_info: {
|
|
120
125
|
name: string;
|
|
121
126
|
email: string;
|
|
@@ -135,6 +140,51 @@ export class BookingClient {
|
|
|
135
140
|
return response.data;
|
|
136
141
|
}
|
|
137
142
|
|
|
143
|
+
/**
|
|
144
|
+
* Create a booking for a specific service item (job posting, class, product, etc.)
|
|
145
|
+
* without requiring the caller to supply or know a slot ID.
|
|
146
|
+
*
|
|
147
|
+
* The API resolves the correct slot for the tenant automatically, creating a
|
|
148
|
+
* default slot if none exists. This is the preferred method for application flows
|
|
149
|
+
* where slots are an internal infrastructure concern, not a user-facing concept.
|
|
150
|
+
*
|
|
151
|
+
* POST /api/v1/bookings (with tenant_id instead of slot_id)
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```typescript
|
|
155
|
+
* const booking = await slotly.booking.createFromServiceItem({
|
|
156
|
+
* tenantId: 'tenant-123',
|
|
157
|
+
* serviceId: 'service-abc',
|
|
158
|
+
* serviceItemId: 'item-xyz',
|
|
159
|
+
* customerInfo: { name: 'Jane Smith', email: 'jane@example.com' },
|
|
160
|
+
* extraData: { kind: 'job_application', booking_moment: 'submitted' },
|
|
161
|
+
* });
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
async createFromServiceItem(data: {
|
|
165
|
+
tenantId: string;
|
|
166
|
+
serviceId: string;
|
|
167
|
+
serviceItemId: string;
|
|
168
|
+
customerInfo: {
|
|
169
|
+
name: string;
|
|
170
|
+
email: string;
|
|
171
|
+
phone?: string;
|
|
172
|
+
isGuestCheckout?: boolean;
|
|
173
|
+
};
|
|
174
|
+
/** Additional fields merged into booking_data alongside service/item IDs */
|
|
175
|
+
extraData?: Record<string, unknown>;
|
|
176
|
+
}): Promise<ApiResponse<Booking>> {
|
|
177
|
+
return this.create({
|
|
178
|
+
tenant_id: data.tenantId,
|
|
179
|
+
customer_info: data.customerInfo,
|
|
180
|
+
booking_data: {
|
|
181
|
+
service_id: data.serviceId,
|
|
182
|
+
service_item_id: data.serviceItemId,
|
|
183
|
+
...data.extraData,
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
|
|
138
188
|
/**
|
|
139
189
|
* Update booking by ID
|
|
140
190
|
* PUT /api/v1/bookings/:id
|