phonic 0.30.28 → 0.30.29

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.
Files changed (34) hide show
  1. package/dist/cjs/Client.js +2 -2
  2. package/dist/cjs/api/resources/agents/client/Client.d.ts +42 -0
  3. package/dist/cjs/api/resources/agents/client/Client.js +174 -0
  4. package/dist/cjs/api/resources/agents/client/requests/AgentsAddCustomPhoneNumberRequest.d.ts +16 -0
  5. package/dist/cjs/api/resources/agents/client/requests/AgentsAddCustomPhoneNumberRequest.js +5 -0
  6. package/dist/cjs/api/resources/agents/client/requests/AgentsRemoveCustomPhoneNumberRequest.d.ts +16 -0
  7. package/dist/cjs/api/resources/agents/client/requests/AgentsRemoveCustomPhoneNumberRequest.js +5 -0
  8. package/dist/cjs/api/resources/agents/client/requests/index.d.ts +2 -0
  9. package/dist/cjs/api/resources/agents/types/AgentsAddCustomPhoneNumberResponse.d.ts +6 -0
  10. package/dist/cjs/api/resources/agents/types/AgentsAddCustomPhoneNumberResponse.js +5 -0
  11. package/dist/cjs/api/resources/agents/types/AgentsRemoveCustomPhoneNumberResponse.d.ts +6 -0
  12. package/dist/cjs/api/resources/agents/types/AgentsRemoveCustomPhoneNumberResponse.js +5 -0
  13. package/dist/cjs/api/resources/agents/types/index.d.ts +2 -0
  14. package/dist/cjs/api/resources/agents/types/index.js +2 -0
  15. package/dist/cjs/version.d.ts +1 -1
  16. package/dist/cjs/version.js +1 -1
  17. package/dist/esm/Client.mjs +2 -2
  18. package/dist/esm/api/resources/agents/client/Client.d.mts +42 -0
  19. package/dist/esm/api/resources/agents/client/Client.mjs +174 -0
  20. package/dist/esm/api/resources/agents/client/requests/AgentsAddCustomPhoneNumberRequest.d.mts +16 -0
  21. package/dist/esm/api/resources/agents/client/requests/AgentsAddCustomPhoneNumberRequest.mjs +4 -0
  22. package/dist/esm/api/resources/agents/client/requests/AgentsRemoveCustomPhoneNumberRequest.d.mts +16 -0
  23. package/dist/esm/api/resources/agents/client/requests/AgentsRemoveCustomPhoneNumberRequest.mjs +4 -0
  24. package/dist/esm/api/resources/agents/client/requests/index.d.mts +2 -0
  25. package/dist/esm/api/resources/agents/types/AgentsAddCustomPhoneNumberResponse.d.mts +6 -0
  26. package/dist/esm/api/resources/agents/types/AgentsAddCustomPhoneNumberResponse.mjs +4 -0
  27. package/dist/esm/api/resources/agents/types/AgentsRemoveCustomPhoneNumberResponse.d.mts +6 -0
  28. package/dist/esm/api/resources/agents/types/AgentsRemoveCustomPhoneNumberResponse.mjs +4 -0
  29. package/dist/esm/api/resources/agents/types/index.d.mts +2 -0
  30. package/dist/esm/api/resources/agents/types/index.mjs +2 -0
  31. package/dist/esm/version.d.mts +1 -1
  32. package/dist/esm/version.mjs +1 -1
  33. package/package.json +1 -1
  34. package/reference.md +148 -0
@@ -51,8 +51,8 @@ class PhonicClient {
51
51
  this._options = Object.assign(Object.assign({}, _options), { headers: (0, headers_js_1.mergeHeaders)({
52
52
  "X-Fern-Language": "JavaScript",
53
53
  "X-Fern-SDK-Name": "phonic",
54
- "X-Fern-SDK-Version": "0.30.28",
55
- "User-Agent": "phonic/0.30.28",
54
+ "X-Fern-SDK-Version": "0.30.29",
55
+ "User-Agent": "phonic/0.30.29",
56
56
  "X-Fern-Runtime": core.RUNTIME.type,
57
57
  "X-Fern-Runtime-Version": core.RUNTIME.version,
58
58
  }, _options === null || _options === void 0 ? void 0 : _options.headers) });
@@ -217,5 +217,47 @@ export declare class Agents {
217
217
  */
218
218
  update(nameOrId: string, request: Phonic.UpdateAgentRequest, requestOptions?: Agents.RequestOptions): core.HttpResponsePromise<Phonic.AgentsUpdateResponse>;
219
219
  private __update;
220
+ /**
221
+ * Adds a custom phone number to an agent. The user must configure their SIP trunk to point to Phonic's SIP server.
222
+ *
223
+ * @param {string} nameOrId - The name or the ID of the agent.
224
+ * @param {Phonic.AgentsAddCustomPhoneNumberRequest} request
225
+ * @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
226
+ *
227
+ * @throws {@link Phonic.BadRequestError}
228
+ * @throws {@link Phonic.UnauthorizedError}
229
+ * @throws {@link Phonic.ForbiddenError}
230
+ * @throws {@link Phonic.NotFoundError}
231
+ * @throws {@link Phonic.ConflictError}
232
+ *
233
+ * @example
234
+ * await client.agents.addCustomPhoneNumber("nameOrId", {
235
+ * project: "main",
236
+ * phone_number: "+15551234567"
237
+ * })
238
+ */
239
+ addCustomPhoneNumber(nameOrId: string, request: Phonic.AgentsAddCustomPhoneNumberRequest, requestOptions?: Agents.RequestOptions): core.HttpResponsePromise<Phonic.AgentsAddCustomPhoneNumberResponse>;
240
+ private __addCustomPhoneNumber;
241
+ /**
242
+ * Removes a custom phone number from an agent.
243
+ *
244
+ * @param {string} nameOrId - The name or the ID of the agent.
245
+ * @param {Phonic.AgentsRemoveCustomPhoneNumberRequest} request
246
+ * @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
247
+ *
248
+ * @throws {@link Phonic.BadRequestError}
249
+ * @throws {@link Phonic.UnauthorizedError}
250
+ * @throws {@link Phonic.ForbiddenError}
251
+ * @throws {@link Phonic.NotFoundError}
252
+ * @throws {@link Phonic.ConflictError}
253
+ *
254
+ * @example
255
+ * await client.agents.removeCustomPhoneNumber("nameOrId", {
256
+ * project: "main",
257
+ * phone_number: "+15551234567"
258
+ * })
259
+ */
260
+ removeCustomPhoneNumber(nameOrId: string, request: Phonic.AgentsRemoveCustomPhoneNumberRequest, requestOptions?: Agents.RequestOptions): core.HttpResponsePromise<Phonic.AgentsRemoveCustomPhoneNumberResponse>;
261
+ private __removeCustomPhoneNumber;
220
262
  protected _getAuthorizationHeader(): Promise<string | undefined>;
221
263
  }
@@ -592,6 +592,180 @@ class Agents {
592
592
  }
593
593
  });
594
594
  }
595
+ /**
596
+ * Adds a custom phone number to an agent. The user must configure their SIP trunk to point to Phonic's SIP server.
597
+ *
598
+ * @param {string} nameOrId - The name or the ID of the agent.
599
+ * @param {Phonic.AgentsAddCustomPhoneNumberRequest} request
600
+ * @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
601
+ *
602
+ * @throws {@link Phonic.BadRequestError}
603
+ * @throws {@link Phonic.UnauthorizedError}
604
+ * @throws {@link Phonic.ForbiddenError}
605
+ * @throws {@link Phonic.NotFoundError}
606
+ * @throws {@link Phonic.ConflictError}
607
+ *
608
+ * @example
609
+ * await client.agents.addCustomPhoneNumber("nameOrId", {
610
+ * project: "main",
611
+ * phone_number: "+15551234567"
612
+ * })
613
+ */
614
+ addCustomPhoneNumber(nameOrId, request, requestOptions) {
615
+ return core.HttpResponsePromise.fromPromise(this.__addCustomPhoneNumber(nameOrId, request, requestOptions));
616
+ }
617
+ __addCustomPhoneNumber(nameOrId, request, requestOptions) {
618
+ return __awaiter(this, void 0, void 0, function* () {
619
+ var _a, _b, _c, _d;
620
+ const { project } = request, _body = __rest(request, ["project"]);
621
+ const _queryParams = {};
622
+ if (project != null) {
623
+ _queryParams["project"] = project;
624
+ }
625
+ let _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
626
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
627
+ url: core.url.join((_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : ((_d = (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.PhonicEnvironment.Default)
628
+ .base, `agents/${encodeURIComponent(nameOrId)}/add-custom-phone-number`),
629
+ method: "POST",
630
+ headers: _headers,
631
+ contentType: "application/json",
632
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
633
+ requestType: "json",
634
+ body: _body,
635
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
636
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
637
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
638
+ });
639
+ if (_response.ok) {
640
+ return {
641
+ data: _response.body,
642
+ rawResponse: _response.rawResponse,
643
+ };
644
+ }
645
+ if (_response.error.reason === "status-code") {
646
+ switch (_response.error.statusCode) {
647
+ case 400:
648
+ throw new Phonic.BadRequestError(_response.error.body, _response.rawResponse);
649
+ case 401:
650
+ throw new Phonic.UnauthorizedError(_response.error.body, _response.rawResponse);
651
+ case 403:
652
+ throw new Phonic.ForbiddenError(_response.error.body, _response.rawResponse);
653
+ case 404:
654
+ throw new Phonic.NotFoundError(_response.error.body, _response.rawResponse);
655
+ case 409:
656
+ throw new Phonic.ConflictError(_response.error.body, _response.rawResponse);
657
+ default:
658
+ throw new errors.PhonicError({
659
+ statusCode: _response.error.statusCode,
660
+ body: _response.error.body,
661
+ rawResponse: _response.rawResponse,
662
+ });
663
+ }
664
+ }
665
+ switch (_response.error.reason) {
666
+ case "non-json":
667
+ throw new errors.PhonicError({
668
+ statusCode: _response.error.statusCode,
669
+ body: _response.error.rawBody,
670
+ rawResponse: _response.rawResponse,
671
+ });
672
+ case "timeout":
673
+ throw new errors.PhonicTimeoutError("Timeout exceeded when calling POST /agents/{nameOrId}/add-custom-phone-number.");
674
+ case "unknown":
675
+ throw new errors.PhonicError({
676
+ message: _response.error.errorMessage,
677
+ rawResponse: _response.rawResponse,
678
+ });
679
+ }
680
+ });
681
+ }
682
+ /**
683
+ * Removes a custom phone number from an agent.
684
+ *
685
+ * @param {string} nameOrId - The name or the ID of the agent.
686
+ * @param {Phonic.AgentsRemoveCustomPhoneNumberRequest} request
687
+ * @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
688
+ *
689
+ * @throws {@link Phonic.BadRequestError}
690
+ * @throws {@link Phonic.UnauthorizedError}
691
+ * @throws {@link Phonic.ForbiddenError}
692
+ * @throws {@link Phonic.NotFoundError}
693
+ * @throws {@link Phonic.ConflictError}
694
+ *
695
+ * @example
696
+ * await client.agents.removeCustomPhoneNumber("nameOrId", {
697
+ * project: "main",
698
+ * phone_number: "+15551234567"
699
+ * })
700
+ */
701
+ removeCustomPhoneNumber(nameOrId, request, requestOptions) {
702
+ return core.HttpResponsePromise.fromPromise(this.__removeCustomPhoneNumber(nameOrId, request, requestOptions));
703
+ }
704
+ __removeCustomPhoneNumber(nameOrId, request, requestOptions) {
705
+ return __awaiter(this, void 0, void 0, function* () {
706
+ var _a, _b, _c, _d;
707
+ const { project } = request, _body = __rest(request, ["project"]);
708
+ const _queryParams = {};
709
+ if (project != null) {
710
+ _queryParams["project"] = project;
711
+ }
712
+ let _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
713
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
714
+ url: core.url.join((_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : ((_d = (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.PhonicEnvironment.Default)
715
+ .base, `agents/${encodeURIComponent(nameOrId)}/remove-custom-phone-number`),
716
+ method: "POST",
717
+ headers: _headers,
718
+ contentType: "application/json",
719
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
720
+ requestType: "json",
721
+ body: _body,
722
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
723
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
724
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
725
+ });
726
+ if (_response.ok) {
727
+ return {
728
+ data: _response.body,
729
+ rawResponse: _response.rawResponse,
730
+ };
731
+ }
732
+ if (_response.error.reason === "status-code") {
733
+ switch (_response.error.statusCode) {
734
+ case 400:
735
+ throw new Phonic.BadRequestError(_response.error.body, _response.rawResponse);
736
+ case 401:
737
+ throw new Phonic.UnauthorizedError(_response.error.body, _response.rawResponse);
738
+ case 403:
739
+ throw new Phonic.ForbiddenError(_response.error.body, _response.rawResponse);
740
+ case 404:
741
+ throw new Phonic.NotFoundError(_response.error.body, _response.rawResponse);
742
+ case 409:
743
+ throw new Phonic.ConflictError(_response.error.body, _response.rawResponse);
744
+ default:
745
+ throw new errors.PhonicError({
746
+ statusCode: _response.error.statusCode,
747
+ body: _response.error.body,
748
+ rawResponse: _response.rawResponse,
749
+ });
750
+ }
751
+ }
752
+ switch (_response.error.reason) {
753
+ case "non-json":
754
+ throw new errors.PhonicError({
755
+ statusCode: _response.error.statusCode,
756
+ body: _response.error.rawBody,
757
+ rawResponse: _response.rawResponse,
758
+ });
759
+ case "timeout":
760
+ throw new errors.PhonicTimeoutError("Timeout exceeded when calling POST /agents/{nameOrId}/remove-custom-phone-number.");
761
+ case "unknown":
762
+ throw new errors.PhonicError({
763
+ message: _response.error.errorMessage,
764
+ rawResponse: _response.rawResponse,
765
+ });
766
+ }
767
+ });
768
+ }
595
769
  _getAuthorizationHeader() {
596
770
  return __awaiter(this, void 0, void 0, function* () {
597
771
  var _a;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ /**
5
+ * @example
6
+ * {
7
+ * project: "main",
8
+ * phone_number: "+15551234567"
9
+ * }
10
+ */
11
+ export interface AgentsAddCustomPhoneNumberRequest {
12
+ /** The name of the project containing the agent. Only used when `nameOrId` is a name. */
13
+ project?: string;
14
+ /** The E.164 formatted phone number to add (e.g., "+15551234567"). */
15
+ phone_number: string;
16
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,16 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ /**
5
+ * @example
6
+ * {
7
+ * project: "main",
8
+ * phone_number: "+15551234567"
9
+ * }
10
+ */
11
+ export interface AgentsRemoveCustomPhoneNumberRequest {
12
+ /** The name of the project containing the agent. Only used when `nameOrId` is a name. */
13
+ project?: string;
14
+ /** The E.164 formatted phone number to remove (e.g., "+15551234567"). */
15
+ phone_number: string;
16
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -4,3 +4,5 @@ export { type UpsertAgentRequest } from "./UpsertAgentRequest.js";
4
4
  export { type AgentsGetRequest } from "./AgentsGetRequest.js";
5
5
  export { type AgentsDeleteRequest } from "./AgentsDeleteRequest.js";
6
6
  export { type UpdateAgentRequest } from "./UpdateAgentRequest.js";
7
+ export { type AgentsAddCustomPhoneNumberRequest } from "./AgentsAddCustomPhoneNumberRequest.js";
8
+ export { type AgentsRemoveCustomPhoneNumberRequest } from "./AgentsRemoveCustomPhoneNumberRequest.js";
@@ -0,0 +1,6 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export interface AgentsAddCustomPhoneNumberResponse {
5
+ success: boolean;
6
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export interface AgentsRemoveCustomPhoneNumberResponse {
5
+ success: boolean;
6
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -4,3 +4,5 @@ export * from "./AgentsUpsertResponse.js";
4
4
  export * from "./AgentsGetResponse.js";
5
5
  export * from "./AgentsDeleteResponse.js";
6
6
  export * from "./AgentsUpdateResponse.js";
7
+ export * from "./AgentsAddCustomPhoneNumberResponse.js";
8
+ export * from "./AgentsRemoveCustomPhoneNumberResponse.js";
@@ -20,3 +20,5 @@ __exportStar(require("./AgentsUpsertResponse.js"), exports);
20
20
  __exportStar(require("./AgentsGetResponse.js"), exports);
21
21
  __exportStar(require("./AgentsDeleteResponse.js"), exports);
22
22
  __exportStar(require("./AgentsUpdateResponse.js"), exports);
23
+ __exportStar(require("./AgentsAddCustomPhoneNumberResponse.js"), exports);
24
+ __exportStar(require("./AgentsRemoveCustomPhoneNumberResponse.js"), exports);
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.30.28";
1
+ export declare const SDK_VERSION = "0.30.29";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = "0.30.28";
4
+ exports.SDK_VERSION = "0.30.29";
@@ -15,8 +15,8 @@ export class PhonicClient {
15
15
  this._options = Object.assign(Object.assign({}, _options), { headers: mergeHeaders({
16
16
  "X-Fern-Language": "JavaScript",
17
17
  "X-Fern-SDK-Name": "phonic",
18
- "X-Fern-SDK-Version": "0.30.28",
19
- "User-Agent": "phonic/0.30.28",
18
+ "X-Fern-SDK-Version": "0.30.29",
19
+ "User-Agent": "phonic/0.30.29",
20
20
  "X-Fern-Runtime": core.RUNTIME.type,
21
21
  "X-Fern-Runtime-Version": core.RUNTIME.version,
22
22
  }, _options === null || _options === void 0 ? void 0 : _options.headers) });
@@ -217,5 +217,47 @@ export declare class Agents {
217
217
  */
218
218
  update(nameOrId: string, request: Phonic.UpdateAgentRequest, requestOptions?: Agents.RequestOptions): core.HttpResponsePromise<Phonic.AgentsUpdateResponse>;
219
219
  private __update;
220
+ /**
221
+ * Adds a custom phone number to an agent. The user must configure their SIP trunk to point to Phonic's SIP server.
222
+ *
223
+ * @param {string} nameOrId - The name or the ID of the agent.
224
+ * @param {Phonic.AgentsAddCustomPhoneNumberRequest} request
225
+ * @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
226
+ *
227
+ * @throws {@link Phonic.BadRequestError}
228
+ * @throws {@link Phonic.UnauthorizedError}
229
+ * @throws {@link Phonic.ForbiddenError}
230
+ * @throws {@link Phonic.NotFoundError}
231
+ * @throws {@link Phonic.ConflictError}
232
+ *
233
+ * @example
234
+ * await client.agents.addCustomPhoneNumber("nameOrId", {
235
+ * project: "main",
236
+ * phone_number: "+15551234567"
237
+ * })
238
+ */
239
+ addCustomPhoneNumber(nameOrId: string, request: Phonic.AgentsAddCustomPhoneNumberRequest, requestOptions?: Agents.RequestOptions): core.HttpResponsePromise<Phonic.AgentsAddCustomPhoneNumberResponse>;
240
+ private __addCustomPhoneNumber;
241
+ /**
242
+ * Removes a custom phone number from an agent.
243
+ *
244
+ * @param {string} nameOrId - The name or the ID of the agent.
245
+ * @param {Phonic.AgentsRemoveCustomPhoneNumberRequest} request
246
+ * @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
247
+ *
248
+ * @throws {@link Phonic.BadRequestError}
249
+ * @throws {@link Phonic.UnauthorizedError}
250
+ * @throws {@link Phonic.ForbiddenError}
251
+ * @throws {@link Phonic.NotFoundError}
252
+ * @throws {@link Phonic.ConflictError}
253
+ *
254
+ * @example
255
+ * await client.agents.removeCustomPhoneNumber("nameOrId", {
256
+ * project: "main",
257
+ * phone_number: "+15551234567"
258
+ * })
259
+ */
260
+ removeCustomPhoneNumber(nameOrId: string, request: Phonic.AgentsRemoveCustomPhoneNumberRequest, requestOptions?: Agents.RequestOptions): core.HttpResponsePromise<Phonic.AgentsRemoveCustomPhoneNumberResponse>;
261
+ private __removeCustomPhoneNumber;
220
262
  protected _getAuthorizationHeader(): Promise<string | undefined>;
221
263
  }
@@ -556,6 +556,180 @@ export class Agents {
556
556
  }
557
557
  });
558
558
  }
559
+ /**
560
+ * Adds a custom phone number to an agent. The user must configure their SIP trunk to point to Phonic's SIP server.
561
+ *
562
+ * @param {string} nameOrId - The name or the ID of the agent.
563
+ * @param {Phonic.AgentsAddCustomPhoneNumberRequest} request
564
+ * @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
565
+ *
566
+ * @throws {@link Phonic.BadRequestError}
567
+ * @throws {@link Phonic.UnauthorizedError}
568
+ * @throws {@link Phonic.ForbiddenError}
569
+ * @throws {@link Phonic.NotFoundError}
570
+ * @throws {@link Phonic.ConflictError}
571
+ *
572
+ * @example
573
+ * await client.agents.addCustomPhoneNumber("nameOrId", {
574
+ * project: "main",
575
+ * phone_number: "+15551234567"
576
+ * })
577
+ */
578
+ addCustomPhoneNumber(nameOrId, request, requestOptions) {
579
+ return core.HttpResponsePromise.fromPromise(this.__addCustomPhoneNumber(nameOrId, request, requestOptions));
580
+ }
581
+ __addCustomPhoneNumber(nameOrId, request, requestOptions) {
582
+ return __awaiter(this, void 0, void 0, function* () {
583
+ var _a, _b, _c, _d;
584
+ const { project } = request, _body = __rest(request, ["project"]);
585
+ const _queryParams = {};
586
+ if (project != null) {
587
+ _queryParams["project"] = project;
588
+ }
589
+ let _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
590
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
591
+ url: core.url.join((_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : ((_d = (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.PhonicEnvironment.Default)
592
+ .base, `agents/${encodeURIComponent(nameOrId)}/add-custom-phone-number`),
593
+ method: "POST",
594
+ headers: _headers,
595
+ contentType: "application/json",
596
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
597
+ requestType: "json",
598
+ body: _body,
599
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
600
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
601
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
602
+ });
603
+ if (_response.ok) {
604
+ return {
605
+ data: _response.body,
606
+ rawResponse: _response.rawResponse,
607
+ };
608
+ }
609
+ if (_response.error.reason === "status-code") {
610
+ switch (_response.error.statusCode) {
611
+ case 400:
612
+ throw new Phonic.BadRequestError(_response.error.body, _response.rawResponse);
613
+ case 401:
614
+ throw new Phonic.UnauthorizedError(_response.error.body, _response.rawResponse);
615
+ case 403:
616
+ throw new Phonic.ForbiddenError(_response.error.body, _response.rawResponse);
617
+ case 404:
618
+ throw new Phonic.NotFoundError(_response.error.body, _response.rawResponse);
619
+ case 409:
620
+ throw new Phonic.ConflictError(_response.error.body, _response.rawResponse);
621
+ default:
622
+ throw new errors.PhonicError({
623
+ statusCode: _response.error.statusCode,
624
+ body: _response.error.body,
625
+ rawResponse: _response.rawResponse,
626
+ });
627
+ }
628
+ }
629
+ switch (_response.error.reason) {
630
+ case "non-json":
631
+ throw new errors.PhonicError({
632
+ statusCode: _response.error.statusCode,
633
+ body: _response.error.rawBody,
634
+ rawResponse: _response.rawResponse,
635
+ });
636
+ case "timeout":
637
+ throw new errors.PhonicTimeoutError("Timeout exceeded when calling POST /agents/{nameOrId}/add-custom-phone-number.");
638
+ case "unknown":
639
+ throw new errors.PhonicError({
640
+ message: _response.error.errorMessage,
641
+ rawResponse: _response.rawResponse,
642
+ });
643
+ }
644
+ });
645
+ }
646
+ /**
647
+ * Removes a custom phone number from an agent.
648
+ *
649
+ * @param {string} nameOrId - The name or the ID of the agent.
650
+ * @param {Phonic.AgentsRemoveCustomPhoneNumberRequest} request
651
+ * @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
652
+ *
653
+ * @throws {@link Phonic.BadRequestError}
654
+ * @throws {@link Phonic.UnauthorizedError}
655
+ * @throws {@link Phonic.ForbiddenError}
656
+ * @throws {@link Phonic.NotFoundError}
657
+ * @throws {@link Phonic.ConflictError}
658
+ *
659
+ * @example
660
+ * await client.agents.removeCustomPhoneNumber("nameOrId", {
661
+ * project: "main",
662
+ * phone_number: "+15551234567"
663
+ * })
664
+ */
665
+ removeCustomPhoneNumber(nameOrId, request, requestOptions) {
666
+ return core.HttpResponsePromise.fromPromise(this.__removeCustomPhoneNumber(nameOrId, request, requestOptions));
667
+ }
668
+ __removeCustomPhoneNumber(nameOrId, request, requestOptions) {
669
+ return __awaiter(this, void 0, void 0, function* () {
670
+ var _a, _b, _c, _d;
671
+ const { project } = request, _body = __rest(request, ["project"]);
672
+ const _queryParams = {};
673
+ if (project != null) {
674
+ _queryParams["project"] = project;
675
+ }
676
+ let _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
677
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
678
+ url: core.url.join((_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : ((_d = (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.PhonicEnvironment.Default)
679
+ .base, `agents/${encodeURIComponent(nameOrId)}/remove-custom-phone-number`),
680
+ method: "POST",
681
+ headers: _headers,
682
+ contentType: "application/json",
683
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
684
+ requestType: "json",
685
+ body: _body,
686
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
687
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
688
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
689
+ });
690
+ if (_response.ok) {
691
+ return {
692
+ data: _response.body,
693
+ rawResponse: _response.rawResponse,
694
+ };
695
+ }
696
+ if (_response.error.reason === "status-code") {
697
+ switch (_response.error.statusCode) {
698
+ case 400:
699
+ throw new Phonic.BadRequestError(_response.error.body, _response.rawResponse);
700
+ case 401:
701
+ throw new Phonic.UnauthorizedError(_response.error.body, _response.rawResponse);
702
+ case 403:
703
+ throw new Phonic.ForbiddenError(_response.error.body, _response.rawResponse);
704
+ case 404:
705
+ throw new Phonic.NotFoundError(_response.error.body, _response.rawResponse);
706
+ case 409:
707
+ throw new Phonic.ConflictError(_response.error.body, _response.rawResponse);
708
+ default:
709
+ throw new errors.PhonicError({
710
+ statusCode: _response.error.statusCode,
711
+ body: _response.error.body,
712
+ rawResponse: _response.rawResponse,
713
+ });
714
+ }
715
+ }
716
+ switch (_response.error.reason) {
717
+ case "non-json":
718
+ throw new errors.PhonicError({
719
+ statusCode: _response.error.statusCode,
720
+ body: _response.error.rawBody,
721
+ rawResponse: _response.rawResponse,
722
+ });
723
+ case "timeout":
724
+ throw new errors.PhonicTimeoutError("Timeout exceeded when calling POST /agents/{nameOrId}/remove-custom-phone-number.");
725
+ case "unknown":
726
+ throw new errors.PhonicError({
727
+ message: _response.error.errorMessage,
728
+ rawResponse: _response.rawResponse,
729
+ });
730
+ }
731
+ });
732
+ }
559
733
  _getAuthorizationHeader() {
560
734
  return __awaiter(this, void 0, void 0, function* () {
561
735
  var _a;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ /**
5
+ * @example
6
+ * {
7
+ * project: "main",
8
+ * phone_number: "+15551234567"
9
+ * }
10
+ */
11
+ export interface AgentsAddCustomPhoneNumberRequest {
12
+ /** The name of the project containing the agent. Only used when `nameOrId` is a name. */
13
+ project?: string;
14
+ /** The E.164 formatted phone number to add (e.g., "+15551234567"). */
15
+ phone_number: string;
16
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export {};
@@ -0,0 +1,16 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ /**
5
+ * @example
6
+ * {
7
+ * project: "main",
8
+ * phone_number: "+15551234567"
9
+ * }
10
+ */
11
+ export interface AgentsRemoveCustomPhoneNumberRequest {
12
+ /** The name of the project containing the agent. Only used when `nameOrId` is a name. */
13
+ project?: string;
14
+ /** The E.164 formatted phone number to remove (e.g., "+15551234567"). */
15
+ phone_number: string;
16
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export {};
@@ -4,3 +4,5 @@ export { type UpsertAgentRequest } from "./UpsertAgentRequest.mjs";
4
4
  export { type AgentsGetRequest } from "./AgentsGetRequest.mjs";
5
5
  export { type AgentsDeleteRequest } from "./AgentsDeleteRequest.mjs";
6
6
  export { type UpdateAgentRequest } from "./UpdateAgentRequest.mjs";
7
+ export { type AgentsAddCustomPhoneNumberRequest } from "./AgentsAddCustomPhoneNumberRequest.mjs";
8
+ export { type AgentsRemoveCustomPhoneNumberRequest } from "./AgentsRemoveCustomPhoneNumberRequest.mjs";
@@ -0,0 +1,6 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export interface AgentsAddCustomPhoneNumberResponse {
5
+ success: boolean;
6
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export interface AgentsRemoveCustomPhoneNumberResponse {
5
+ success: boolean;
6
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export {};
@@ -4,3 +4,5 @@ export * from "./AgentsUpsertResponse.mjs";
4
4
  export * from "./AgentsGetResponse.mjs";
5
5
  export * from "./AgentsDeleteResponse.mjs";
6
6
  export * from "./AgentsUpdateResponse.mjs";
7
+ export * from "./AgentsAddCustomPhoneNumberResponse.mjs";
8
+ export * from "./AgentsRemoveCustomPhoneNumberResponse.mjs";
@@ -4,3 +4,5 @@ export * from "./AgentsUpsertResponse.mjs";
4
4
  export * from "./AgentsGetResponse.mjs";
5
5
  export * from "./AgentsDeleteResponse.mjs";
6
6
  export * from "./AgentsUpdateResponse.mjs";
7
+ export * from "./AgentsAddCustomPhoneNumberResponse.mjs";
8
+ export * from "./AgentsRemoveCustomPhoneNumberResponse.mjs";
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.30.28";
1
+ export declare const SDK_VERSION = "0.30.29";
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.30.28";
1
+ export const SDK_VERSION = "0.30.29";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phonic",
3
- "version": "0.30.28",
3
+ "version": "0.30.29",
4
4
  "private": false,
5
5
  "repository": "github:Phonic-Co/phonic-node",
6
6
  "type": "commonjs",
package/reference.md CHANGED
@@ -501,6 +501,154 @@ await client.agents.update("nameOrId", {
501
501
  </dl>
502
502
  </details>
503
503
 
504
+ <details><summary><code>client.agents.<a href="/src/api/resources/agents/client/Client.ts">addCustomPhoneNumber</a>(nameOrId, { ...params }) -> Phonic.AgentsAddCustomPhoneNumberResponse</code></summary>
505
+ <dl>
506
+ <dd>
507
+
508
+ #### 📝 Description
509
+
510
+ <dl>
511
+ <dd>
512
+
513
+ <dl>
514
+ <dd>
515
+
516
+ Adds a custom phone number to an agent. The user must configure their SIP trunk to point to Phonic's SIP server.
517
+
518
+ </dd>
519
+ </dl>
520
+ </dd>
521
+ </dl>
522
+
523
+ #### 🔌 Usage
524
+
525
+ <dl>
526
+ <dd>
527
+
528
+ <dl>
529
+ <dd>
530
+
531
+ ```typescript
532
+ await client.agents.addCustomPhoneNumber("nameOrId", {
533
+ project: "main",
534
+ phone_number: "+15551234567",
535
+ });
536
+ ```
537
+
538
+ </dd>
539
+ </dl>
540
+ </dd>
541
+ </dl>
542
+
543
+ #### ⚙️ Parameters
544
+
545
+ <dl>
546
+ <dd>
547
+
548
+ <dl>
549
+ <dd>
550
+
551
+ **nameOrId:** `string` — The name or the ID of the agent.
552
+
553
+ </dd>
554
+ </dl>
555
+
556
+ <dl>
557
+ <dd>
558
+
559
+ **request:** `Phonic.AgentsAddCustomPhoneNumberRequest`
560
+
561
+ </dd>
562
+ </dl>
563
+
564
+ <dl>
565
+ <dd>
566
+
567
+ **requestOptions:** `Agents.RequestOptions`
568
+
569
+ </dd>
570
+ </dl>
571
+ </dd>
572
+ </dl>
573
+
574
+ </dd>
575
+ </dl>
576
+ </details>
577
+
578
+ <details><summary><code>client.agents.<a href="/src/api/resources/agents/client/Client.ts">removeCustomPhoneNumber</a>(nameOrId, { ...params }) -> Phonic.AgentsRemoveCustomPhoneNumberResponse</code></summary>
579
+ <dl>
580
+ <dd>
581
+
582
+ #### 📝 Description
583
+
584
+ <dl>
585
+ <dd>
586
+
587
+ <dl>
588
+ <dd>
589
+
590
+ Removes a custom phone number from an agent.
591
+
592
+ </dd>
593
+ </dl>
594
+ </dd>
595
+ </dl>
596
+
597
+ #### 🔌 Usage
598
+
599
+ <dl>
600
+ <dd>
601
+
602
+ <dl>
603
+ <dd>
604
+
605
+ ```typescript
606
+ await client.agents.removeCustomPhoneNumber("nameOrId", {
607
+ project: "main",
608
+ phone_number: "+15551234567",
609
+ });
610
+ ```
611
+
612
+ </dd>
613
+ </dl>
614
+ </dd>
615
+ </dl>
616
+
617
+ #### ⚙️ Parameters
618
+
619
+ <dl>
620
+ <dd>
621
+
622
+ <dl>
623
+ <dd>
624
+
625
+ **nameOrId:** `string` — The name or the ID of the agent.
626
+
627
+ </dd>
628
+ </dl>
629
+
630
+ <dl>
631
+ <dd>
632
+
633
+ **request:** `Phonic.AgentsRemoveCustomPhoneNumberRequest`
634
+
635
+ </dd>
636
+ </dl>
637
+
638
+ <dl>
639
+ <dd>
640
+
641
+ **requestOptions:** `Agents.RequestOptions`
642
+
643
+ </dd>
644
+ </dl>
645
+ </dd>
646
+ </dl>
647
+
648
+ </dd>
649
+ </dl>
650
+ </details>
651
+
504
652
  ## Tools
505
653
 
506
654
  <details><summary><code>client.tools.<a href="/src/api/resources/tools/client/Client.ts">list</a>({ ...params }) -> Phonic.ToolsListResponse</code></summary>