@unboundcx/sdk 4.13.55 → 4.13.56

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unboundcx/sdk",
3
- "version": "4.13.55",
3
+ "version": "4.13.56",
4
4
  "description": "Official JavaScript SDK for the Unbound API - A comprehensive toolkit for integrating with Unbound's communication, AI, and data management services",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -0,0 +1,71 @@
1
+ import { internalRequest } from '../../base.js';
2
+
3
+ /**
4
+ * Offer Service - accept/decline a direct offer (transfer/invite/help) routed to a user
5
+ */
6
+ export class OfferService {
7
+ constructor(sdk) {
8
+ this.sdk = sdk;
9
+ }
10
+
11
+ /**
12
+ * Accept a pending direct offer.
13
+ * Creates/reuses the caller's worker session as needed and assigns the task to them.
14
+ *
15
+ * @param {Object} options - Options
16
+ * @param {string} options.offerId - Offer ID
17
+ * @returns {Promise<Object>} { taskId, workerId, isVoice }
18
+ *
19
+ * @example
20
+ * const result = await sdk.taskRouter.offer.accept({ offerId: 'offer_123' });
21
+ */
22
+ async accept({ offerId }) {
23
+ this.sdk.validateParams(
24
+ { offerId },
25
+ {
26
+ offerId: { type: 'string', required: true },
27
+ },
28
+ );
29
+
30
+ const params = {
31
+ body: { offerId },
32
+ };
33
+
34
+ const result = await internalRequest(this.sdk,
35
+ '/taskRouter/offers/accept',
36
+ 'PUT',
37
+ params,
38
+ );
39
+ return result;
40
+ }
41
+
42
+ /**
43
+ * Decline a pending direct offer.
44
+ *
45
+ * @param {Object} options - Options
46
+ * @param {string} options.offerId - Offer ID
47
+ * @returns {Promise<Object>} { offerId }
48
+ *
49
+ * @example
50
+ * const result = await sdk.taskRouter.offer.decline({ offerId: 'offer_123' });
51
+ */
52
+ async decline({ offerId }) {
53
+ this.sdk.validateParams(
54
+ { offerId },
55
+ {
56
+ offerId: { type: 'string', required: true },
57
+ },
58
+ );
59
+
60
+ const params = {
61
+ body: { offerId },
62
+ };
63
+
64
+ const result = await internalRequest(this.sdk,
65
+ '/taskRouter/offers/decline',
66
+ 'PUT',
67
+ params,
68
+ );
69
+ return result;
70
+ }
71
+ }
@@ -2,6 +2,7 @@ import { WorkerService } from './WorkerService.js';
2
2
  import { TaskService } from './TaskService.js';
3
3
  import { MetricsService } from './MetricsService.js';
4
4
  import { CCService } from './CCService.js';
5
+ import { OfferService } from './OfferService.js';
5
6
 
6
7
  export class TaskRouterService {
7
8
  constructor(sdk) {
@@ -10,5 +11,6 @@ export class TaskRouterService {
10
11
  this.task = new TaskService(sdk);
11
12
  this.metrics = new MetricsService(sdk);
12
13
  this.cc = new CCService(sdk);
14
+ this.offer = new OfferService(sdk);
13
15
  }
14
16
  }