@atzentis/booking-sdk 0.1.6 → 0.1.8
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 +635 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1273 -1
- package/dist/index.d.ts +1273 -1
- package/dist/index.js +631 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -37,11 +37,15 @@ __export(index_exports, {
|
|
|
37
37
|
CategoriesService: () => CategoriesService,
|
|
38
38
|
ConflictError: () => ConflictError,
|
|
39
39
|
DEFAULT_MODULES: () => DEFAULT_MODULES,
|
|
40
|
+
DistributionService: () => DistributionService,
|
|
41
|
+
FinanceService: () => FinanceService,
|
|
40
42
|
ForbiddenError: () => ForbiddenError,
|
|
43
|
+
GuestsService: () => GuestsService,
|
|
41
44
|
HttpClient: () => HttpClient,
|
|
42
45
|
NotFoundError: () => NotFoundError,
|
|
43
46
|
PROPERTY_MODULES: () => PROPERTY_MODULES,
|
|
44
47
|
PaymentError: () => PaymentError,
|
|
48
|
+
PaymentsService: () => PaymentsService,
|
|
45
49
|
PropertiesService: () => PropertiesService,
|
|
46
50
|
RateLimitError: () => RateLimitError,
|
|
47
51
|
SPACE_STATUSES: () => SPACE_STATUSES,
|
|
@@ -1091,6 +1095,613 @@ var CategoriesService = class extends BaseService {
|
|
|
1091
1095
|
}
|
|
1092
1096
|
};
|
|
1093
1097
|
|
|
1098
|
+
// src/services/distribution.ts
|
|
1099
|
+
var DistributionService = class extends BaseService {
|
|
1100
|
+
constructor() {
|
|
1101
|
+
super(...arguments);
|
|
1102
|
+
this.basePath = "/distribution/v1";
|
|
1103
|
+
}
|
|
1104
|
+
// ---------------------------------------------------------------------------
|
|
1105
|
+
// Channel CRUD
|
|
1106
|
+
// ---------------------------------------------------------------------------
|
|
1107
|
+
/** Create a new distribution channel */
|
|
1108
|
+
createChannel(input) {
|
|
1109
|
+
return this._post(this._buildPath("channels"), input);
|
|
1110
|
+
}
|
|
1111
|
+
/** Get a channel by ID */
|
|
1112
|
+
getChannel(channelId) {
|
|
1113
|
+
return this._get(this._buildPath("channels", channelId));
|
|
1114
|
+
}
|
|
1115
|
+
/** List channels with optional filters */
|
|
1116
|
+
listChannels(params) {
|
|
1117
|
+
if (!params) return this._get(this._buildPath("channels"));
|
|
1118
|
+
const query = {};
|
|
1119
|
+
if (params.propertyId !== void 0) query.propertyId = params.propertyId;
|
|
1120
|
+
if (params.type !== void 0) query.type = params.type;
|
|
1121
|
+
if (params.status !== void 0) query.status = params.status;
|
|
1122
|
+
if (params.enabled !== void 0) query.enabled = params.enabled;
|
|
1123
|
+
if (params.limit !== void 0) query.limit = params.limit;
|
|
1124
|
+
if (params.cursor !== void 0) query.cursor = params.cursor;
|
|
1125
|
+
return this._get(this._buildPath("channels"), query);
|
|
1126
|
+
}
|
|
1127
|
+
/** Update a channel */
|
|
1128
|
+
updateChannel(channelId, input) {
|
|
1129
|
+
return this._patch(this._buildPath("channels", channelId), input);
|
|
1130
|
+
}
|
|
1131
|
+
/** Delete a channel */
|
|
1132
|
+
deleteChannel(channelId) {
|
|
1133
|
+
return this._delete(this._buildPath("channels", channelId));
|
|
1134
|
+
}
|
|
1135
|
+
// ---------------------------------------------------------------------------
|
|
1136
|
+
// Mapping management
|
|
1137
|
+
// ---------------------------------------------------------------------------
|
|
1138
|
+
/** Create a mapping between a local category and OTA room type/rate plan */
|
|
1139
|
+
createMapping(channelId, input) {
|
|
1140
|
+
return this._post(this._buildPath("channels", channelId, "mappings"), input);
|
|
1141
|
+
}
|
|
1142
|
+
/** List mappings for a channel */
|
|
1143
|
+
listMappings(channelId, params) {
|
|
1144
|
+
if (!params) {
|
|
1145
|
+
return this._get(this._buildPath("channels", channelId, "mappings"));
|
|
1146
|
+
}
|
|
1147
|
+
const query = {};
|
|
1148
|
+
if (params.localCategoryId !== void 0) query.localCategoryId = params.localCategoryId;
|
|
1149
|
+
if (params.limit !== void 0) query.limit = params.limit;
|
|
1150
|
+
if (params.cursor !== void 0) query.cursor = params.cursor;
|
|
1151
|
+
return this._get(this._buildPath("channels", channelId, "mappings"), query);
|
|
1152
|
+
}
|
|
1153
|
+
/** Delete a mapping */
|
|
1154
|
+
deleteMapping(channelId, mappingId) {
|
|
1155
|
+
return this._delete(this._buildPath("channels", channelId, "mappings", mappingId));
|
|
1156
|
+
}
|
|
1157
|
+
// ---------------------------------------------------------------------------
|
|
1158
|
+
// Push/pull sync
|
|
1159
|
+
// ---------------------------------------------------------------------------
|
|
1160
|
+
/** Push availability and rates to a channel */
|
|
1161
|
+
push(channelId, input) {
|
|
1162
|
+
return this._post(this._buildPath("channels", channelId, "push"), input ?? {});
|
|
1163
|
+
}
|
|
1164
|
+
/** Pull reservations from a channel */
|
|
1165
|
+
pull(channelId, input) {
|
|
1166
|
+
return this._post(this._buildPath("channels", channelId, "pull"), input ?? {});
|
|
1167
|
+
}
|
|
1168
|
+
/** Get sync operation log for a channel */
|
|
1169
|
+
getSyncLog(channelId, params) {
|
|
1170
|
+
if (!params) {
|
|
1171
|
+
return this._get(this._buildPath("channels", channelId, "sync-log"));
|
|
1172
|
+
}
|
|
1173
|
+
const query = {};
|
|
1174
|
+
if (params.type !== void 0) query.type = params.type;
|
|
1175
|
+
if (params.status !== void 0) query.status = params.status;
|
|
1176
|
+
if (params.from !== void 0) query.from = params.from;
|
|
1177
|
+
if (params.to !== void 0) query.to = params.to;
|
|
1178
|
+
if (params.limit !== void 0) query.limit = params.limit;
|
|
1179
|
+
if (params.cursor !== void 0) query.cursor = params.cursor;
|
|
1180
|
+
return this._get(this._buildPath("channels", channelId, "sync-log"), query);
|
|
1181
|
+
}
|
|
1182
|
+
// ---------------------------------------------------------------------------
|
|
1183
|
+
// iCal import/export
|
|
1184
|
+
// ---------------------------------------------------------------------------
|
|
1185
|
+
/** Import availability from an external iCal feed */
|
|
1186
|
+
icalImport(input) {
|
|
1187
|
+
return this._post(this._buildPath("ical", "import"), input);
|
|
1188
|
+
}
|
|
1189
|
+
/** Get iCal export URL for a space */
|
|
1190
|
+
icalExport(spaceId) {
|
|
1191
|
+
return this._get(this._buildPath("ical", "export", spaceId));
|
|
1192
|
+
}
|
|
1193
|
+
};
|
|
1194
|
+
|
|
1195
|
+
// src/services/finance.ts
|
|
1196
|
+
var FinanceService = class extends BaseService {
|
|
1197
|
+
constructor() {
|
|
1198
|
+
super(...arguments);
|
|
1199
|
+
this.basePath = "/finance/v1";
|
|
1200
|
+
}
|
|
1201
|
+
// ---------------------------------------------------------------------------
|
|
1202
|
+
// Folio CRUD and lifecycle
|
|
1203
|
+
// ---------------------------------------------------------------------------
|
|
1204
|
+
/** Create a new folio for a booking */
|
|
1205
|
+
createFolio(input) {
|
|
1206
|
+
return this._post(this._buildPath("folios"), input);
|
|
1207
|
+
}
|
|
1208
|
+
/** Get a folio by ID */
|
|
1209
|
+
getFolio(folioId) {
|
|
1210
|
+
return this._get(this._buildPath("folios", folioId));
|
|
1211
|
+
}
|
|
1212
|
+
/** List folios with optional filters */
|
|
1213
|
+
listFolios(params) {
|
|
1214
|
+
if (!params) return this._get(this._buildPath("folios"));
|
|
1215
|
+
const query = {};
|
|
1216
|
+
if (params.bookingId !== void 0) query.bookingId = params.bookingId;
|
|
1217
|
+
if (params.guestId !== void 0) query.guestId = params.guestId;
|
|
1218
|
+
if (params.status !== void 0) query.status = params.status;
|
|
1219
|
+
if (params.limit !== void 0) query.limit = params.limit;
|
|
1220
|
+
if (params.cursor !== void 0) query.cursor = params.cursor;
|
|
1221
|
+
return this._get(this._buildPath("folios"), query);
|
|
1222
|
+
}
|
|
1223
|
+
/** Update a folio */
|
|
1224
|
+
updateFolio(folioId, input) {
|
|
1225
|
+
return this._patch(this._buildPath("folios", folioId), input);
|
|
1226
|
+
}
|
|
1227
|
+
/** Close a folio (no more charges can be added) */
|
|
1228
|
+
closeFolio(folioId) {
|
|
1229
|
+
return this._post(this._buildPath("folios", folioId, "close"), {});
|
|
1230
|
+
}
|
|
1231
|
+
/** Settle a folio (mark as fully paid) */
|
|
1232
|
+
settleFolio(folioId) {
|
|
1233
|
+
return this._post(this._buildPath("folios", folioId, "settle"), {});
|
|
1234
|
+
}
|
|
1235
|
+
// ---------------------------------------------------------------------------
|
|
1236
|
+
// Charge operations
|
|
1237
|
+
// ---------------------------------------------------------------------------
|
|
1238
|
+
/** Create a charge on a folio */
|
|
1239
|
+
createCharge(folioId, input) {
|
|
1240
|
+
return this._post(this._buildPath("folios", folioId, "charges"), input);
|
|
1241
|
+
}
|
|
1242
|
+
/** List charges on a folio */
|
|
1243
|
+
listCharges(folioId, params) {
|
|
1244
|
+
if (!params) {
|
|
1245
|
+
return this._get(this._buildPath("folios", folioId, "charges"));
|
|
1246
|
+
}
|
|
1247
|
+
const query = {};
|
|
1248
|
+
if (params.type !== void 0) query.type = params.type;
|
|
1249
|
+
if (params.limit !== void 0) query.limit = params.limit;
|
|
1250
|
+
if (params.cursor !== void 0) query.cursor = params.cursor;
|
|
1251
|
+
return this._get(this._buildPath("folios", folioId, "charges"), query);
|
|
1252
|
+
}
|
|
1253
|
+
/** Create a transitory (non-billable) charge on a folio */
|
|
1254
|
+
createTransitoryCharge(folioId, input) {
|
|
1255
|
+
return this._post(
|
|
1256
|
+
this._buildPath("folios", folioId, "charges", "transitory"),
|
|
1257
|
+
input
|
|
1258
|
+
);
|
|
1259
|
+
}
|
|
1260
|
+
/** Move charges from one folio to another */
|
|
1261
|
+
moveCharges(folioId, input) {
|
|
1262
|
+
return this._post(
|
|
1263
|
+
this._buildPath("folios", folioId, "charges", "move"),
|
|
1264
|
+
input
|
|
1265
|
+
);
|
|
1266
|
+
}
|
|
1267
|
+
// ---------------------------------------------------------------------------
|
|
1268
|
+
// Folio payment operations
|
|
1269
|
+
// ---------------------------------------------------------------------------
|
|
1270
|
+
/** Record a payment on a folio */
|
|
1271
|
+
createFolioPayment(folioId, input) {
|
|
1272
|
+
return this._post(this._buildPath("folios", folioId, "payments"), input);
|
|
1273
|
+
}
|
|
1274
|
+
/** List payments on a folio */
|
|
1275
|
+
listFolioPayments(folioId, params) {
|
|
1276
|
+
if (!params) {
|
|
1277
|
+
return this._get(this._buildPath("folios", folioId, "payments"));
|
|
1278
|
+
}
|
|
1279
|
+
const query = {};
|
|
1280
|
+
if (params.limit !== void 0) query.limit = params.limit;
|
|
1281
|
+
if (params.cursor !== void 0) query.cursor = params.cursor;
|
|
1282
|
+
return this._get(this._buildPath("folios", folioId, "payments"), query);
|
|
1283
|
+
}
|
|
1284
|
+
// ---------------------------------------------------------------------------
|
|
1285
|
+
// Invoice operations
|
|
1286
|
+
// ---------------------------------------------------------------------------
|
|
1287
|
+
/** Generate an invoice for a folio */
|
|
1288
|
+
generateInvoice(folioId, input) {
|
|
1289
|
+
return this._post(this._buildPath("folios", folioId, "invoice"), input ?? {});
|
|
1290
|
+
}
|
|
1291
|
+
/** Get an invoice by ID */
|
|
1292
|
+
getInvoice(invoiceId) {
|
|
1293
|
+
return this._get(this._buildPath("invoices", invoiceId));
|
|
1294
|
+
}
|
|
1295
|
+
/** Get invoice as PDF binary data */
|
|
1296
|
+
getInvoicePdf(invoiceId) {
|
|
1297
|
+
return this._get(this._buildPath("invoices", invoiceId, "pdf"));
|
|
1298
|
+
}
|
|
1299
|
+
// ---------------------------------------------------------------------------
|
|
1300
|
+
// Accounting reports
|
|
1301
|
+
// ---------------------------------------------------------------------------
|
|
1302
|
+
/** Get daily accounting report */
|
|
1303
|
+
getDailyReport(params) {
|
|
1304
|
+
if (!params) return this._get(this._buildPath("accounting", "daily"));
|
|
1305
|
+
const query = {};
|
|
1306
|
+
if (params.date !== void 0) query.date = params.date;
|
|
1307
|
+
if (params.propertyId !== void 0) query.propertyId = params.propertyId;
|
|
1308
|
+
return this._get(this._buildPath("accounting", "daily"), query);
|
|
1309
|
+
}
|
|
1310
|
+
/** Get revenue report by charge type */
|
|
1311
|
+
getRevenueReport(params) {
|
|
1312
|
+
if (!params)
|
|
1313
|
+
return this._get(this._buildPath("accounting", "revenue"));
|
|
1314
|
+
const query = {};
|
|
1315
|
+
if (params.from !== void 0) query.from = params.from;
|
|
1316
|
+
if (params.to !== void 0) query.to = params.to;
|
|
1317
|
+
if (params.propertyId !== void 0) query.propertyId = params.propertyId;
|
|
1318
|
+
return this._get(this._buildPath("accounting", "revenue"), query);
|
|
1319
|
+
}
|
|
1320
|
+
/** Get VAT accounting report */
|
|
1321
|
+
getVatReport(params) {
|
|
1322
|
+
if (!params) return this._get(this._buildPath("accounting", "vat"));
|
|
1323
|
+
const query = {};
|
|
1324
|
+
if (params.from !== void 0) query.from = params.from;
|
|
1325
|
+
if (params.to !== void 0) query.to = params.to;
|
|
1326
|
+
if (params.propertyId !== void 0) query.propertyId = params.propertyId;
|
|
1327
|
+
return this._get(this._buildPath("accounting", "vat"), query);
|
|
1328
|
+
}
|
|
1329
|
+
};
|
|
1330
|
+
|
|
1331
|
+
// src/services/guests.ts
|
|
1332
|
+
var GuestsService = class extends BaseService {
|
|
1333
|
+
constructor() {
|
|
1334
|
+
super(...arguments);
|
|
1335
|
+
this.basePath = "/guest/v1/profiles";
|
|
1336
|
+
}
|
|
1337
|
+
// ---------------------------------------------------------------------------
|
|
1338
|
+
// CRUD
|
|
1339
|
+
// ---------------------------------------------------------------------------
|
|
1340
|
+
/**
|
|
1341
|
+
* Create a new guest profile.
|
|
1342
|
+
*
|
|
1343
|
+
* @example
|
|
1344
|
+
* ```typescript
|
|
1345
|
+
* const guest = await client.guests.create({
|
|
1346
|
+
* firstName: "Maria",
|
|
1347
|
+
* lastName: "Papadopoulou",
|
|
1348
|
+
* email: "maria@example.com",
|
|
1349
|
+
* phone: "+30 210 1234567",
|
|
1350
|
+
* nationality: "GR",
|
|
1351
|
+
* });
|
|
1352
|
+
* ```
|
|
1353
|
+
*/
|
|
1354
|
+
create(input) {
|
|
1355
|
+
return this._post(this.basePath, input);
|
|
1356
|
+
}
|
|
1357
|
+
/**
|
|
1358
|
+
* Get a single guest by ID.
|
|
1359
|
+
*
|
|
1360
|
+
* @example
|
|
1361
|
+
* ```typescript
|
|
1362
|
+
* const guest = await client.guests.get("guest_42");
|
|
1363
|
+
* ```
|
|
1364
|
+
*/
|
|
1365
|
+
get(guestId) {
|
|
1366
|
+
return this._get(this._buildPath(guestId));
|
|
1367
|
+
}
|
|
1368
|
+
/**
|
|
1369
|
+
* List guests with optional filters and cursor-based pagination.
|
|
1370
|
+
*
|
|
1371
|
+
* @example
|
|
1372
|
+
* ```typescript
|
|
1373
|
+
* const page = await client.guests.list({
|
|
1374
|
+
* tags: ["vip", "returning"],
|
|
1375
|
+
* sort: { field: "lastName", direction: "asc" },
|
|
1376
|
+
* limit: 20,
|
|
1377
|
+
* });
|
|
1378
|
+
* ```
|
|
1379
|
+
*/
|
|
1380
|
+
list(params) {
|
|
1381
|
+
if (!params) {
|
|
1382
|
+
return this._get(this.basePath);
|
|
1383
|
+
}
|
|
1384
|
+
const query = {};
|
|
1385
|
+
if (params.tags !== void 0 && params.tags.length > 0) {
|
|
1386
|
+
query.tags = params.tags.join(",");
|
|
1387
|
+
}
|
|
1388
|
+
if (params.source !== void 0) query.source = params.source;
|
|
1389
|
+
if (params.createdFrom !== void 0) query.createdFrom = params.createdFrom;
|
|
1390
|
+
if (params.createdTo !== void 0) query.createdTo = params.createdTo;
|
|
1391
|
+
if (params.sort !== void 0) {
|
|
1392
|
+
query.sort = `${params.sort.field}:${params.sort.direction}`;
|
|
1393
|
+
}
|
|
1394
|
+
if (params.limit !== void 0) query.limit = params.limit;
|
|
1395
|
+
if (params.cursor !== void 0) query.cursor = params.cursor;
|
|
1396
|
+
return this._get(this.basePath, query);
|
|
1397
|
+
}
|
|
1398
|
+
/**
|
|
1399
|
+
* Update an existing guest profile.
|
|
1400
|
+
*
|
|
1401
|
+
* @example
|
|
1402
|
+
* ```typescript
|
|
1403
|
+
* const updated = await client.guests.update("guest_42", {
|
|
1404
|
+
* email: "maria.new@example.com",
|
|
1405
|
+
* tags: ["vip"],
|
|
1406
|
+
* });
|
|
1407
|
+
* ```
|
|
1408
|
+
*/
|
|
1409
|
+
update(guestId, input) {
|
|
1410
|
+
return this._patch(this._buildPath(guestId), input);
|
|
1411
|
+
}
|
|
1412
|
+
/**
|
|
1413
|
+
* Delete a guest profile (soft-delete).
|
|
1414
|
+
*
|
|
1415
|
+
* @example
|
|
1416
|
+
* ```typescript
|
|
1417
|
+
* await client.guests.delete("guest_42");
|
|
1418
|
+
* ```
|
|
1419
|
+
*/
|
|
1420
|
+
delete(guestId) {
|
|
1421
|
+
return this._delete(this._buildPath(guestId));
|
|
1422
|
+
}
|
|
1423
|
+
// ---------------------------------------------------------------------------
|
|
1424
|
+
// Search and Duplicate Detection
|
|
1425
|
+
// ---------------------------------------------------------------------------
|
|
1426
|
+
/**
|
|
1427
|
+
* Search guests by name, email, phone, or passport number.
|
|
1428
|
+
*
|
|
1429
|
+
* Returns results sorted by relevance score (highest first).
|
|
1430
|
+
*
|
|
1431
|
+
* @param query - Search query string
|
|
1432
|
+
* @param params - Optional search parameters (limit, fields)
|
|
1433
|
+
*
|
|
1434
|
+
* @example
|
|
1435
|
+
* ```typescript
|
|
1436
|
+
* // Search by name
|
|
1437
|
+
* const results = await client.guests.search("Papadopoulos");
|
|
1438
|
+
*
|
|
1439
|
+
* // Search by email with field filter
|
|
1440
|
+
* const results2 = await client.guests.search("maria@", {
|
|
1441
|
+
* fields: ["email"],
|
|
1442
|
+
* limit: 5,
|
|
1443
|
+
* });
|
|
1444
|
+
* ```
|
|
1445
|
+
*/
|
|
1446
|
+
search(query, params) {
|
|
1447
|
+
const searchQuery = {
|
|
1448
|
+
q: query
|
|
1449
|
+
};
|
|
1450
|
+
if (params?.limit !== void 0) searchQuery.limit = params.limit;
|
|
1451
|
+
if (params?.fields !== void 0 && params.fields.length > 0) {
|
|
1452
|
+
searchQuery.fields = params.fields.join(",");
|
|
1453
|
+
}
|
|
1454
|
+
return this._get(this._buildPath("search"), searchQuery);
|
|
1455
|
+
}
|
|
1456
|
+
/**
|
|
1457
|
+
* Find potential duplicate profiles for a guest.
|
|
1458
|
+
*
|
|
1459
|
+
* Returns candidates sorted by confidence score (highest first).
|
|
1460
|
+
*
|
|
1461
|
+
* @throws {NotFoundError} 404 if the guest is not found
|
|
1462
|
+
*
|
|
1463
|
+
* @example
|
|
1464
|
+
* ```typescript
|
|
1465
|
+
* const duplicates = await client.guests.findDuplicates("guest_42");
|
|
1466
|
+
* for (const dup of duplicates.data) {
|
|
1467
|
+
* console.log(`${dup.guest.firstName} — ${dup.confidence} (${dup.matchedFields})`);
|
|
1468
|
+
* }
|
|
1469
|
+
* ```
|
|
1470
|
+
*/
|
|
1471
|
+
findDuplicates(guestId) {
|
|
1472
|
+
return this._get(this._buildPath(guestId, "duplicates"));
|
|
1473
|
+
}
|
|
1474
|
+
// ---------------------------------------------------------------------------
|
|
1475
|
+
// Merge
|
|
1476
|
+
// ---------------------------------------------------------------------------
|
|
1477
|
+
/**
|
|
1478
|
+
* Merge duplicate guest profiles into a primary profile.
|
|
1479
|
+
*
|
|
1480
|
+
* **Warning: This operation is irreversible.** All history from duplicate
|
|
1481
|
+
* profiles is transferred to the primary. Duplicate profiles are soft-deleted.
|
|
1482
|
+
*
|
|
1483
|
+
* @throws {NotFoundError} 404 if primary or any duplicate is not found
|
|
1484
|
+
* @throws {ConflictError} 409 if attempting to merge a guest into itself
|
|
1485
|
+
* @throws {ValidationError} 400 if duplicateIds is empty
|
|
1486
|
+
*
|
|
1487
|
+
* @example
|
|
1488
|
+
* ```typescript
|
|
1489
|
+
* const merged = await client.guests.merge("guest_primary", {
|
|
1490
|
+
* duplicateIds: ["guest_dup1", "guest_dup2"],
|
|
1491
|
+
* });
|
|
1492
|
+
* ```
|
|
1493
|
+
*/
|
|
1494
|
+
merge(primaryId, input) {
|
|
1495
|
+
return this._post(this._buildPath(primaryId, "merge"), input);
|
|
1496
|
+
}
|
|
1497
|
+
// ---------------------------------------------------------------------------
|
|
1498
|
+
// Preferences
|
|
1499
|
+
// ---------------------------------------------------------------------------
|
|
1500
|
+
/**
|
|
1501
|
+
* Get guest preferences.
|
|
1502
|
+
*
|
|
1503
|
+
* Returns default/empty preferences if none have been set (does not throw 404).
|
|
1504
|
+
*
|
|
1505
|
+
* @throws {NotFoundError} 404 if the guest is not found
|
|
1506
|
+
*
|
|
1507
|
+
* @example
|
|
1508
|
+
* ```typescript
|
|
1509
|
+
* const prefs = await client.guests.getPreferences("guest_42");
|
|
1510
|
+
* console.log(prefs.dietary, prefs.roomType);
|
|
1511
|
+
* ```
|
|
1512
|
+
*/
|
|
1513
|
+
getPreferences(guestId) {
|
|
1514
|
+
return this._get(this._buildPath(guestId, "preferences"));
|
|
1515
|
+
}
|
|
1516
|
+
/**
|
|
1517
|
+
* Update guest preferences (partial merge).
|
|
1518
|
+
*
|
|
1519
|
+
* Only provided fields are updated; unspecified fields retain their values.
|
|
1520
|
+
*
|
|
1521
|
+
* @throws {NotFoundError} 404 if the guest is not found
|
|
1522
|
+
*
|
|
1523
|
+
* @example
|
|
1524
|
+
* ```typescript
|
|
1525
|
+
* const updated = await client.guests.updatePreferences("guest_42", {
|
|
1526
|
+
* dietary: ["vegetarian"],
|
|
1527
|
+
* roomType: "suite",
|
|
1528
|
+
* custom: { pillow: "firm" },
|
|
1529
|
+
* });
|
|
1530
|
+
* ```
|
|
1531
|
+
*/
|
|
1532
|
+
updatePreferences(guestId, input) {
|
|
1533
|
+
return this._patch(this._buildPath(guestId, "preferences"), input);
|
|
1534
|
+
}
|
|
1535
|
+
// ---------------------------------------------------------------------------
|
|
1536
|
+
// Cross-Domain History
|
|
1537
|
+
// ---------------------------------------------------------------------------
|
|
1538
|
+
/**
|
|
1539
|
+
* Get a guest's booking history.
|
|
1540
|
+
*
|
|
1541
|
+
* Returns lightweight booking summaries with pagination support.
|
|
1542
|
+
*
|
|
1543
|
+
* @throws {NotFoundError} 404 if the guest is not found
|
|
1544
|
+
*
|
|
1545
|
+
* @example
|
|
1546
|
+
* ```typescript
|
|
1547
|
+
* const bookings = await client.guests.getBookings("guest_42", {
|
|
1548
|
+
* from: "2025-01-01",
|
|
1549
|
+
* to: "2025-12-31",
|
|
1550
|
+
* limit: 10,
|
|
1551
|
+
* });
|
|
1552
|
+
* ```
|
|
1553
|
+
*/
|
|
1554
|
+
getBookings(guestId, params) {
|
|
1555
|
+
return this._get(
|
|
1556
|
+
this._buildPath(guestId, "bookings"),
|
|
1557
|
+
params ? this._buildHistoryQuery(params) : void 0
|
|
1558
|
+
);
|
|
1559
|
+
}
|
|
1560
|
+
/**
|
|
1561
|
+
* Get a guest's folio history.
|
|
1562
|
+
*
|
|
1563
|
+
* Returns lightweight folio summaries with pagination support.
|
|
1564
|
+
*
|
|
1565
|
+
* @throws {NotFoundError} 404 if the guest is not found
|
|
1566
|
+
*
|
|
1567
|
+
* @example
|
|
1568
|
+
* ```typescript
|
|
1569
|
+
* const folios = await client.guests.getFolios("guest_42");
|
|
1570
|
+
* ```
|
|
1571
|
+
*/
|
|
1572
|
+
getFolios(guestId, params) {
|
|
1573
|
+
return this._get(
|
|
1574
|
+
this._buildPath(guestId, "folios"),
|
|
1575
|
+
params ? this._buildHistoryQuery(params) : void 0
|
|
1576
|
+
);
|
|
1577
|
+
}
|
|
1578
|
+
/**
|
|
1579
|
+
* Get a guest's order history.
|
|
1580
|
+
*
|
|
1581
|
+
* Returns lightweight order summaries with pagination support.
|
|
1582
|
+
*
|
|
1583
|
+
* @throws {NotFoundError} 404 if the guest is not found
|
|
1584
|
+
*
|
|
1585
|
+
* @example
|
|
1586
|
+
* ```typescript
|
|
1587
|
+
* const orders = await client.guests.getOrders("guest_42", {
|
|
1588
|
+
* limit: 5,
|
|
1589
|
+
* cursor: "next_page",
|
|
1590
|
+
* });
|
|
1591
|
+
* ```
|
|
1592
|
+
*/
|
|
1593
|
+
getOrders(guestId, params) {
|
|
1594
|
+
return this._get(
|
|
1595
|
+
this._buildPath(guestId, "orders"),
|
|
1596
|
+
params ? this._buildHistoryQuery(params) : void 0
|
|
1597
|
+
);
|
|
1598
|
+
}
|
|
1599
|
+
/** Build query params from GuestHistoryParams, omitting undefined values */
|
|
1600
|
+
_buildHistoryQuery(params) {
|
|
1601
|
+
const query = {};
|
|
1602
|
+
if (params.limit !== void 0) query.limit = params.limit;
|
|
1603
|
+
if (params.cursor !== void 0) query.cursor = params.cursor;
|
|
1604
|
+
if (params.from !== void 0) query.from = params.from;
|
|
1605
|
+
if (params.to !== void 0) query.to = params.to;
|
|
1606
|
+
return query;
|
|
1607
|
+
}
|
|
1608
|
+
};
|
|
1609
|
+
|
|
1610
|
+
// src/services/payments.ts
|
|
1611
|
+
var PaymentsService = class extends BaseService {
|
|
1612
|
+
constructor() {
|
|
1613
|
+
super(...arguments);
|
|
1614
|
+
this.basePath = "/payment/v1";
|
|
1615
|
+
}
|
|
1616
|
+
// ---------------------------------------------------------------------------
|
|
1617
|
+
// Process and refund
|
|
1618
|
+
// ---------------------------------------------------------------------------
|
|
1619
|
+
/** Process a payment for a booking */
|
|
1620
|
+
process(input) {
|
|
1621
|
+
return this._post(this._buildPath("payments"), input);
|
|
1622
|
+
}
|
|
1623
|
+
/** Refund a payment (full or partial) */
|
|
1624
|
+
refund(paymentId, input) {
|
|
1625
|
+
return this._post(this._buildPath("payments", paymentId, "refund"), input ?? {});
|
|
1626
|
+
}
|
|
1627
|
+
// ---------------------------------------------------------------------------
|
|
1628
|
+
// Transactions
|
|
1629
|
+
// ---------------------------------------------------------------------------
|
|
1630
|
+
/** Get a transaction by ID */
|
|
1631
|
+
getTransaction(transactionId) {
|
|
1632
|
+
return this._get(this._buildPath("transactions", transactionId));
|
|
1633
|
+
}
|
|
1634
|
+
/** List transactions with optional filters */
|
|
1635
|
+
listTransactions(params) {
|
|
1636
|
+
if (!params) return this._get(this._buildPath("transactions"));
|
|
1637
|
+
const query = {};
|
|
1638
|
+
if (params.bookingId !== void 0) query.bookingId = params.bookingId;
|
|
1639
|
+
if (params.status !== void 0) query.status = params.status;
|
|
1640
|
+
if (params.provider !== void 0) query.provider = params.provider;
|
|
1641
|
+
if (params.type !== void 0) query.type = params.type;
|
|
1642
|
+
if (params.from !== void 0) query.from = params.from;
|
|
1643
|
+
if (params.to !== void 0) query.to = params.to;
|
|
1644
|
+
if (params.limit !== void 0) query.limit = params.limit;
|
|
1645
|
+
if (params.cursor !== void 0) query.cursor = params.cursor;
|
|
1646
|
+
return this._get(this._buildPath("transactions"), query);
|
|
1647
|
+
}
|
|
1648
|
+
// ---------------------------------------------------------------------------
|
|
1649
|
+
// Payment accounts (stored cards)
|
|
1650
|
+
// ---------------------------------------------------------------------------
|
|
1651
|
+
/** Create a payment account (store a card on file) */
|
|
1652
|
+
createAccount(input) {
|
|
1653
|
+
return this._post(this._buildPath("accounts"), input);
|
|
1654
|
+
}
|
|
1655
|
+
/** Get a payment account by ID */
|
|
1656
|
+
getAccount(accountId) {
|
|
1657
|
+
return this._get(this._buildPath("accounts", accountId));
|
|
1658
|
+
}
|
|
1659
|
+
/** List payment accounts with optional filters */
|
|
1660
|
+
listAccounts(params) {
|
|
1661
|
+
if (!params) return this._get(this._buildPath("accounts"));
|
|
1662
|
+
const query = {};
|
|
1663
|
+
if (params.bookingId !== void 0) query.bookingId = params.bookingId;
|
|
1664
|
+
if (params.guestId !== void 0) query.guestId = params.guestId;
|
|
1665
|
+
if (params.status !== void 0) query.status = params.status;
|
|
1666
|
+
if (params.limit !== void 0) query.limit = params.limit;
|
|
1667
|
+
if (params.cursor !== void 0) query.cursor = params.cursor;
|
|
1668
|
+
return this._get(this._buildPath("accounts"), query);
|
|
1669
|
+
}
|
|
1670
|
+
/** Delete a payment account */
|
|
1671
|
+
deleteAccount(accountId) {
|
|
1672
|
+
return this._delete(this._buildPath("accounts", accountId));
|
|
1673
|
+
}
|
|
1674
|
+
// ---------------------------------------------------------------------------
|
|
1675
|
+
// Authorize and capture
|
|
1676
|
+
// ---------------------------------------------------------------------------
|
|
1677
|
+
/** Authorize a hold on a stored card */
|
|
1678
|
+
authorize(accountId, input) {
|
|
1679
|
+
return this._post(this._buildPath("accounts", accountId, "authorize"), input);
|
|
1680
|
+
}
|
|
1681
|
+
/** Capture a previously authorized hold */
|
|
1682
|
+
capture(accountId, input) {
|
|
1683
|
+
return this._post(this._buildPath("accounts", accountId, "capture"), input);
|
|
1684
|
+
}
|
|
1685
|
+
// ---------------------------------------------------------------------------
|
|
1686
|
+
// Terminal operations
|
|
1687
|
+
// ---------------------------------------------------------------------------
|
|
1688
|
+
/** Initiate a POS terminal payment authorization */
|
|
1689
|
+
terminalAuthorize(input) {
|
|
1690
|
+
return this._post(this._buildPath("terminal", "authorize"), input);
|
|
1691
|
+
}
|
|
1692
|
+
// ---------------------------------------------------------------------------
|
|
1693
|
+
// IRIS operations
|
|
1694
|
+
// ---------------------------------------------------------------------------
|
|
1695
|
+
/** Initiate an IRIS instant bank transfer */
|
|
1696
|
+
irisInitiate(input) {
|
|
1697
|
+
return this._post(this._buildPath("iris", "initiate"), input);
|
|
1698
|
+
}
|
|
1699
|
+
/** Get the status of an IRIS transfer */
|
|
1700
|
+
irisStatus(transferId) {
|
|
1701
|
+
return this._get(this._buildPath("iris", transferId));
|
|
1702
|
+
}
|
|
1703
|
+
};
|
|
1704
|
+
|
|
1094
1705
|
// src/services/properties.ts
|
|
1095
1706
|
var PropertiesService = class extends BaseService {
|
|
1096
1707
|
constructor() {
|
|
@@ -1320,6 +1931,26 @@ var BookingClient = class {
|
|
|
1320
1931
|
this._bookings ?? (this._bookings = new BookingsService(this.httpClient));
|
|
1321
1932
|
return this._bookings;
|
|
1322
1933
|
}
|
|
1934
|
+
/** Distribution service — lazy-initialized on first access */
|
|
1935
|
+
get distribution() {
|
|
1936
|
+
this._distribution ?? (this._distribution = new DistributionService(this.httpClient));
|
|
1937
|
+
return this._distribution;
|
|
1938
|
+
}
|
|
1939
|
+
/** Finance service — lazy-initialized on first access */
|
|
1940
|
+
get finance() {
|
|
1941
|
+
this._finance ?? (this._finance = new FinanceService(this.httpClient));
|
|
1942
|
+
return this._finance;
|
|
1943
|
+
}
|
|
1944
|
+
/** Guests service — lazy-initialized on first access */
|
|
1945
|
+
get guests() {
|
|
1946
|
+
this._guests ?? (this._guests = new GuestsService(this.httpClient));
|
|
1947
|
+
return this._guests;
|
|
1948
|
+
}
|
|
1949
|
+
/** Payments service — lazy-initialized on first access */
|
|
1950
|
+
get payments() {
|
|
1951
|
+
this._payments ?? (this._payments = new PaymentsService(this.httpClient));
|
|
1952
|
+
return this._payments;
|
|
1953
|
+
}
|
|
1323
1954
|
/** Properties service — lazy-initialized on first access */
|
|
1324
1955
|
get properties() {
|
|
1325
1956
|
this._properties ?? (this._properties = new PropertiesService(this.httpClient));
|
|
@@ -1453,11 +2084,15 @@ var VERSION = "0.1.0";
|
|
|
1453
2084
|
CategoriesService,
|
|
1454
2085
|
ConflictError,
|
|
1455
2086
|
DEFAULT_MODULES,
|
|
2087
|
+
DistributionService,
|
|
2088
|
+
FinanceService,
|
|
1456
2089
|
ForbiddenError,
|
|
2090
|
+
GuestsService,
|
|
1457
2091
|
HttpClient,
|
|
1458
2092
|
NotFoundError,
|
|
1459
2093
|
PROPERTY_MODULES,
|
|
1460
2094
|
PaymentError,
|
|
2095
|
+
PaymentsService,
|
|
1461
2096
|
PropertiesService,
|
|
1462
2097
|
RateLimitError,
|
|
1463
2098
|
SPACE_STATUSES,
|