@opens/gateways 1.16.10 → 1.16.12

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.mjs CHANGED
@@ -350,32 +350,6 @@ var CustomerServiceGateway = class {
350
350
  });
351
351
  return data;
352
352
  }
353
- /**
354
- * Submits one response to a survey announcement.
355
- * @param announcementId - The unique identifier of the survey announcement.
356
- * @param payload - The subject identifier and validated survey answers.
357
- * @returns The persisted survey response.
358
- */
359
- async submitSurveyResponse(announcementId, payload) {
360
- const { data } = await this.httpClient.post(
361
- `${this.baseUrl}/announcements/${announcementId}/responses`,
362
- payload
363
- );
364
- return data;
365
- }
366
- /**
367
- * Retrieves paginated responses for a survey announcement.
368
- * @param announcementId - The unique identifier of the survey announcement.
369
- * @param query - Pagination options for the administrative list.
370
- * @returns Paginated survey responses.
371
- */
372
- async findSurveyResponses(announcementId, query) {
373
- const { data } = await this.httpClient.get(
374
- `${this.baseUrl}/announcements/admin/${announcementId}/responses`,
375
- { params: query }
376
- );
377
- return data;
378
- }
379
353
  };
380
354
 
381
355
  // src/chat-config/index.ts
@@ -1409,6 +1383,88 @@ var AccessHubGateway = class {
1409
1383
  }
1410
1384
  };
1411
1385
 
1386
+ // src/notifications/index.ts
1387
+ var NotificationsGateway = class {
1388
+ constructor(httpClient, baseUrl) {
1389
+ this.httpClient = httpClient;
1390
+ this.baseUrl = baseUrl;
1391
+ }
1392
+ httpClient;
1393
+ baseUrl;
1394
+ /**
1395
+ * Returns the catalog of available system notifications with their types and metadata.
1396
+ * @param params - Optional filters by type slug or type ID.
1397
+ * @returns A list of system notifications and the total count.
1398
+ */
1399
+ async getSystemNotifications(params) {
1400
+ const { data } = await this.httpClient.get(
1401
+ `${this.baseUrl}/notification/system-notifications`,
1402
+ { params }
1403
+ );
1404
+ return data;
1405
+ }
1406
+ /**
1407
+ * Lists push notification devices registered for the authenticated user.
1408
+ * @param params - Optional filters, pagination and service-token context.
1409
+ * @returns A list of user devices and the total count.
1410
+ */
1411
+ async getUserDevices(params) {
1412
+ const { data } = await this.httpClient.get(`${this.baseUrl}/user/devices`, { params });
1413
+ return data;
1414
+ }
1415
+ /**
1416
+ * Registers or updates a push notification token for a user device.
1417
+ * Idempotent via findOrCreate on deviceToken.
1418
+ * @param payload - Device token and either deviceSlug or deviceId.
1419
+ * @returns The registered device summary.
1420
+ */
1421
+ async registerUserDevice(payload) {
1422
+ const { data } = await this.httpClient.post(`${this.baseUrl}/user/devices`, payload);
1423
+ return data;
1424
+ }
1425
+ /**
1426
+ * Deletes a registered user device and its notification token.
1427
+ * @param id - UUID of the user device record.
1428
+ * @returns Confirmation of deletion.
1429
+ */
1430
+ async deleteUserDevice(id) {
1431
+ const { data } = await this.httpClient.delete(`${this.baseUrl}/user/devices/${id}`);
1432
+ return data;
1433
+ }
1434
+ /**
1435
+ * Lists active notification preferences for the user, optionally filtered by device.
1436
+ * @param params - Optional filters and service-token context.
1437
+ * @returns A list of user preferences.
1438
+ */
1439
+ async getUserPreferences(params) {
1440
+ const { data } = await this.httpClient.get(`${this.baseUrl}/user/preferences`, { params });
1441
+ return data;
1442
+ }
1443
+ /**
1444
+ * Creates or activates a notification preference for a user device.
1445
+ * Idempotent via findOrCreate on the user/device/notification combination.
1446
+ * @param payload - Device ID and either systemNotificationSlug or systemNotificationId.
1447
+ * @returns The created or existing preference.
1448
+ */
1449
+ async createUserPreference(payload) {
1450
+ const { data } = await this.httpClient.post(`${this.baseUrl}/user/preferences`, payload);
1451
+ return data;
1452
+ }
1453
+ /**
1454
+ * Deletes a notification preference by its ID.
1455
+ * @param id - UUID of the preference in `user_notification_preferences`.
1456
+ * @param params - Optional companyId/userId for Service Token context.
1457
+ * @returns Confirmation of deletion.
1458
+ */
1459
+ async deleteUserPreference(id, params) {
1460
+ const { data } = await this.httpClient.delete(
1461
+ `${this.baseUrl}/user/preferences/${id}`,
1462
+ { params }
1463
+ );
1464
+ return data;
1465
+ }
1466
+ };
1467
+
1412
1468
  // src/@common/client.ts
1413
1469
  import axios from "axios";
1414
1470
  var SDKGateways = class {
@@ -1425,7 +1481,8 @@ var SDKGateways = class {
1425
1481
  cases;
1426
1482
  rh;
1427
1483
  accessHub;
1428
- constructor(customerService, chatConfig, campaigns, chatAdapter, assets, contactList, integrations, chatWebservice, callReport, calls, cases, rh, accessHub) {
1484
+ notifications;
1485
+ constructor(customerService, chatConfig, campaigns, chatAdapter, assets, contactList, integrations, chatWebservice, callReport, calls, cases, rh, accessHub, notifications) {
1429
1486
  this.customerService = customerService;
1430
1487
  this.chatConfig = chatConfig;
1431
1488
  this.campaigns = campaigns;
@@ -1439,6 +1496,7 @@ var SDKGateways = class {
1439
1496
  this.cases = cases;
1440
1497
  this.rh = rh;
1441
1498
  this.accessHub = accessHub;
1499
+ this.notifications = notifications;
1442
1500
  }
1443
1501
  };
1444
1502
  function createClient(params) {
@@ -1460,6 +1518,7 @@ function createClient(params) {
1460
1518
  const cases = params.services.cases ? new CasesGateway(httpClient, params.services.cases.baseUrl) : null;
1461
1519
  const rh = params.services.rh ? new RhGateway(httpClient, params.services.rh.baseUrl) : null;
1462
1520
  const accessHub = params.services.accessHub ? new AccessHubGateway(httpClient, params.services.accessHub.baseUrl) : null;
1521
+ const notifications = params.services.notifications ? new NotificationsGateway(httpClient, params.services.notifications.baseUrl) : null;
1463
1522
  return new SDKGateways(
1464
1523
  customerService,
1465
1524
  chatConfig,
@@ -1473,7 +1532,8 @@ function createClient(params) {
1473
1532
  calls,
1474
1533
  cases,
1475
1534
  rh,
1476
- accessHub
1535
+ accessHub,
1536
+ notifications
1477
1537
  );
1478
1538
  }
1479
1539
 
@@ -1491,7 +1551,8 @@ var SERVICE_GATEWAYS = {
1491
1551
  CALLS: "calls",
1492
1552
  CASES: "cases",
1493
1553
  RH: "rh",
1494
- ACCESS_HUB: "access-hub"
1554
+ ACCESS_HUB: "access-hub",
1555
+ NOTIFICATIONS: "notifications"
1495
1556
  };
1496
1557
 
1497
1558
  // src/index.ts
@@ -1560,6 +1621,10 @@ function gateway(service) {
1560
1621
  if (!sdk.client.accessHub)
1561
1622
  throw new Error(`Service 'access-hub' is not configured. Provide its baseUrl in configure().`);
1562
1623
  return sdk.client.accessHub;
1624
+ case SERVICE_GATEWAYS.NOTIFICATIONS:
1625
+ if (!sdk.client.notifications)
1626
+ throw new Error(`Service 'notifications' is not configured. Provide its baseUrl in configure().`);
1627
+ return sdk.client.notifications;
1563
1628
  default:
1564
1629
  throw new Error(`Unknown service gateway: ${service}`);
1565
1630
  }