@osmapi/osmtalk-sdk 0.3.1 → 0.4.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/README.md +24 -1
- package/dist/index.d.mts +81 -5
- package/dist/index.d.ts +81 -5
- package/dist/index.js +65 -2
- package/dist/index.mjs +65 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -38,8 +38,9 @@ console.log("Call started:", call.callId);
|
|
|
38
38
|
| Resource | Operations |
|
|
39
39
|
|---|---|
|
|
40
40
|
| `client.agents` | `list`, `get`, `create`, `update`, `delete`, `connect`, `publishVersion`, `listVersions`, `getVersion`, `rollbackToVersion` |
|
|
41
|
-
| `client.calls` | `list
|
|
41
|
+
| `client.calls` | `list` (paginated), `get`, `outbound`, `end`, `transfer`, `waitUntilEnded` |
|
|
42
42
|
| `client.campaigns` | `list`, `get`, `create`, `update`, `delete`, `start`, `pause`, `resume`, `stop`, `report`, `uploadLeadsCsv`, `uploadLeads`, `listLeads` |
|
|
43
|
+
| `client.phoneNumbers` | `list`, `update` |
|
|
43
44
|
| `client.dnc` | `list`, `add`, `bulkAdd`, `remove` |
|
|
44
45
|
| `client.eval` | `simulate`, `createTestCase`, `listTestCases`, `runTestCase`, `runAll`, `listRuns`, `getRun` |
|
|
45
46
|
| `client.settings` | `get`, `getStorage`, `updateStorage`, `getWebhook`, `updateWebhook`, `getCompliance`, `updateCompliance` |
|
|
@@ -47,6 +48,12 @@ console.log("Call started:", call.callId);
|
|
|
47
48
|
|
|
48
49
|
Plus the standalone helpers `verifyWebhookSignature` / `verifyWebhookSignatureAsync` (see below).
|
|
49
50
|
|
|
51
|
+
## What's new in 0.4.0
|
|
52
|
+
|
|
53
|
+
- **Breaking**: `client.calls.list()` now returns `Paginated<CallRecord>` — `{ data, total, limit, offset }` — not a raw array. The server always returned this shape; the prior type was wrong. See [CHANGELOG.md](./CHANGELOG.md) for a one-line migration.
|
|
54
|
+
- **New `client.phoneNumbers`** resource — `list()` and `update()` for managing org-owned numbers.
|
|
55
|
+
- **`calls.list()` accepts filters**: `status`, `agentId`, `channel`, `from`, `to`, `search`, `limit`, `offset`.
|
|
56
|
+
|
|
50
57
|
## What's new in 0.3.0
|
|
51
58
|
|
|
52
59
|
- **Auto-retry** on 5xx, 429, and network errors with `Retry-After` honored and exponential backoff. No more hand-rolling retry wrappers.
|
|
@@ -86,6 +93,22 @@ const report = await client.campaigns.report(camp.id);
|
|
|
86
93
|
console.log(report.counts.byStatus);
|
|
87
94
|
```
|
|
88
95
|
|
|
96
|
+
### Listing recent calls with filters
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
const { data, total } = await client.calls.list({
|
|
100
|
+
status: "completed",
|
|
101
|
+
channel: "phone",
|
|
102
|
+
from: "2026-05-01",
|
|
103
|
+
limit: 25,
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
console.log(`Showing ${data.length} of ${total} matching calls`);
|
|
107
|
+
for (const call of data) {
|
|
108
|
+
console.log(call.id, call.durationSeconds, "s", call.disposition);
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
89
112
|
### Wait for a call to finish (without writing a poll loop)
|
|
90
113
|
|
|
91
114
|
```ts
|
package/dist/index.d.mts
CHANGED
|
@@ -15,7 +15,19 @@
|
|
|
15
15
|
* runtime version checks (e.g. logging which SDK build is talking to the
|
|
16
16
|
* API, or feature-detecting against minimum versions in shared code).
|
|
17
17
|
*/
|
|
18
|
-
declare const SDK_VERSION = "0.
|
|
18
|
+
declare const SDK_VERSION = "0.4.0";
|
|
19
|
+
/**
|
|
20
|
+
* Paginated list envelope returned by some endpoints (currently
|
|
21
|
+
* `calls.list`; more list resources will migrate to this shape over
|
|
22
|
+
* future minor versions). Lets consumers build pagination UIs without
|
|
23
|
+
* a second count request.
|
|
24
|
+
*/
|
|
25
|
+
interface Paginated<T> {
|
|
26
|
+
data: T[];
|
|
27
|
+
total: number;
|
|
28
|
+
limit: number;
|
|
29
|
+
offset: number;
|
|
30
|
+
}
|
|
19
31
|
interface OsmtalkOptions {
|
|
20
32
|
apiKey: string;
|
|
21
33
|
baseUrl?: string;
|
|
@@ -45,8 +57,25 @@ interface OsmtalkOptions {
|
|
|
45
57
|
*/
|
|
46
58
|
organizationId?: string;
|
|
47
59
|
}
|
|
48
|
-
|
|
49
|
-
|
|
60
|
+
/** Extra options accepted by paginated list endpoints. */
|
|
61
|
+
interface ListOptions extends RequestOptionsBase {
|
|
62
|
+
limit?: number;
|
|
63
|
+
offset?: number;
|
|
64
|
+
}
|
|
65
|
+
/** Filters accepted by `client.calls.list()`. */
|
|
66
|
+
interface CallListOptions extends ListOptions {
|
|
67
|
+
status?: string;
|
|
68
|
+
agentId?: string;
|
|
69
|
+
channel?: "phone" | "web" | "chat" | "whatsapp_call" | "whatsapp_message" | (string & {});
|
|
70
|
+
/** ISO date (e.g. "2026-05-13"); filters by call started_at ≥ this date. */
|
|
71
|
+
from?: string;
|
|
72
|
+
/** ISO date; filters by call started_at on or before this date (end-of-day). */
|
|
73
|
+
to?: string;
|
|
74
|
+
/** Free-text search across room name + agent name. */
|
|
75
|
+
search?: string;
|
|
76
|
+
}
|
|
77
|
+
/** Internal base — RequestOptions adds idempotencyKey on top. */
|
|
78
|
+
interface RequestOptionsBase {
|
|
50
79
|
/** AbortSignal for caller-side cancellation. Combined with the SDK's timeout signal. */
|
|
51
80
|
signal?: AbortSignal;
|
|
52
81
|
/** Per-call override of the global timeout. */
|
|
@@ -54,6 +83,9 @@ interface RequestOptions {
|
|
|
54
83
|
/** Per-call override of the org ID. */
|
|
55
84
|
organizationId?: string;
|
|
56
85
|
}
|
|
86
|
+
interface RequestOptions extends RequestOptionsBase {
|
|
87
|
+
idempotencyKey?: string;
|
|
88
|
+
}
|
|
57
89
|
interface DynamicVariables {
|
|
58
90
|
[key: string]: string | number | boolean;
|
|
59
91
|
}
|
|
@@ -270,7 +302,20 @@ declare const TERMINAL_CALL_STATUSES: readonly ["completed", "failed", "ended",
|
|
|
270
302
|
declare class CallsResource {
|
|
271
303
|
private readonly http;
|
|
272
304
|
constructor(http: HttpClient);
|
|
273
|
-
|
|
305
|
+
/**
|
|
306
|
+
* List calls. Returns a paginated envelope (NOT a raw array) so you
|
|
307
|
+
* can drive UI pagination without a separate count query.
|
|
308
|
+
*
|
|
309
|
+
* const { data, total, limit, offset } = await client.calls.list({ limit: 50 });
|
|
310
|
+
*
|
|
311
|
+
* Filters supported: `status`, `agentId`, `channel`, `from`, `to`,
|
|
312
|
+
* `search`, plus standard `limit`/`offset`. See {@link CallListOptions}.
|
|
313
|
+
*
|
|
314
|
+
* Breaking change in SDK 0.4.0: prior versions typed this as
|
|
315
|
+
* `Promise<CallRecord[]>` but the server has always returned an
|
|
316
|
+
* envelope. The type now matches reality.
|
|
317
|
+
*/
|
|
318
|
+
list(opts?: CallListOptions): Promise<Paginated<CallRecord>>;
|
|
274
319
|
get(id: string, opts?: RequestOptions): Promise<CallRecord>;
|
|
275
320
|
/**
|
|
276
321
|
* Place an outbound call. Pass `idempotencyKey` so a retry within 24h
|
|
@@ -507,6 +552,36 @@ declare class CampaignsResource {
|
|
|
507
552
|
offset?: number;
|
|
508
553
|
}): Promise<Record<string, unknown>[]>;
|
|
509
554
|
}
|
|
555
|
+
interface PhoneNumberRecord {
|
|
556
|
+
id: string;
|
|
557
|
+
phoneNumber: string;
|
|
558
|
+
name?: string | null;
|
|
559
|
+
countryCode?: string | null;
|
|
560
|
+
inboundAgentId?: string | null;
|
|
561
|
+
outboundAgentId?: string | null;
|
|
562
|
+
/** Joined from the agents table; convenience when rendering UIs. */
|
|
563
|
+
inboundAgentName?: string | null;
|
|
564
|
+
sipProvider?: string | null;
|
|
565
|
+
monthlyRental?: string | null;
|
|
566
|
+
isActive: boolean;
|
|
567
|
+
createdAt?: string | null;
|
|
568
|
+
[key: string]: unknown;
|
|
569
|
+
}
|
|
570
|
+
declare class PhoneNumbersResource {
|
|
571
|
+
private readonly http;
|
|
572
|
+
constructor(http: HttpClient);
|
|
573
|
+
/**
|
|
574
|
+
* List phone numbers owned by your org.
|
|
575
|
+
* Returns a plain array (not yet paginated server-side).
|
|
576
|
+
*/
|
|
577
|
+
list(opts?: RequestOptions): Promise<PhoneNumberRecord[]>;
|
|
578
|
+
/** Update the friendly name and/or agent bindings on a number. */
|
|
579
|
+
update(id: string, input: {
|
|
580
|
+
name?: string;
|
|
581
|
+
inboundAgentId?: string | null;
|
|
582
|
+
outboundAgentId?: string | null;
|
|
583
|
+
}, opts?: RequestOptions): Promise<PhoneNumberRecord>;
|
|
584
|
+
}
|
|
510
585
|
declare class DncResource {
|
|
511
586
|
private readonly http;
|
|
512
587
|
constructor(http: HttpClient);
|
|
@@ -595,6 +670,7 @@ declare class Osmtalk {
|
|
|
595
670
|
readonly agents: AgentsResource;
|
|
596
671
|
readonly calls: CallsResource;
|
|
597
672
|
readonly campaigns: CampaignsResource;
|
|
673
|
+
readonly phoneNumbers: PhoneNumbersResource;
|
|
598
674
|
readonly dnc: DncResource;
|
|
599
675
|
readonly eval: EvalResource;
|
|
600
676
|
readonly settings: SettingsResource;
|
|
@@ -602,4 +678,4 @@ declare class Osmtalk {
|
|
|
602
678
|
constructor(opts: OsmtalkOptions);
|
|
603
679
|
}
|
|
604
680
|
|
|
605
|
-
export { type AgentRecord, type AgentTemplateResult, type AssistantOverride, type CallRecord, type CallStartRequest, type CampaignCreateRequest, type CampaignRecord, type DynamicVariables, type LeadRow, Osmtalk, OsmtalkError, type OsmtalkErrorBody, type OsmtalkOptions, type PresetCostEstimate, type PresetWithCost, type ProviderHealth, type RequestOptions, SDK_VERSION, TERMINAL_CALL_STATUSES, Osmtalk as default, verifyWebhookSignature, verifyWebhookSignatureAsync };
|
|
681
|
+
export { type AgentRecord, type AgentTemplateResult, type AssistantOverride, type CallListOptions, type CallRecord, type CallStartRequest, type CampaignCreateRequest, type CampaignRecord, type DynamicVariables, type LeadRow, type ListOptions, Osmtalk, OsmtalkError, type OsmtalkErrorBody, type OsmtalkOptions, type Paginated, type PhoneNumberRecord, type PresetCostEstimate, type PresetWithCost, type ProviderHealth, type RequestOptions, SDK_VERSION, TERMINAL_CALL_STATUSES, Osmtalk as default, verifyWebhookSignature, verifyWebhookSignatureAsync };
|
package/dist/index.d.ts
CHANGED
|
@@ -15,7 +15,19 @@
|
|
|
15
15
|
* runtime version checks (e.g. logging which SDK build is talking to the
|
|
16
16
|
* API, or feature-detecting against minimum versions in shared code).
|
|
17
17
|
*/
|
|
18
|
-
declare const SDK_VERSION = "0.
|
|
18
|
+
declare const SDK_VERSION = "0.4.0";
|
|
19
|
+
/**
|
|
20
|
+
* Paginated list envelope returned by some endpoints (currently
|
|
21
|
+
* `calls.list`; more list resources will migrate to this shape over
|
|
22
|
+
* future minor versions). Lets consumers build pagination UIs without
|
|
23
|
+
* a second count request.
|
|
24
|
+
*/
|
|
25
|
+
interface Paginated<T> {
|
|
26
|
+
data: T[];
|
|
27
|
+
total: number;
|
|
28
|
+
limit: number;
|
|
29
|
+
offset: number;
|
|
30
|
+
}
|
|
19
31
|
interface OsmtalkOptions {
|
|
20
32
|
apiKey: string;
|
|
21
33
|
baseUrl?: string;
|
|
@@ -45,8 +57,25 @@ interface OsmtalkOptions {
|
|
|
45
57
|
*/
|
|
46
58
|
organizationId?: string;
|
|
47
59
|
}
|
|
48
|
-
|
|
49
|
-
|
|
60
|
+
/** Extra options accepted by paginated list endpoints. */
|
|
61
|
+
interface ListOptions extends RequestOptionsBase {
|
|
62
|
+
limit?: number;
|
|
63
|
+
offset?: number;
|
|
64
|
+
}
|
|
65
|
+
/** Filters accepted by `client.calls.list()`. */
|
|
66
|
+
interface CallListOptions extends ListOptions {
|
|
67
|
+
status?: string;
|
|
68
|
+
agentId?: string;
|
|
69
|
+
channel?: "phone" | "web" | "chat" | "whatsapp_call" | "whatsapp_message" | (string & {});
|
|
70
|
+
/** ISO date (e.g. "2026-05-13"); filters by call started_at ≥ this date. */
|
|
71
|
+
from?: string;
|
|
72
|
+
/** ISO date; filters by call started_at on or before this date (end-of-day). */
|
|
73
|
+
to?: string;
|
|
74
|
+
/** Free-text search across room name + agent name. */
|
|
75
|
+
search?: string;
|
|
76
|
+
}
|
|
77
|
+
/** Internal base — RequestOptions adds idempotencyKey on top. */
|
|
78
|
+
interface RequestOptionsBase {
|
|
50
79
|
/** AbortSignal for caller-side cancellation. Combined with the SDK's timeout signal. */
|
|
51
80
|
signal?: AbortSignal;
|
|
52
81
|
/** Per-call override of the global timeout. */
|
|
@@ -54,6 +83,9 @@ interface RequestOptions {
|
|
|
54
83
|
/** Per-call override of the org ID. */
|
|
55
84
|
organizationId?: string;
|
|
56
85
|
}
|
|
86
|
+
interface RequestOptions extends RequestOptionsBase {
|
|
87
|
+
idempotencyKey?: string;
|
|
88
|
+
}
|
|
57
89
|
interface DynamicVariables {
|
|
58
90
|
[key: string]: string | number | boolean;
|
|
59
91
|
}
|
|
@@ -270,7 +302,20 @@ declare const TERMINAL_CALL_STATUSES: readonly ["completed", "failed", "ended",
|
|
|
270
302
|
declare class CallsResource {
|
|
271
303
|
private readonly http;
|
|
272
304
|
constructor(http: HttpClient);
|
|
273
|
-
|
|
305
|
+
/**
|
|
306
|
+
* List calls. Returns a paginated envelope (NOT a raw array) so you
|
|
307
|
+
* can drive UI pagination without a separate count query.
|
|
308
|
+
*
|
|
309
|
+
* const { data, total, limit, offset } = await client.calls.list({ limit: 50 });
|
|
310
|
+
*
|
|
311
|
+
* Filters supported: `status`, `agentId`, `channel`, `from`, `to`,
|
|
312
|
+
* `search`, plus standard `limit`/`offset`. See {@link CallListOptions}.
|
|
313
|
+
*
|
|
314
|
+
* Breaking change in SDK 0.4.0: prior versions typed this as
|
|
315
|
+
* `Promise<CallRecord[]>` but the server has always returned an
|
|
316
|
+
* envelope. The type now matches reality.
|
|
317
|
+
*/
|
|
318
|
+
list(opts?: CallListOptions): Promise<Paginated<CallRecord>>;
|
|
274
319
|
get(id: string, opts?: RequestOptions): Promise<CallRecord>;
|
|
275
320
|
/**
|
|
276
321
|
* Place an outbound call. Pass `idempotencyKey` so a retry within 24h
|
|
@@ -507,6 +552,36 @@ declare class CampaignsResource {
|
|
|
507
552
|
offset?: number;
|
|
508
553
|
}): Promise<Record<string, unknown>[]>;
|
|
509
554
|
}
|
|
555
|
+
interface PhoneNumberRecord {
|
|
556
|
+
id: string;
|
|
557
|
+
phoneNumber: string;
|
|
558
|
+
name?: string | null;
|
|
559
|
+
countryCode?: string | null;
|
|
560
|
+
inboundAgentId?: string | null;
|
|
561
|
+
outboundAgentId?: string | null;
|
|
562
|
+
/** Joined from the agents table; convenience when rendering UIs. */
|
|
563
|
+
inboundAgentName?: string | null;
|
|
564
|
+
sipProvider?: string | null;
|
|
565
|
+
monthlyRental?: string | null;
|
|
566
|
+
isActive: boolean;
|
|
567
|
+
createdAt?: string | null;
|
|
568
|
+
[key: string]: unknown;
|
|
569
|
+
}
|
|
570
|
+
declare class PhoneNumbersResource {
|
|
571
|
+
private readonly http;
|
|
572
|
+
constructor(http: HttpClient);
|
|
573
|
+
/**
|
|
574
|
+
* List phone numbers owned by your org.
|
|
575
|
+
* Returns a plain array (not yet paginated server-side).
|
|
576
|
+
*/
|
|
577
|
+
list(opts?: RequestOptions): Promise<PhoneNumberRecord[]>;
|
|
578
|
+
/** Update the friendly name and/or agent bindings on a number. */
|
|
579
|
+
update(id: string, input: {
|
|
580
|
+
name?: string;
|
|
581
|
+
inboundAgentId?: string | null;
|
|
582
|
+
outboundAgentId?: string | null;
|
|
583
|
+
}, opts?: RequestOptions): Promise<PhoneNumberRecord>;
|
|
584
|
+
}
|
|
510
585
|
declare class DncResource {
|
|
511
586
|
private readonly http;
|
|
512
587
|
constructor(http: HttpClient);
|
|
@@ -595,6 +670,7 @@ declare class Osmtalk {
|
|
|
595
670
|
readonly agents: AgentsResource;
|
|
596
671
|
readonly calls: CallsResource;
|
|
597
672
|
readonly campaigns: CampaignsResource;
|
|
673
|
+
readonly phoneNumbers: PhoneNumbersResource;
|
|
598
674
|
readonly dnc: DncResource;
|
|
599
675
|
readonly eval: EvalResource;
|
|
600
676
|
readonly settings: SettingsResource;
|
|
@@ -602,4 +678,4 @@ declare class Osmtalk {
|
|
|
602
678
|
constructor(opts: OsmtalkOptions);
|
|
603
679
|
}
|
|
604
680
|
|
|
605
|
-
export { type AgentRecord, type AgentTemplateResult, type AssistantOverride, type CallRecord, type CallStartRequest, type CampaignCreateRequest, type CampaignRecord, type DynamicVariables, type LeadRow, Osmtalk, OsmtalkError, type OsmtalkErrorBody, type OsmtalkOptions, type PresetCostEstimate, type PresetWithCost, type ProviderHealth, type RequestOptions, SDK_VERSION, TERMINAL_CALL_STATUSES, Osmtalk as default, verifyWebhookSignature, verifyWebhookSignatureAsync };
|
|
681
|
+
export { type AgentRecord, type AgentTemplateResult, type AssistantOverride, type CallListOptions, type CallRecord, type CallStartRequest, type CampaignCreateRequest, type CampaignRecord, type DynamicVariables, type LeadRow, type ListOptions, Osmtalk, OsmtalkError, type OsmtalkErrorBody, type OsmtalkOptions, type Paginated, type PhoneNumberRecord, type PresetCostEstimate, type PresetWithCost, type ProviderHealth, type RequestOptions, SDK_VERSION, TERMINAL_CALL_STATUSES, Osmtalk as default, verifyWebhookSignature, verifyWebhookSignatureAsync };
|
package/dist/index.js
CHANGED
|
@@ -29,7 +29,7 @@ __export(index_exports, {
|
|
|
29
29
|
verifyWebhookSignatureAsync: () => verifyWebhookSignatureAsync
|
|
30
30
|
});
|
|
31
31
|
module.exports = __toCommonJS(index_exports);
|
|
32
|
-
var SDK_VERSION = "0.
|
|
32
|
+
var SDK_VERSION = "0.4.0";
|
|
33
33
|
var OsmtalkError = class extends Error {
|
|
34
34
|
status;
|
|
35
35
|
body;
|
|
@@ -273,8 +273,38 @@ var CallsResource = class {
|
|
|
273
273
|
this.http = http;
|
|
274
274
|
}
|
|
275
275
|
http;
|
|
276
|
+
/**
|
|
277
|
+
* List calls. Returns a paginated envelope (NOT a raw array) so you
|
|
278
|
+
* can drive UI pagination without a separate count query.
|
|
279
|
+
*
|
|
280
|
+
* const { data, total, limit, offset } = await client.calls.list({ limit: 50 });
|
|
281
|
+
*
|
|
282
|
+
* Filters supported: `status`, `agentId`, `channel`, `from`, `to`,
|
|
283
|
+
* `search`, plus standard `limit`/`offset`. See {@link CallListOptions}.
|
|
284
|
+
*
|
|
285
|
+
* Breaking change in SDK 0.4.0: prior versions typed this as
|
|
286
|
+
* `Promise<CallRecord[]>` but the server has always returned an
|
|
287
|
+
* envelope. The type now matches reality.
|
|
288
|
+
*/
|
|
276
289
|
list(opts) {
|
|
277
|
-
|
|
290
|
+
const qs = new URLSearchParams();
|
|
291
|
+
if (opts?.status) qs.set("status", opts.status);
|
|
292
|
+
if (opts?.agentId) qs.set("agentId", opts.agentId);
|
|
293
|
+
if (opts?.channel) qs.set("channel", String(opts.channel));
|
|
294
|
+
if (opts?.from) qs.set("from", opts.from);
|
|
295
|
+
if (opts?.to) qs.set("to", opts.to);
|
|
296
|
+
if (opts?.search) qs.set("search", opts.search);
|
|
297
|
+
if (opts?.limit !== void 0) qs.set("limit", String(opts.limit));
|
|
298
|
+
if (opts?.offset !== void 0) qs.set("offset", String(opts.offset));
|
|
299
|
+
const suffix = qs.toString() ? `?${qs}` : "";
|
|
300
|
+
return this.http.request(
|
|
301
|
+
"GET",
|
|
302
|
+
`/api/calls${suffix}`,
|
|
303
|
+
void 0,
|
|
304
|
+
void 0,
|
|
305
|
+
void 0,
|
|
306
|
+
opts
|
|
307
|
+
);
|
|
278
308
|
}
|
|
279
309
|
get(id, opts) {
|
|
280
310
|
return this.http.request("GET", `/api/calls/${id}`, void 0, void 0, void 0, opts);
|
|
@@ -519,6 +549,37 @@ var CampaignsResource = class {
|
|
|
519
549
|
return this.http.request("GET", `/api/campaigns/${id}/leads${suffix}`);
|
|
520
550
|
}
|
|
521
551
|
};
|
|
552
|
+
var PhoneNumbersResource = class {
|
|
553
|
+
constructor(http) {
|
|
554
|
+
this.http = http;
|
|
555
|
+
}
|
|
556
|
+
http;
|
|
557
|
+
/**
|
|
558
|
+
* List phone numbers owned by your org.
|
|
559
|
+
* Returns a plain array (not yet paginated server-side).
|
|
560
|
+
*/
|
|
561
|
+
list(opts) {
|
|
562
|
+
return this.http.request(
|
|
563
|
+
"GET",
|
|
564
|
+
"/api/phone-numbers",
|
|
565
|
+
void 0,
|
|
566
|
+
void 0,
|
|
567
|
+
void 0,
|
|
568
|
+
opts
|
|
569
|
+
);
|
|
570
|
+
}
|
|
571
|
+
/** Update the friendly name and/or agent bindings on a number. */
|
|
572
|
+
update(id, input, opts) {
|
|
573
|
+
return this.http.request(
|
|
574
|
+
"PUT",
|
|
575
|
+
`/api/phone-numbers/${id}`,
|
|
576
|
+
input,
|
|
577
|
+
void 0,
|
|
578
|
+
opts?.idempotencyKey,
|
|
579
|
+
opts
|
|
580
|
+
);
|
|
581
|
+
}
|
|
582
|
+
};
|
|
522
583
|
var DncResource = class {
|
|
523
584
|
constructor(http) {
|
|
524
585
|
this.http = http;
|
|
@@ -602,6 +663,7 @@ var Osmtalk = class {
|
|
|
602
663
|
agents;
|
|
603
664
|
calls;
|
|
604
665
|
campaigns;
|
|
666
|
+
phoneNumbers;
|
|
605
667
|
dnc;
|
|
606
668
|
eval;
|
|
607
669
|
settings;
|
|
@@ -611,6 +673,7 @@ var Osmtalk = class {
|
|
|
611
673
|
this.agents = new AgentsResource(http);
|
|
612
674
|
this.calls = new CallsResource(http);
|
|
613
675
|
this.campaigns = new CampaignsResource(http);
|
|
676
|
+
this.phoneNumbers = new PhoneNumbersResource(http);
|
|
614
677
|
this.dnc = new DncResource(http);
|
|
615
678
|
this.eval = new EvalResource(http);
|
|
616
679
|
this.settings = new SettingsResource(http);
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
var SDK_VERSION = "0.
|
|
2
|
+
var SDK_VERSION = "0.4.0";
|
|
3
3
|
var OsmtalkError = class extends Error {
|
|
4
4
|
status;
|
|
5
5
|
body;
|
|
@@ -243,8 +243,38 @@ var CallsResource = class {
|
|
|
243
243
|
this.http = http;
|
|
244
244
|
}
|
|
245
245
|
http;
|
|
246
|
+
/**
|
|
247
|
+
* List calls. Returns a paginated envelope (NOT a raw array) so you
|
|
248
|
+
* can drive UI pagination without a separate count query.
|
|
249
|
+
*
|
|
250
|
+
* const { data, total, limit, offset } = await client.calls.list({ limit: 50 });
|
|
251
|
+
*
|
|
252
|
+
* Filters supported: `status`, `agentId`, `channel`, `from`, `to`,
|
|
253
|
+
* `search`, plus standard `limit`/`offset`. See {@link CallListOptions}.
|
|
254
|
+
*
|
|
255
|
+
* Breaking change in SDK 0.4.0: prior versions typed this as
|
|
256
|
+
* `Promise<CallRecord[]>` but the server has always returned an
|
|
257
|
+
* envelope. The type now matches reality.
|
|
258
|
+
*/
|
|
246
259
|
list(opts) {
|
|
247
|
-
|
|
260
|
+
const qs = new URLSearchParams();
|
|
261
|
+
if (opts?.status) qs.set("status", opts.status);
|
|
262
|
+
if (opts?.agentId) qs.set("agentId", opts.agentId);
|
|
263
|
+
if (opts?.channel) qs.set("channel", String(opts.channel));
|
|
264
|
+
if (opts?.from) qs.set("from", opts.from);
|
|
265
|
+
if (opts?.to) qs.set("to", opts.to);
|
|
266
|
+
if (opts?.search) qs.set("search", opts.search);
|
|
267
|
+
if (opts?.limit !== void 0) qs.set("limit", String(opts.limit));
|
|
268
|
+
if (opts?.offset !== void 0) qs.set("offset", String(opts.offset));
|
|
269
|
+
const suffix = qs.toString() ? `?${qs}` : "";
|
|
270
|
+
return this.http.request(
|
|
271
|
+
"GET",
|
|
272
|
+
`/api/calls${suffix}`,
|
|
273
|
+
void 0,
|
|
274
|
+
void 0,
|
|
275
|
+
void 0,
|
|
276
|
+
opts
|
|
277
|
+
);
|
|
248
278
|
}
|
|
249
279
|
get(id, opts) {
|
|
250
280
|
return this.http.request("GET", `/api/calls/${id}`, void 0, void 0, void 0, opts);
|
|
@@ -489,6 +519,37 @@ var CampaignsResource = class {
|
|
|
489
519
|
return this.http.request("GET", `/api/campaigns/${id}/leads${suffix}`);
|
|
490
520
|
}
|
|
491
521
|
};
|
|
522
|
+
var PhoneNumbersResource = class {
|
|
523
|
+
constructor(http) {
|
|
524
|
+
this.http = http;
|
|
525
|
+
}
|
|
526
|
+
http;
|
|
527
|
+
/**
|
|
528
|
+
* List phone numbers owned by your org.
|
|
529
|
+
* Returns a plain array (not yet paginated server-side).
|
|
530
|
+
*/
|
|
531
|
+
list(opts) {
|
|
532
|
+
return this.http.request(
|
|
533
|
+
"GET",
|
|
534
|
+
"/api/phone-numbers",
|
|
535
|
+
void 0,
|
|
536
|
+
void 0,
|
|
537
|
+
void 0,
|
|
538
|
+
opts
|
|
539
|
+
);
|
|
540
|
+
}
|
|
541
|
+
/** Update the friendly name and/or agent bindings on a number. */
|
|
542
|
+
update(id, input, opts) {
|
|
543
|
+
return this.http.request(
|
|
544
|
+
"PUT",
|
|
545
|
+
`/api/phone-numbers/${id}`,
|
|
546
|
+
input,
|
|
547
|
+
void 0,
|
|
548
|
+
opts?.idempotencyKey,
|
|
549
|
+
opts
|
|
550
|
+
);
|
|
551
|
+
}
|
|
552
|
+
};
|
|
492
553
|
var DncResource = class {
|
|
493
554
|
constructor(http) {
|
|
494
555
|
this.http = http;
|
|
@@ -572,6 +633,7 @@ var Osmtalk = class {
|
|
|
572
633
|
agents;
|
|
573
634
|
calls;
|
|
574
635
|
campaigns;
|
|
636
|
+
phoneNumbers;
|
|
575
637
|
dnc;
|
|
576
638
|
eval;
|
|
577
639
|
settings;
|
|
@@ -581,6 +643,7 @@ var Osmtalk = class {
|
|
|
581
643
|
this.agents = new AgentsResource(http);
|
|
582
644
|
this.calls = new CallsResource(http);
|
|
583
645
|
this.campaigns = new CampaignsResource(http);
|
|
646
|
+
this.phoneNumbers = new PhoneNumbersResource(http);
|
|
584
647
|
this.dnc = new DncResource(http);
|
|
585
648
|
this.eval = new EvalResource(http);
|
|
586
649
|
this.settings = new SettingsResource(http);
|