@atzentis/booking-sdk 0.1.1 → 0.1.3
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 +213 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +315 -20
- package/dist/index.d.ts +315 -20
- package/dist/index.js +209 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -94,6 +94,314 @@ declare class HttpClient {
|
|
|
94
94
|
private buildHeaders;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
/** The standard paginated response shape returned by all v4.0 list endpoints */
|
|
98
|
+
interface Paginated<T> {
|
|
99
|
+
/** The items for this page */
|
|
100
|
+
data: T[];
|
|
101
|
+
/** Opaque cursor for the next page; null when on the last page */
|
|
102
|
+
cursor: string | null;
|
|
103
|
+
/** True if more pages exist beyond this one */
|
|
104
|
+
hasMore: boolean;
|
|
105
|
+
}
|
|
106
|
+
/** Options for configuring pagination behavior */
|
|
107
|
+
interface PaginationOptions {
|
|
108
|
+
/** Number of items per page (defaults to API default if omitted) */
|
|
109
|
+
limit?: number;
|
|
110
|
+
/** Initial cursor — omit to start from the first page */
|
|
111
|
+
cursor?: string;
|
|
112
|
+
}
|
|
113
|
+
/** Callback type: a function that fetches one page given current cursor options */
|
|
114
|
+
type PageFetcher<T> = (options: PaginationOptions) => Promise<Paginated<T>>;
|
|
115
|
+
|
|
116
|
+
/** All supported property types in the v4.0 API */
|
|
117
|
+
type PropertyType = "hotel" | "resort" | "villa" | "apartment" | "hostel" | "bnb" | "restaurant" | "cafe" | "bar" | "beach" | "spa" | "salon" | "custom";
|
|
118
|
+
/** Property lifecycle status */
|
|
119
|
+
type PropertyStatus = "active" | "inactive" | "setup" | "suspended";
|
|
120
|
+
/** Geographic coordinates */
|
|
121
|
+
interface Coordinates {
|
|
122
|
+
lat: number;
|
|
123
|
+
lng: number;
|
|
124
|
+
}
|
|
125
|
+
/** Physical address of a property */
|
|
126
|
+
interface PropertyAddress {
|
|
127
|
+
street: string;
|
|
128
|
+
city: string;
|
|
129
|
+
country: string;
|
|
130
|
+
state?: string;
|
|
131
|
+
postalCode?: string;
|
|
132
|
+
coordinates?: Coordinates;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Feature modules that can be enabled per property.
|
|
136
|
+
*
|
|
137
|
+
* Each flag controls access to a v4.0 API service group:
|
|
138
|
+
* - `booking` — Reservation and availability management
|
|
139
|
+
* - `concierge` — Guest request and service management
|
|
140
|
+
* - `intelligence` — Analytics and reporting
|
|
141
|
+
* - `revenue` — Dynamic pricing and yield management
|
|
142
|
+
* - `housekeeping` — Room cleaning and maintenance scheduling
|
|
143
|
+
* - `nightAudit` — End-of-day accounting reconciliation
|
|
144
|
+
* - `distribution` — Channel manager and OTA connectivity
|
|
145
|
+
* - `fiscal` — Tax compliance and fiscal reporting
|
|
146
|
+
* - `pos` — Point of sale bridge integration
|
|
147
|
+
*/
|
|
148
|
+
interface PropertyModules {
|
|
149
|
+
booking?: boolean;
|
|
150
|
+
concierge?: boolean;
|
|
151
|
+
intelligence?: boolean;
|
|
152
|
+
revenue?: boolean;
|
|
153
|
+
housekeeping?: boolean;
|
|
154
|
+
nightAudit?: boolean;
|
|
155
|
+
distribution?: boolean;
|
|
156
|
+
fiscal?: boolean;
|
|
157
|
+
pos?: boolean;
|
|
158
|
+
}
|
|
159
|
+
/** All 9 module names as a readonly tuple */
|
|
160
|
+
declare const PROPERTY_MODULES: readonly ["booking", "concierge", "intelligence", "revenue", "housekeeping", "nightAudit", "distribution", "fiscal", "pos"];
|
|
161
|
+
/** Default modules configuration with all modules disabled */
|
|
162
|
+
declare const DEFAULT_MODULES: PropertyModules;
|
|
163
|
+
/** A property in the Atzentis Booking system */
|
|
164
|
+
interface Property {
|
|
165
|
+
id: string;
|
|
166
|
+
name: string;
|
|
167
|
+
type: PropertyType;
|
|
168
|
+
status: PropertyStatus;
|
|
169
|
+
currency: string;
|
|
170
|
+
timezone: string;
|
|
171
|
+
address: PropertyAddress;
|
|
172
|
+
modules: PropertyModules;
|
|
173
|
+
createdAt: string;
|
|
174
|
+
updatedAt: string;
|
|
175
|
+
}
|
|
176
|
+
/** Input for creating a new property */
|
|
177
|
+
interface CreatePropertyInput {
|
|
178
|
+
name: string;
|
|
179
|
+
type: PropertyType;
|
|
180
|
+
currency: string;
|
|
181
|
+
timezone: string;
|
|
182
|
+
address: PropertyAddress;
|
|
183
|
+
modules?: PropertyModules;
|
|
184
|
+
}
|
|
185
|
+
/** Input for updating an existing property — all fields optional */
|
|
186
|
+
type UpdatePropertyInput = Partial<CreatePropertyInput>;
|
|
187
|
+
/** Query parameters for listing properties */
|
|
188
|
+
interface ListPropertiesParams {
|
|
189
|
+
type?: PropertyType;
|
|
190
|
+
status?: PropertyStatus;
|
|
191
|
+
cursor?: string;
|
|
192
|
+
limit?: number;
|
|
193
|
+
}
|
|
194
|
+
/** A space category (room type) belonging to a property */
|
|
195
|
+
interface SpaceCategory {
|
|
196
|
+
id: string;
|
|
197
|
+
propertyId: string;
|
|
198
|
+
name: string;
|
|
199
|
+
code: string;
|
|
200
|
+
maxOccupancy: number;
|
|
201
|
+
/** Base price in integer cents */
|
|
202
|
+
basePrice: number;
|
|
203
|
+
description?: string;
|
|
204
|
+
sortOrder?: number;
|
|
205
|
+
createdAt: string;
|
|
206
|
+
updatedAt: string;
|
|
207
|
+
}
|
|
208
|
+
/** Input for creating a new space category */
|
|
209
|
+
interface CreateCategoryInput {
|
|
210
|
+
propertyId: string;
|
|
211
|
+
name: string;
|
|
212
|
+
code: string;
|
|
213
|
+
maxOccupancy: number;
|
|
214
|
+
/** Base price in integer cents */
|
|
215
|
+
basePrice: number;
|
|
216
|
+
description?: string;
|
|
217
|
+
sortOrder?: number;
|
|
218
|
+
}
|
|
219
|
+
/** Input for updating a space category — cannot change propertyId */
|
|
220
|
+
type UpdateCategoryInput = Partial<Omit<CreateCategoryInput, "propertyId">>;
|
|
221
|
+
/** Query parameters for listing categories — propertyId is required */
|
|
222
|
+
interface ListCategoriesParams {
|
|
223
|
+
propertyId: string;
|
|
224
|
+
cursor?: string;
|
|
225
|
+
limit?: number;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Abstract base class for all SDK services.
|
|
230
|
+
* Provides typed HTTP helper methods and path construction.
|
|
231
|
+
* Not exported from the public API.
|
|
232
|
+
*/
|
|
233
|
+
declare abstract class BaseService {
|
|
234
|
+
protected readonly http: HttpClient;
|
|
235
|
+
protected abstract readonly basePath: string;
|
|
236
|
+
constructor(http: HttpClient);
|
|
237
|
+
/** Build a full path from the base path and additional segments */
|
|
238
|
+
protected _buildPath(...segments: string[]): string;
|
|
239
|
+
/** GET request returning typed response */
|
|
240
|
+
protected _get<T>(path: string, query?: Record<string, string | number | boolean | null | undefined>): Promise<T>;
|
|
241
|
+
/** POST request with body, returning typed response */
|
|
242
|
+
protected _post<T>(path: string, body: unknown): Promise<T>;
|
|
243
|
+
/** PATCH request with body, returning typed response */
|
|
244
|
+
protected _patch<T>(path: string, body: unknown): Promise<T>;
|
|
245
|
+
/** DELETE request, returning void */
|
|
246
|
+
protected _delete(path: string): Promise<void>;
|
|
247
|
+
/** GET list request with optional query params, returning paginated response */
|
|
248
|
+
protected _list<T>(params?: any): Promise<Paginated<T>>;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Service for managing space categories (room types) in the Atzentis Booking API.
|
|
253
|
+
*
|
|
254
|
+
* Categories are property-scoped — `propertyId` is required for create and list operations.
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* ```typescript
|
|
258
|
+
* const booking = new BookingClient({ apiKey: "atz_io_live_xxxxx" });
|
|
259
|
+
*
|
|
260
|
+
* // List categories for a property
|
|
261
|
+
* const { data } = await booking.categories.list({ propertyId: "prop_abc123" });
|
|
262
|
+
*
|
|
263
|
+
* // Create a new category
|
|
264
|
+
* const category = await booking.categories.create({
|
|
265
|
+
* propertyId: "prop_abc123",
|
|
266
|
+
* name: "Deluxe Suite",
|
|
267
|
+
* code: "DLX",
|
|
268
|
+
* maxOccupancy: 3,
|
|
269
|
+
* basePrice: 25000, // €250.00 in cents
|
|
270
|
+
* });
|
|
271
|
+
* ```
|
|
272
|
+
*/
|
|
273
|
+
declare class CategoriesService extends BaseService {
|
|
274
|
+
protected readonly basePath = "/inventory/v1/categories";
|
|
275
|
+
/**
|
|
276
|
+
* Create a new space category.
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* ```typescript
|
|
280
|
+
* const category = await booking.categories.create({
|
|
281
|
+
* propertyId: "prop_abc123",
|
|
282
|
+
* name: "Standard Room",
|
|
283
|
+
* code: "STD",
|
|
284
|
+
* maxOccupancy: 2,
|
|
285
|
+
* basePrice: 12000, // €120.00 in cents
|
|
286
|
+
* });
|
|
287
|
+
* ```
|
|
288
|
+
*/
|
|
289
|
+
create(input: CreateCategoryInput): Promise<SpaceCategory>;
|
|
290
|
+
/**
|
|
291
|
+
* List categories for a property with cursor-based pagination.
|
|
292
|
+
*
|
|
293
|
+
* @param params - Must include `propertyId`
|
|
294
|
+
*
|
|
295
|
+
* @example
|
|
296
|
+
* ```typescript
|
|
297
|
+
* const page = await booking.categories.list({
|
|
298
|
+
* propertyId: "prop_abc123",
|
|
299
|
+
* limit: 50,
|
|
300
|
+
* });
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
303
|
+
list(params: ListCategoriesParams): Promise<Paginated<SpaceCategory>>;
|
|
304
|
+
/**
|
|
305
|
+
* Update an existing space category.
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* ```typescript
|
|
309
|
+
* const updated = await booking.categories.update("cat_xyz789", {
|
|
310
|
+
* basePrice: 15000, // Updated to €150.00
|
|
311
|
+
* });
|
|
312
|
+
* ```
|
|
313
|
+
*/
|
|
314
|
+
update(categoryId: string, input: UpdateCategoryInput): Promise<SpaceCategory>;
|
|
315
|
+
/**
|
|
316
|
+
* Delete a space category.
|
|
317
|
+
*
|
|
318
|
+
* @example
|
|
319
|
+
* ```typescript
|
|
320
|
+
* await booking.categories.delete("cat_xyz789");
|
|
321
|
+
* ```
|
|
322
|
+
*/
|
|
323
|
+
delete(categoryId: string): Promise<void>;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Service for managing properties in the Atzentis Booking API.
|
|
328
|
+
*
|
|
329
|
+
* @example
|
|
330
|
+
* ```typescript
|
|
331
|
+
* const booking = new BookingClient({ apiKey: "atz_io_live_xxxxx" });
|
|
332
|
+
*
|
|
333
|
+
* // List all active properties
|
|
334
|
+
* const { data, hasMore } = await booking.properties.list({ status: "active" });
|
|
335
|
+
*
|
|
336
|
+
* // Create a new property
|
|
337
|
+
* const property = await booking.properties.create({
|
|
338
|
+
* name: "Seaside Villa",
|
|
339
|
+
* type: "villa",
|
|
340
|
+
* currency: "EUR",
|
|
341
|
+
* timezone: "Europe/Athens",
|
|
342
|
+
* address: { street: "123 Coast Rd", city: "Chania", country: "GR" },
|
|
343
|
+
* });
|
|
344
|
+
* ```
|
|
345
|
+
*/
|
|
346
|
+
declare class PropertiesService extends BaseService {
|
|
347
|
+
protected readonly basePath = "/inventory/v1/properties";
|
|
348
|
+
/**
|
|
349
|
+
* Create a new property.
|
|
350
|
+
*
|
|
351
|
+
* @example
|
|
352
|
+
* ```typescript
|
|
353
|
+
* const property = await booking.properties.create({
|
|
354
|
+
* name: "Hotel Athena",
|
|
355
|
+
* type: "hotel",
|
|
356
|
+
* currency: "EUR",
|
|
357
|
+
* timezone: "Europe/Athens",
|
|
358
|
+
* address: { street: "1 Plaka St", city: "Athens", country: "GR" },
|
|
359
|
+
* });
|
|
360
|
+
* ```
|
|
361
|
+
*/
|
|
362
|
+
create(input: CreatePropertyInput): Promise<Property>;
|
|
363
|
+
/**
|
|
364
|
+
* List properties with optional filters and cursor-based pagination.
|
|
365
|
+
*
|
|
366
|
+
* @example
|
|
367
|
+
* ```typescript
|
|
368
|
+
* const page = await booking.properties.list({ type: "hotel", limit: 20 });
|
|
369
|
+
* console.log(page.data); // Property[]
|
|
370
|
+
* console.log(page.hasMore); // boolean
|
|
371
|
+
* ```
|
|
372
|
+
*/
|
|
373
|
+
list(params?: ListPropertiesParams): Promise<Paginated<Property>>;
|
|
374
|
+
/**
|
|
375
|
+
* Get a single property by ID.
|
|
376
|
+
*
|
|
377
|
+
* @example
|
|
378
|
+
* ```typescript
|
|
379
|
+
* const property = await booking.properties.get("prop_abc123");
|
|
380
|
+
* ```
|
|
381
|
+
*/
|
|
382
|
+
get(propertyId: string): Promise<Property>;
|
|
383
|
+
/**
|
|
384
|
+
* Update an existing property.
|
|
385
|
+
*
|
|
386
|
+
* @example
|
|
387
|
+
* ```typescript
|
|
388
|
+
* const updated = await booking.properties.update("prop_abc123", {
|
|
389
|
+
* name: "Hotel Athena Deluxe",
|
|
390
|
+
* });
|
|
391
|
+
* ```
|
|
392
|
+
*/
|
|
393
|
+
update(propertyId: string, input: UpdatePropertyInput): Promise<Property>;
|
|
394
|
+
/**
|
|
395
|
+
* Delete a property.
|
|
396
|
+
*
|
|
397
|
+
* @example
|
|
398
|
+
* ```typescript
|
|
399
|
+
* await booking.properties.delete("prop_abc123");
|
|
400
|
+
* ```
|
|
401
|
+
*/
|
|
402
|
+
delete(propertyId: string): Promise<void>;
|
|
403
|
+
}
|
|
404
|
+
|
|
97
405
|
/**
|
|
98
406
|
* Main SDK client for the Atzentis Booking API.
|
|
99
407
|
*
|
|
@@ -105,7 +413,13 @@ declare class HttpClient {
|
|
|
105
413
|
*/
|
|
106
414
|
declare class BookingClient {
|
|
107
415
|
readonly httpClient: HttpClient;
|
|
416
|
+
private _properties?;
|
|
417
|
+
private _categories?;
|
|
108
418
|
constructor(config: BookingClientConfig);
|
|
419
|
+
/** Properties service — lazy-initialized on first access */
|
|
420
|
+
get properties(): PropertiesService;
|
|
421
|
+
/** Categories service — lazy-initialized on first access */
|
|
422
|
+
get categories(): CategoriesService;
|
|
109
423
|
setApiKey(key: string): void;
|
|
110
424
|
setTenantId(id: string): void;
|
|
111
425
|
}
|
|
@@ -164,25 +478,6 @@ declare class TimeoutError extends BookingError {
|
|
|
164
478
|
/** Creates a typed BookingError from an HTTP response and parsed body */
|
|
165
479
|
declare function createErrorFromResponse(response: Response, body: unknown, retryAfterHeader?: string | null): BookingError;
|
|
166
480
|
|
|
167
|
-
/** The standard paginated response shape returned by all v4.0 list endpoints */
|
|
168
|
-
interface Paginated<T> {
|
|
169
|
-
/** The items for this page */
|
|
170
|
-
data: T[];
|
|
171
|
-
/** Opaque cursor for the next page; null when on the last page */
|
|
172
|
-
cursor: string | null;
|
|
173
|
-
/** True if more pages exist beyond this one */
|
|
174
|
-
hasMore: boolean;
|
|
175
|
-
}
|
|
176
|
-
/** Options for configuring pagination behavior */
|
|
177
|
-
interface PaginationOptions {
|
|
178
|
-
/** Number of items per page (defaults to API default if omitted) */
|
|
179
|
-
limit?: number;
|
|
180
|
-
/** Initial cursor — omit to start from the first page */
|
|
181
|
-
cursor?: string;
|
|
182
|
-
}
|
|
183
|
-
/** Callback type: a function that fetches one page given current cursor options */
|
|
184
|
-
type PageFetcher<T> = (options: PaginationOptions) => Promise<Paginated<T>>;
|
|
185
|
-
|
|
186
481
|
/**
|
|
187
482
|
* Returns an AsyncIterable that yields each page's data array in order.
|
|
188
483
|
* Iteration stops automatically when hasMore is false or cursor is null.
|
|
@@ -207,4 +502,4 @@ declare function firstPage<T>(fetcher: PageFetcher<T>, options?: PaginationOptio
|
|
|
207
502
|
|
|
208
503
|
declare const VERSION = "0.1.0";
|
|
209
504
|
|
|
210
|
-
export { AuthenticationError, BookingClient, type BookingClientConfig, BookingError, type BookingErrorOptions, ConflictError, ForbiddenError, HttpClient, type HttpClientOptions, type HttpMethod, type HttpResponse, type Logger, NotFoundError, type PageFetcher, type Paginated, type PaginationOptions, PaymentError, RateLimitError, type RequestOptions, type ResolvedBookingClientConfig, type RetryConfig, type RetryOptions, ServerError, TimeoutError, VERSION, ValidationError, bookingClientConfigSchema, createErrorFromResponse, firstPage, paginate };
|
|
505
|
+
export { AuthenticationError, BookingClient, type BookingClientConfig, BookingError, type BookingErrorOptions, CategoriesService, ConflictError, type Coordinates, type CreateCategoryInput, type CreatePropertyInput, DEFAULT_MODULES, ForbiddenError, HttpClient, type HttpClientOptions, type HttpMethod, type HttpResponse, type ListCategoriesParams, type ListPropertiesParams, type Logger, NotFoundError, PROPERTY_MODULES, type PageFetcher, type Paginated, type PaginationOptions, PaymentError, PropertiesService, type Property, type PropertyAddress, type PropertyModules, type PropertyStatus, type PropertyType, RateLimitError, type RequestOptions, type ResolvedBookingClientConfig, type RetryConfig, type RetryOptions, ServerError, type SpaceCategory, TimeoutError, type UpdateCategoryInput, type UpdatePropertyInput, VERSION, ValidationError, bookingClientConfigSchema, createErrorFromResponse, firstPage, paginate };
|
package/dist/index.js
CHANGED
|
@@ -442,6 +442,177 @@ _timeout = new WeakMap();
|
|
|
442
442
|
_debug = new WeakMap();
|
|
443
443
|
_logger = new WeakMap();
|
|
444
444
|
|
|
445
|
+
// src/services/base.ts
|
|
446
|
+
var BaseService = class {
|
|
447
|
+
constructor(http) {
|
|
448
|
+
this.http = http;
|
|
449
|
+
}
|
|
450
|
+
/** Build a full path from the base path and additional segments */
|
|
451
|
+
_buildPath(...segments) {
|
|
452
|
+
if (segments.length === 0) return this.basePath;
|
|
453
|
+
return `${this.basePath}/${segments.join("/")}`;
|
|
454
|
+
}
|
|
455
|
+
/** GET request returning typed response */
|
|
456
|
+
_get(path, query) {
|
|
457
|
+
return this.http.get(path, { query });
|
|
458
|
+
}
|
|
459
|
+
/** POST request with body, returning typed response */
|
|
460
|
+
_post(path, body) {
|
|
461
|
+
return this.http.post(path, { body });
|
|
462
|
+
}
|
|
463
|
+
/** PATCH request with body, returning typed response */
|
|
464
|
+
_patch(path, body) {
|
|
465
|
+
return this.http.patch(path, { body });
|
|
466
|
+
}
|
|
467
|
+
/** DELETE request, returning void */
|
|
468
|
+
_delete(path) {
|
|
469
|
+
return this.http.delete(path);
|
|
470
|
+
}
|
|
471
|
+
/** GET list request with optional query params, returning paginated response */
|
|
472
|
+
// biome-ignore lint/suspicious/noExplicitAny: params are typed at service level, cast needed for HttpClient
|
|
473
|
+
_list(params) {
|
|
474
|
+
return this.http.get(this.basePath, { query: params });
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
|
|
478
|
+
// src/services/categories.ts
|
|
479
|
+
var CategoriesService = class extends BaseService {
|
|
480
|
+
constructor() {
|
|
481
|
+
super(...arguments);
|
|
482
|
+
this.basePath = "/inventory/v1/categories";
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Create a new space category.
|
|
486
|
+
*
|
|
487
|
+
* @example
|
|
488
|
+
* ```typescript
|
|
489
|
+
* const category = await booking.categories.create({
|
|
490
|
+
* propertyId: "prop_abc123",
|
|
491
|
+
* name: "Standard Room",
|
|
492
|
+
* code: "STD",
|
|
493
|
+
* maxOccupancy: 2,
|
|
494
|
+
* basePrice: 12000, // €120.00 in cents
|
|
495
|
+
* });
|
|
496
|
+
* ```
|
|
497
|
+
*/
|
|
498
|
+
create(input) {
|
|
499
|
+
return this._post(this.basePath, input);
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* List categories for a property with cursor-based pagination.
|
|
503
|
+
*
|
|
504
|
+
* @param params - Must include `propertyId`
|
|
505
|
+
*
|
|
506
|
+
* @example
|
|
507
|
+
* ```typescript
|
|
508
|
+
* const page = await booking.categories.list({
|
|
509
|
+
* propertyId: "prop_abc123",
|
|
510
|
+
* limit: 50,
|
|
511
|
+
* });
|
|
512
|
+
* ```
|
|
513
|
+
*/
|
|
514
|
+
list(params) {
|
|
515
|
+
return this._list(params);
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Update an existing space category.
|
|
519
|
+
*
|
|
520
|
+
* @example
|
|
521
|
+
* ```typescript
|
|
522
|
+
* const updated = await booking.categories.update("cat_xyz789", {
|
|
523
|
+
* basePrice: 15000, // Updated to €150.00
|
|
524
|
+
* });
|
|
525
|
+
* ```
|
|
526
|
+
*/
|
|
527
|
+
update(categoryId, input) {
|
|
528
|
+
return this._patch(this._buildPath(categoryId), input);
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Delete a space category.
|
|
532
|
+
*
|
|
533
|
+
* @example
|
|
534
|
+
* ```typescript
|
|
535
|
+
* await booking.categories.delete("cat_xyz789");
|
|
536
|
+
* ```
|
|
537
|
+
*/
|
|
538
|
+
delete(categoryId) {
|
|
539
|
+
return this._delete(this._buildPath(categoryId));
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
|
|
543
|
+
// src/services/properties.ts
|
|
544
|
+
var PropertiesService = class extends BaseService {
|
|
545
|
+
constructor() {
|
|
546
|
+
super(...arguments);
|
|
547
|
+
this.basePath = "/inventory/v1/properties";
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Create a new property.
|
|
551
|
+
*
|
|
552
|
+
* @example
|
|
553
|
+
* ```typescript
|
|
554
|
+
* const property = await booking.properties.create({
|
|
555
|
+
* name: "Hotel Athena",
|
|
556
|
+
* type: "hotel",
|
|
557
|
+
* currency: "EUR",
|
|
558
|
+
* timezone: "Europe/Athens",
|
|
559
|
+
* address: { street: "1 Plaka St", city: "Athens", country: "GR" },
|
|
560
|
+
* });
|
|
561
|
+
* ```
|
|
562
|
+
*/
|
|
563
|
+
create(input) {
|
|
564
|
+
return this._post(this.basePath, input);
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* List properties with optional filters and cursor-based pagination.
|
|
568
|
+
*
|
|
569
|
+
* @example
|
|
570
|
+
* ```typescript
|
|
571
|
+
* const page = await booking.properties.list({ type: "hotel", limit: 20 });
|
|
572
|
+
* console.log(page.data); // Property[]
|
|
573
|
+
* console.log(page.hasMore); // boolean
|
|
574
|
+
* ```
|
|
575
|
+
*/
|
|
576
|
+
list(params) {
|
|
577
|
+
return this._list(params);
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* Get a single property by ID.
|
|
581
|
+
*
|
|
582
|
+
* @example
|
|
583
|
+
* ```typescript
|
|
584
|
+
* const property = await booking.properties.get("prop_abc123");
|
|
585
|
+
* ```
|
|
586
|
+
*/
|
|
587
|
+
get(propertyId) {
|
|
588
|
+
return this._get(this._buildPath(propertyId));
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* Update an existing property.
|
|
592
|
+
*
|
|
593
|
+
* @example
|
|
594
|
+
* ```typescript
|
|
595
|
+
* const updated = await booking.properties.update("prop_abc123", {
|
|
596
|
+
* name: "Hotel Athena Deluxe",
|
|
597
|
+
* });
|
|
598
|
+
* ```
|
|
599
|
+
*/
|
|
600
|
+
update(propertyId, input) {
|
|
601
|
+
return this._patch(this._buildPath(propertyId), input);
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* Delete a property.
|
|
605
|
+
*
|
|
606
|
+
* @example
|
|
607
|
+
* ```typescript
|
|
608
|
+
* await booking.properties.delete("prop_abc123");
|
|
609
|
+
* ```
|
|
610
|
+
*/
|
|
611
|
+
delete(propertyId) {
|
|
612
|
+
return this._delete(this._buildPath(propertyId));
|
|
613
|
+
}
|
|
614
|
+
};
|
|
615
|
+
|
|
445
616
|
// src/client.ts
|
|
446
617
|
var BookingClient = class {
|
|
447
618
|
constructor(config) {
|
|
@@ -459,6 +630,16 @@ var BookingClient = class {
|
|
|
459
630
|
logger: validated.logger
|
|
460
631
|
});
|
|
461
632
|
}
|
|
633
|
+
/** Properties service — lazy-initialized on first access */
|
|
634
|
+
get properties() {
|
|
635
|
+
this._properties ?? (this._properties = new PropertiesService(this.httpClient));
|
|
636
|
+
return this._properties;
|
|
637
|
+
}
|
|
638
|
+
/** Categories service — lazy-initialized on first access */
|
|
639
|
+
get categories() {
|
|
640
|
+
this._categories ?? (this._categories = new CategoriesService(this.httpClient));
|
|
641
|
+
return this._categories;
|
|
642
|
+
}
|
|
462
643
|
setApiKey(key) {
|
|
463
644
|
if (!key || key.trim().length === 0) {
|
|
464
645
|
throw new Error("apiKey must be a non-empty string");
|
|
@@ -498,17 +679,45 @@ async function firstPage(fetcher, options) {
|
|
|
498
679
|
return fetcher({ ...options ?? {} });
|
|
499
680
|
}
|
|
500
681
|
|
|
682
|
+
// src/types/properties.ts
|
|
683
|
+
var PROPERTY_MODULES = [
|
|
684
|
+
"booking",
|
|
685
|
+
"concierge",
|
|
686
|
+
"intelligence",
|
|
687
|
+
"revenue",
|
|
688
|
+
"housekeeping",
|
|
689
|
+
"nightAudit",
|
|
690
|
+
"distribution",
|
|
691
|
+
"fiscal",
|
|
692
|
+
"pos"
|
|
693
|
+
];
|
|
694
|
+
var DEFAULT_MODULES = {
|
|
695
|
+
booking: false,
|
|
696
|
+
concierge: false,
|
|
697
|
+
intelligence: false,
|
|
698
|
+
revenue: false,
|
|
699
|
+
housekeeping: false,
|
|
700
|
+
nightAudit: false,
|
|
701
|
+
distribution: false,
|
|
702
|
+
fiscal: false,
|
|
703
|
+
pos: false
|
|
704
|
+
};
|
|
705
|
+
|
|
501
706
|
// src/index.ts
|
|
502
707
|
var VERSION = "0.1.0";
|
|
503
708
|
export {
|
|
504
709
|
AuthenticationError,
|
|
505
710
|
BookingClient,
|
|
506
711
|
BookingError,
|
|
712
|
+
CategoriesService,
|
|
507
713
|
ConflictError,
|
|
714
|
+
DEFAULT_MODULES,
|
|
508
715
|
ForbiddenError,
|
|
509
716
|
HttpClient,
|
|
510
717
|
NotFoundError,
|
|
718
|
+
PROPERTY_MODULES,
|
|
511
719
|
PaymentError,
|
|
720
|
+
PropertiesService,
|
|
512
721
|
RateLimitError,
|
|
513
722
|
ServerError,
|
|
514
723
|
TimeoutError,
|