phonic 0.32.2 → 0.32.3

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 (212) hide show
  1. package/dist/cjs/BaseClient.js +2 -2
  2. package/dist/cjs/Client.d.ts +3 -0
  3. package/dist/cjs/Client.js +23 -18
  4. package/dist/cjs/api/errors/TooManyRequestsError.d.ts +6 -0
  5. package/dist/cjs/api/errors/TooManyRequestsError.js +54 -0
  6. package/dist/cjs/api/errors/index.d.ts +1 -0
  7. package/dist/cjs/api/errors/index.js +1 -0
  8. package/dist/cjs/api/resources/agents/client/requests/AgentsCreateRequest.d.ts +8 -0
  9. package/dist/cjs/api/resources/agents/client/requests/UpdateAgentRequest.d.ts +14 -0
  10. package/dist/cjs/api/resources/agents/client/requests/UpsertAgentRequest.d.ts +6 -0
  11. package/dist/cjs/api/resources/agents/types/AgentsUpdateResponse.d.ts +5 -0
  12. package/dist/cjs/api/resources/apiKeys/client/Client.d.ts +79 -0
  13. package/dist/cjs/api/resources/apiKeys/client/Client.js +293 -0
  14. package/dist/cjs/api/resources/apiKeys/client/index.d.ts +1 -0
  15. package/dist/cjs/api/resources/apiKeys/client/index.js +17 -0
  16. package/dist/cjs/api/resources/apiKeys/client/requests/CreateApiKeyRequest.d.ts +10 -0
  17. package/dist/cjs/api/resources/apiKeys/client/requests/CreateApiKeyRequest.js +3 -0
  18. package/dist/cjs/api/resources/apiKeys/client/requests/UpdateApiKeyRequest.d.ts +10 -0
  19. package/dist/cjs/api/resources/apiKeys/client/requests/UpdateApiKeyRequest.js +3 -0
  20. package/dist/cjs/api/resources/apiKeys/client/requests/index.d.ts +2 -0
  21. package/dist/cjs/api/resources/apiKeys/client/requests/index.js +2 -0
  22. package/dist/cjs/api/resources/apiKeys/exports.d.ts +2 -0
  23. package/dist/cjs/api/resources/apiKeys/exports.js +21 -0
  24. package/dist/cjs/api/resources/apiKeys/index.d.ts +2 -0
  25. package/dist/cjs/api/resources/apiKeys/index.js +18 -0
  26. package/dist/cjs/api/resources/apiKeys/types/ApiKeysDeleteResponse.d.ts +3 -0
  27. package/dist/cjs/api/resources/apiKeys/types/ApiKeysDeleteResponse.js +3 -0
  28. package/dist/cjs/api/resources/apiKeys/types/ApiKeysUpdateResponse.d.ts +3 -0
  29. package/dist/cjs/api/resources/apiKeys/types/ApiKeysUpdateResponse.js +3 -0
  30. package/dist/cjs/api/resources/apiKeys/types/index.d.ts +2 -0
  31. package/dist/cjs/api/resources/apiKeys/types/index.js +18 -0
  32. package/dist/cjs/api/resources/auth/client/Client.d.ts +20 -0
  33. package/dist/cjs/api/resources/auth/client/Client.js +70 -0
  34. package/dist/cjs/api/resources/auth/client/requests/CreateConversationTokenRequest.d.ts +13 -0
  35. package/dist/cjs/api/resources/auth/client/requests/CreateConversationTokenRequest.js +3 -0
  36. package/dist/cjs/api/resources/auth/client/requests/index.d.ts +1 -0
  37. package/dist/cjs/api/resources/auth/types/AuthCreateConversationTokenResponse.d.ts +6 -0
  38. package/dist/cjs/api/resources/auth/types/AuthCreateConversationTokenResponse.js +3 -0
  39. package/dist/cjs/api/resources/auth/types/index.d.ts +1 -0
  40. package/dist/cjs/api/resources/auth/types/index.js +1 -0
  41. package/dist/cjs/api/resources/conversations/client/Client.d.ts +26 -1
  42. package/dist/cjs/api/resources/conversations/client/Client.js +78 -0
  43. package/dist/cjs/api/resources/conversations/client/requests/ReplayConversationRequest.d.ts +10 -0
  44. package/dist/cjs/api/resources/conversations/client/requests/ReplayConversationRequest.js +3 -0
  45. package/dist/cjs/api/resources/conversations/client/requests/index.d.ts +1 -0
  46. package/dist/cjs/api/resources/conversations/types/ConversationsEvaluateResponse.d.ts +19 -0
  47. package/dist/cjs/api/resources/conversations/types/ConversationsEvaluateResponse.js +17 -0
  48. package/dist/cjs/api/resources/conversations/types/ConversationsReplayResponse.d.ts +4 -0
  49. package/dist/cjs/api/resources/conversations/types/ConversationsReplayResponse.js +3 -0
  50. package/dist/cjs/api/resources/conversations/types/index.d.ts +2 -0
  51. package/dist/cjs/api/resources/conversations/types/index.js +2 -0
  52. package/dist/cjs/api/resources/index.d.ts +4 -0
  53. package/dist/cjs/api/resources/index.js +5 -1
  54. package/dist/cjs/api/resources/projects/client/Client.d.ts +16 -0
  55. package/dist/cjs/api/resources/projects/client/Client.js +58 -0
  56. package/dist/cjs/api/resources/projects/types/ProjectsListEvalsResponse.d.ts +4 -0
  57. package/dist/cjs/api/resources/projects/types/ProjectsListEvalsResponse.js +3 -0
  58. package/dist/cjs/api/resources/projects/types/index.d.ts +1 -0
  59. package/dist/cjs/api/resources/projects/types/index.js +1 -0
  60. package/dist/cjs/api/resources/tools/client/Client.d.ts +2 -1
  61. package/dist/cjs/api/resources/tools/client/Client.js +2 -1
  62. package/dist/cjs/api/resources/tools/client/requests/CreateToolRequest.d.ts +4 -1
  63. package/dist/cjs/api/resources/tools/client/requests/UpdateToolRequest.d.ts +5 -13
  64. package/dist/cjs/api/resources/tools/client/requests/UpdateToolRequest.js +0 -8
  65. package/dist/cjs/api/resources/workspace/client/Client.d.ts +20 -0
  66. package/dist/cjs/api/resources/workspace/client/Client.js +65 -0
  67. package/dist/cjs/api/resources/workspace/client/index.d.ts +1 -1
  68. package/dist/cjs/api/resources/workspace/client/index.js +15 -0
  69. package/dist/cjs/api/resources/workspace/client/requests/UpdateWorkspaceRequest.d.ts +16 -0
  70. package/dist/cjs/api/resources/workspace/client/requests/UpdateWorkspaceRequest.js +3 -0
  71. package/dist/cjs/api/resources/workspace/client/requests/index.d.ts +1 -0
  72. package/dist/cjs/api/resources/workspace/client/requests/index.js +2 -0
  73. package/dist/cjs/api/resources/workspace/types/WorkspaceGetResponse.d.ts +6 -0
  74. package/dist/cjs/api/resources/workspace/types/WorkspaceUpdateResponse.d.ts +3 -0
  75. package/dist/cjs/api/resources/workspace/types/WorkspaceUpdateResponse.js +3 -0
  76. package/dist/cjs/api/resources/workspace/types/index.d.ts +1 -0
  77. package/dist/cjs/api/resources/workspace/types/index.js +1 -0
  78. package/dist/cjs/api/types/Agent.d.ts +9 -0
  79. package/dist/cjs/api/types/AgentIntegration.d.ts +13 -0
  80. package/dist/cjs/api/types/AgentIntegration.js +3 -0
  81. package/dist/cjs/api/types/ApiKeyWithSecret.d.ts +8 -0
  82. package/dist/cjs/api/types/ApiKeyWithSecret.js +3 -0
  83. package/dist/cjs/api/types/AudioChunkResponsePayload.d.ts +2 -0
  84. package/dist/cjs/api/types/ConfigOptions.d.ts +67 -0
  85. package/dist/cjs/api/types/Conversation.d.ts +23 -0
  86. package/dist/cjs/api/types/ConversationEval.d.ts +22 -1
  87. package/dist/cjs/api/types/ConversationEval.js +11 -0
  88. package/dist/cjs/api/types/ConversationEvalPromptInfo.d.ts +7 -0
  89. package/dist/cjs/api/types/ConversationEvalPromptInfo.js +3 -0
  90. package/dist/cjs/api/types/ConversationExtraction.d.ts +2 -4
  91. package/dist/cjs/api/types/ConversationItem.d.ts +4 -2
  92. package/dist/cjs/api/types/CreateAgentRequest.d.ts +8 -0
  93. package/dist/cjs/api/types/DataRetentionPolicy.d.ts +21 -0
  94. package/dist/cjs/api/types/DataRetentionPolicy.js +3 -0
  95. package/dist/cjs/api/types/DtmfPayload.d.ts +2 -0
  96. package/dist/cjs/api/types/ExtractionField.d.ts +2 -2
  97. package/dist/cjs/api/types/OutboundCallConfig.d.ts +40 -0
  98. package/dist/cjs/api/types/OutboundCallConfig.js +6 -0
  99. package/dist/cjs/api/types/OutboundNumberPool.d.ts +9 -0
  100. package/dist/cjs/api/types/OutboundNumberPool.js +3 -0
  101. package/dist/cjs/api/types/Tool.d.ts +3 -1
  102. package/dist/cjs/api/types/index.d.ts +5 -0
  103. package/dist/cjs/api/types/index.js +5 -0
  104. package/dist/cjs/version.d.ts +1 -1
  105. package/dist/cjs/version.js +1 -1
  106. package/dist/esm/BaseClient.mjs +2 -2
  107. package/dist/esm/Client.d.mts +3 -0
  108. package/dist/esm/Client.mjs +5 -0
  109. package/dist/esm/api/errors/TooManyRequestsError.d.mts +6 -0
  110. package/dist/esm/api/errors/TooManyRequestsError.mjs +17 -0
  111. package/dist/esm/api/errors/index.d.mts +1 -0
  112. package/dist/esm/api/errors/index.mjs +1 -0
  113. package/dist/esm/api/resources/agents/client/requests/AgentsCreateRequest.d.mts +8 -0
  114. package/dist/esm/api/resources/agents/client/requests/UpdateAgentRequest.d.mts +14 -0
  115. package/dist/esm/api/resources/agents/client/requests/UpsertAgentRequest.d.mts +6 -0
  116. package/dist/esm/api/resources/agents/types/AgentsUpdateResponse.d.mts +5 -0
  117. package/dist/esm/api/resources/apiKeys/client/Client.d.mts +79 -0
  118. package/dist/esm/api/resources/apiKeys/client/Client.mjs +256 -0
  119. package/dist/esm/api/resources/apiKeys/client/index.d.mts +1 -0
  120. package/dist/esm/api/resources/apiKeys/client/index.mjs +1 -0
  121. package/dist/esm/api/resources/apiKeys/client/requests/CreateApiKeyRequest.d.mts +10 -0
  122. package/dist/esm/api/resources/apiKeys/client/requests/CreateApiKeyRequest.mjs +2 -0
  123. package/dist/esm/api/resources/apiKeys/client/requests/UpdateApiKeyRequest.d.mts +10 -0
  124. package/dist/esm/api/resources/apiKeys/client/requests/UpdateApiKeyRequest.mjs +2 -0
  125. package/dist/esm/api/resources/apiKeys/client/requests/index.d.mts +2 -0
  126. package/dist/esm/api/resources/apiKeys/client/requests/index.mjs +1 -0
  127. package/dist/esm/api/resources/apiKeys/exports.d.mts +2 -0
  128. package/dist/esm/api/resources/apiKeys/exports.mjs +3 -0
  129. package/dist/esm/api/resources/apiKeys/index.d.mts +2 -0
  130. package/dist/esm/api/resources/apiKeys/index.mjs +2 -0
  131. package/dist/esm/api/resources/apiKeys/types/ApiKeysDeleteResponse.d.mts +3 -0
  132. package/dist/esm/api/resources/apiKeys/types/ApiKeysDeleteResponse.mjs +2 -0
  133. package/dist/esm/api/resources/apiKeys/types/ApiKeysUpdateResponse.d.mts +3 -0
  134. package/dist/esm/api/resources/apiKeys/types/ApiKeysUpdateResponse.mjs +2 -0
  135. package/dist/esm/api/resources/apiKeys/types/index.d.mts +2 -0
  136. package/dist/esm/api/resources/apiKeys/types/index.mjs +2 -0
  137. package/dist/esm/api/resources/auth/client/Client.d.mts +20 -0
  138. package/dist/esm/api/resources/auth/client/Client.mjs +70 -0
  139. package/dist/esm/api/resources/auth/client/requests/CreateConversationTokenRequest.d.mts +13 -0
  140. package/dist/esm/api/resources/auth/client/requests/CreateConversationTokenRequest.mjs +2 -0
  141. package/dist/esm/api/resources/auth/client/requests/index.d.mts +1 -0
  142. package/dist/esm/api/resources/auth/types/AuthCreateConversationTokenResponse.d.mts +6 -0
  143. package/dist/esm/api/resources/auth/types/AuthCreateConversationTokenResponse.mjs +2 -0
  144. package/dist/esm/api/resources/auth/types/index.d.mts +1 -0
  145. package/dist/esm/api/resources/auth/types/index.mjs +1 -0
  146. package/dist/esm/api/resources/conversations/client/Client.d.mts +26 -1
  147. package/dist/esm/api/resources/conversations/client/Client.mjs +78 -0
  148. package/dist/esm/api/resources/conversations/client/requests/ReplayConversationRequest.d.mts +10 -0
  149. package/dist/esm/api/resources/conversations/client/requests/ReplayConversationRequest.mjs +2 -0
  150. package/dist/esm/api/resources/conversations/client/requests/index.d.mts +1 -0
  151. package/dist/esm/api/resources/conversations/types/ConversationsEvaluateResponse.d.mts +19 -0
  152. package/dist/esm/api/resources/conversations/types/ConversationsEvaluateResponse.mjs +14 -0
  153. package/dist/esm/api/resources/conversations/types/ConversationsReplayResponse.d.mts +4 -0
  154. package/dist/esm/api/resources/conversations/types/ConversationsReplayResponse.mjs +2 -0
  155. package/dist/esm/api/resources/conversations/types/index.d.mts +2 -0
  156. package/dist/esm/api/resources/conversations/types/index.mjs +2 -0
  157. package/dist/esm/api/resources/index.d.mts +4 -0
  158. package/dist/esm/api/resources/index.mjs +4 -0
  159. package/dist/esm/api/resources/projects/client/Client.d.mts +16 -0
  160. package/dist/esm/api/resources/projects/client/Client.mjs +58 -0
  161. package/dist/esm/api/resources/projects/types/ProjectsListEvalsResponse.d.mts +4 -0
  162. package/dist/esm/api/resources/projects/types/ProjectsListEvalsResponse.mjs +2 -0
  163. package/dist/esm/api/resources/projects/types/index.d.mts +1 -0
  164. package/dist/esm/api/resources/projects/types/index.mjs +1 -0
  165. package/dist/esm/api/resources/tools/client/Client.d.mts +2 -1
  166. package/dist/esm/api/resources/tools/client/Client.mjs +2 -1
  167. package/dist/esm/api/resources/tools/client/requests/CreateToolRequest.d.mts +4 -1
  168. package/dist/esm/api/resources/tools/client/requests/UpdateToolRequest.d.mts +5 -13
  169. package/dist/esm/api/resources/tools/client/requests/UpdateToolRequest.mjs +0 -8
  170. package/dist/esm/api/resources/workspace/client/Client.d.mts +20 -0
  171. package/dist/esm/api/resources/workspace/client/Client.mjs +65 -0
  172. package/dist/esm/api/resources/workspace/client/index.d.mts +1 -1
  173. package/dist/esm/api/resources/workspace/client/index.mjs +1 -1
  174. package/dist/esm/api/resources/workspace/client/requests/UpdateWorkspaceRequest.d.mts +16 -0
  175. package/dist/esm/api/resources/workspace/client/requests/UpdateWorkspaceRequest.mjs +2 -0
  176. package/dist/esm/api/resources/workspace/client/requests/index.d.mts +1 -0
  177. package/dist/esm/api/resources/workspace/client/requests/index.mjs +1 -0
  178. package/dist/esm/api/resources/workspace/types/WorkspaceGetResponse.d.mts +6 -0
  179. package/dist/esm/api/resources/workspace/types/WorkspaceUpdateResponse.d.mts +3 -0
  180. package/dist/esm/api/resources/workspace/types/WorkspaceUpdateResponse.mjs +2 -0
  181. package/dist/esm/api/resources/workspace/types/index.d.mts +1 -0
  182. package/dist/esm/api/resources/workspace/types/index.mjs +1 -0
  183. package/dist/esm/api/types/Agent.d.mts +9 -0
  184. package/dist/esm/api/types/AgentIntegration.d.mts +13 -0
  185. package/dist/esm/api/types/AgentIntegration.mjs +2 -0
  186. package/dist/esm/api/types/ApiKeyWithSecret.d.mts +8 -0
  187. package/dist/esm/api/types/ApiKeyWithSecret.mjs +2 -0
  188. package/dist/esm/api/types/AudioChunkResponsePayload.d.mts +2 -0
  189. package/dist/esm/api/types/ConfigOptions.d.mts +67 -0
  190. package/dist/esm/api/types/Conversation.d.mts +23 -0
  191. package/dist/esm/api/types/ConversationEval.d.mts +22 -1
  192. package/dist/esm/api/types/ConversationEval.mjs +10 -1
  193. package/dist/esm/api/types/ConversationEvalPromptInfo.d.mts +7 -0
  194. package/dist/esm/api/types/ConversationEvalPromptInfo.mjs +2 -0
  195. package/dist/esm/api/types/ConversationExtraction.d.mts +2 -4
  196. package/dist/esm/api/types/ConversationItem.d.mts +4 -2
  197. package/dist/esm/api/types/CreateAgentRequest.d.mts +8 -0
  198. package/dist/esm/api/types/DataRetentionPolicy.d.mts +21 -0
  199. package/dist/esm/api/types/DataRetentionPolicy.mjs +2 -0
  200. package/dist/esm/api/types/DtmfPayload.d.mts +2 -0
  201. package/dist/esm/api/types/ExtractionField.d.mts +2 -2
  202. package/dist/esm/api/types/OutboundCallConfig.d.mts +40 -0
  203. package/dist/esm/api/types/OutboundCallConfig.mjs +6 -0
  204. package/dist/esm/api/types/OutboundNumberPool.d.mts +9 -0
  205. package/dist/esm/api/types/OutboundNumberPool.mjs +2 -0
  206. package/dist/esm/api/types/Tool.d.mts +3 -1
  207. package/dist/esm/api/types/index.d.mts +5 -0
  208. package/dist/esm/api/types/index.mjs +5 -0
  209. package/dist/esm/version.d.mts +1 -1
  210. package/dist/esm/version.mjs +1 -1
  211. package/package.json +12 -1
  212. package/reference.md +540 -2
@@ -0,0 +1,256 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ import { normalizeClientOptionsWithAuth } from "../../../../BaseClient.mjs";
12
+ import { mergeHeaders } from "../../../../core/headers.mjs";
13
+ import * as core from "../../../../core/index.mjs";
14
+ import * as environments from "../../../../environments.mjs";
15
+ import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.mjs";
16
+ import * as errors from "../../../../errors/index.mjs";
17
+ import * as Phonic from "../../../index.mjs";
18
+ export class ApiKeysClient {
19
+ constructor(options = {}) {
20
+ this._options = normalizeClientOptionsWithAuth(options);
21
+ }
22
+ /**
23
+ * Creates a new API key in the workspace.
24
+ *
25
+ * @param {Phonic.CreateApiKeyRequest} request
26
+ * @param {ApiKeysClient.RequestOptions} requestOptions - Request-specific configuration.
27
+ *
28
+ * @throws {@link Phonic.BadRequestError}
29
+ * @throws {@link Phonic.UnauthorizedError}
30
+ * @throws {@link Phonic.InternalServerError}
31
+ *
32
+ * @example
33
+ * await client.apiKeys.create({
34
+ * name: "production-key"
35
+ * })
36
+ */
37
+ create(request, requestOptions) {
38
+ return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions));
39
+ }
40
+ __create(request, requestOptions) {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
43
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
44
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
45
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
46
+ 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)
47
+ .base, "api_keys"),
48
+ method: "POST",
49
+ headers: _headers,
50
+ contentType: "application/json",
51
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
52
+ requestType: "json",
53
+ body: request,
54
+ timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
55
+ maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
56
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
57
+ fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
58
+ logging: this._options.logging,
59
+ });
60
+ if (_response.ok) {
61
+ return { data: _response.body, rawResponse: _response.rawResponse };
62
+ }
63
+ if (_response.error.reason === "status-code") {
64
+ switch (_response.error.statusCode) {
65
+ case 400:
66
+ throw new Phonic.BadRequestError(_response.error.body, _response.rawResponse);
67
+ case 401:
68
+ throw new Phonic.UnauthorizedError(_response.error.body, _response.rawResponse);
69
+ case 500:
70
+ throw new Phonic.InternalServerError(_response.error.body, _response.rawResponse);
71
+ default:
72
+ throw new errors.PhonicError({
73
+ statusCode: _response.error.statusCode,
74
+ body: _response.error.body,
75
+ rawResponse: _response.rawResponse,
76
+ });
77
+ }
78
+ }
79
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/api_keys");
80
+ });
81
+ }
82
+ /**
83
+ * Deletes an API key.
84
+ *
85
+ * @param {string} id - The ID of the API key to delete.
86
+ * @param {ApiKeysClient.RequestOptions} requestOptions - Request-specific configuration.
87
+ *
88
+ * @throws {@link Phonic.UnauthorizedError}
89
+ * @throws {@link Phonic.NotFoundError}
90
+ * @throws {@link Phonic.InternalServerError}
91
+ *
92
+ * @example
93
+ * await client.apiKeys.delete("id")
94
+ */
95
+ delete(id, requestOptions) {
96
+ return core.HttpResponsePromise.fromPromise(this.__delete(id, requestOptions));
97
+ }
98
+ __delete(id, requestOptions) {
99
+ return __awaiter(this, void 0, void 0, function* () {
100
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
101
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
102
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
103
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
104
+ 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)
105
+ .base, `api_keys/${core.url.encodePathParam(id)}`),
106
+ method: "DELETE",
107
+ headers: _headers,
108
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
109
+ timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
110
+ maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
111
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
112
+ fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
113
+ logging: this._options.logging,
114
+ });
115
+ if (_response.ok) {
116
+ return { data: _response.body, rawResponse: _response.rawResponse };
117
+ }
118
+ if (_response.error.reason === "status-code") {
119
+ switch (_response.error.statusCode) {
120
+ case 401:
121
+ throw new Phonic.UnauthorizedError(_response.error.body, _response.rawResponse);
122
+ case 404:
123
+ throw new Phonic.NotFoundError(_response.error.body, _response.rawResponse);
124
+ case 500:
125
+ throw new Phonic.InternalServerError(_response.error.body, _response.rawResponse);
126
+ default:
127
+ throw new errors.PhonicError({
128
+ statusCode: _response.error.statusCode,
129
+ body: _response.error.body,
130
+ rawResponse: _response.rawResponse,
131
+ });
132
+ }
133
+ }
134
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/api_keys/{id}");
135
+ });
136
+ }
137
+ /**
138
+ * Updates an API key.
139
+ *
140
+ * @param {string} id - The ID of the API key to update.
141
+ * @param {Phonic.UpdateApiKeyRequest} request
142
+ * @param {ApiKeysClient.RequestOptions} requestOptions - Request-specific configuration.
143
+ *
144
+ * @throws {@link Phonic.BadRequestError}
145
+ * @throws {@link Phonic.UnauthorizedError}
146
+ * @throws {@link Phonic.NotFoundError}
147
+ * @throws {@link Phonic.InternalServerError}
148
+ *
149
+ * @example
150
+ * await client.apiKeys.update("id", {
151
+ * name: "renamed-key"
152
+ * })
153
+ */
154
+ update(id, request, requestOptions) {
155
+ return core.HttpResponsePromise.fromPromise(this.__update(id, request, requestOptions));
156
+ }
157
+ __update(id, request, requestOptions) {
158
+ return __awaiter(this, void 0, void 0, function* () {
159
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
160
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
161
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
162
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
163
+ 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)
164
+ .base, `api_keys/${core.url.encodePathParam(id)}`),
165
+ method: "PATCH",
166
+ headers: _headers,
167
+ contentType: "application/json",
168
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
169
+ requestType: "json",
170
+ body: request,
171
+ timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
172
+ maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
173
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
174
+ fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
175
+ logging: this._options.logging,
176
+ });
177
+ if (_response.ok) {
178
+ return { data: _response.body, rawResponse: _response.rawResponse };
179
+ }
180
+ if (_response.error.reason === "status-code") {
181
+ switch (_response.error.statusCode) {
182
+ case 400:
183
+ throw new Phonic.BadRequestError(_response.error.body, _response.rawResponse);
184
+ case 401:
185
+ throw new Phonic.UnauthorizedError(_response.error.body, _response.rawResponse);
186
+ case 404:
187
+ throw new Phonic.NotFoundError(_response.error.body, _response.rawResponse);
188
+ case 500:
189
+ throw new Phonic.InternalServerError(_response.error.body, _response.rawResponse);
190
+ default:
191
+ throw new errors.PhonicError({
192
+ statusCode: _response.error.statusCode,
193
+ body: _response.error.body,
194
+ rawResponse: _response.rawResponse,
195
+ });
196
+ }
197
+ }
198
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "PATCH", "/api_keys/{id}");
199
+ });
200
+ }
201
+ /**
202
+ * Rotates an API key, generating a new secret and invalidating the old one.
203
+ *
204
+ * @param {string} id - The ID of the API key to rotate.
205
+ * @param {ApiKeysClient.RequestOptions} requestOptions - Request-specific configuration.
206
+ *
207
+ * @throws {@link Phonic.UnauthorizedError}
208
+ * @throws {@link Phonic.NotFoundError}
209
+ * @throws {@link Phonic.InternalServerError}
210
+ *
211
+ * @example
212
+ * await client.apiKeys.rotate("id")
213
+ */
214
+ rotate(id, requestOptions) {
215
+ return core.HttpResponsePromise.fromPromise(this.__rotate(id, requestOptions));
216
+ }
217
+ __rotate(id, requestOptions) {
218
+ return __awaiter(this, void 0, void 0, function* () {
219
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
220
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
221
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
222
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
223
+ 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)
224
+ .base, `api_keys/${core.url.encodePathParam(id)}/rotate`),
225
+ method: "POST",
226
+ headers: _headers,
227
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
228
+ timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
229
+ maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
230
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
231
+ fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
232
+ logging: this._options.logging,
233
+ });
234
+ if (_response.ok) {
235
+ return { data: _response.body, rawResponse: _response.rawResponse };
236
+ }
237
+ if (_response.error.reason === "status-code") {
238
+ switch (_response.error.statusCode) {
239
+ case 401:
240
+ throw new Phonic.UnauthorizedError(_response.error.body, _response.rawResponse);
241
+ case 404:
242
+ throw new Phonic.NotFoundError(_response.error.body, _response.rawResponse);
243
+ case 500:
244
+ throw new Phonic.InternalServerError(_response.error.body, _response.rawResponse);
245
+ default:
246
+ throw new errors.PhonicError({
247
+ statusCode: _response.error.statusCode,
248
+ body: _response.error.body,
249
+ rawResponse: _response.rawResponse,
250
+ });
251
+ }
252
+ }
253
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/api_keys/{id}/rotate");
254
+ });
255
+ }
256
+ }
@@ -0,0 +1 @@
1
+ export * from "./requests/index.mjs";
@@ -0,0 +1 @@
1
+ export * from "./requests/index.mjs";
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * name: "production-key"
5
+ * }
6
+ */
7
+ export interface CreateApiKeyRequest {
8
+ /** A name to identify the API key. */
9
+ name: string;
10
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * name: "renamed-key"
5
+ * }
6
+ */
7
+ export interface UpdateApiKeyRequest {
8
+ /** The new name for the API key. */
9
+ name: string;
10
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -0,0 +1,2 @@
1
+ export type { CreateApiKeyRequest } from "./CreateApiKeyRequest.mjs";
2
+ export type { UpdateApiKeyRequest } from "./UpdateApiKeyRequest.mjs";
@@ -0,0 +1,2 @@
1
+ export { ApiKeysClient } from "./client/Client.mjs";
2
+ export * from "./client/index.mjs";
@@ -0,0 +1,3 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export { ApiKeysClient } from "./client/Client.mjs";
3
+ export * from "./client/index.mjs";
@@ -0,0 +1,2 @@
1
+ export * from "./client/index.mjs";
2
+ export * from "./types/index.mjs";
@@ -0,0 +1,2 @@
1
+ export * from "./client/index.mjs";
2
+ export * from "./types/index.mjs";
@@ -0,0 +1,3 @@
1
+ export interface ApiKeysDeleteResponse {
2
+ success: boolean;
3
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -0,0 +1,3 @@
1
+ export interface ApiKeysUpdateResponse {
2
+ success: boolean;
3
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from "./ApiKeysDeleteResponse.mjs";
2
+ export * from "./ApiKeysUpdateResponse.mjs";
@@ -0,0 +1,2 @@
1
+ export * from "./ApiKeysDeleteResponse.mjs";
2
+ export * from "./ApiKeysUpdateResponse.mjs";
@@ -28,4 +28,24 @@ export declare class AuthClient {
28
28
  */
29
29
  createSessionToken(request?: Phonic.CreateSessionTokenRequest, requestOptions?: AuthClient.RequestOptions): core.HttpResponsePromise<Phonic.AuthCreateSessionTokenResponse>;
30
30
  private __createSessionToken;
31
+ /**
32
+ * Creates a short-lived conversation token scoped to a specific agent. Conversation tokens are useful for client-side applications that start a conversation with a single agent without exposing your API key.
33
+ *
34
+ * @param {Phonic.CreateConversationTokenRequest} request
35
+ * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
36
+ *
37
+ * @throws {@link Phonic.BadRequestError}
38
+ * @throws {@link Phonic.UnauthorizedError}
39
+ * @throws {@link Phonic.ForbiddenError}
40
+ * @throws {@link Phonic.NotFoundError}
41
+ * @throws {@link Phonic.InternalServerError}
42
+ *
43
+ * @example
44
+ * await client.auth.createConversationToken({
45
+ * agent_id: "agent_12cf6e88-c254-4d3e-a149-a7f1bdd22783",
46
+ * ttl_seconds: 30
47
+ * })
48
+ */
49
+ createConversationToken(request: Phonic.CreateConversationTokenRequest, requestOptions?: AuthClient.RequestOptions): core.HttpResponsePromise<Phonic.AuthCreateConversationTokenResponse>;
50
+ private __createConversationToken;
31
51
  }
@@ -85,4 +85,74 @@ export class AuthClient {
85
85
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/auth/session_token");
86
86
  });
87
87
  }
88
+ /**
89
+ * Creates a short-lived conversation token scoped to a specific agent. Conversation tokens are useful for client-side applications that start a conversation with a single agent without exposing your API key.
90
+ *
91
+ * @param {Phonic.CreateConversationTokenRequest} request
92
+ * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
93
+ *
94
+ * @throws {@link Phonic.BadRequestError}
95
+ * @throws {@link Phonic.UnauthorizedError}
96
+ * @throws {@link Phonic.ForbiddenError}
97
+ * @throws {@link Phonic.NotFoundError}
98
+ * @throws {@link Phonic.InternalServerError}
99
+ *
100
+ * @example
101
+ * await client.auth.createConversationToken({
102
+ * agent_id: "agent_12cf6e88-c254-4d3e-a149-a7f1bdd22783",
103
+ * ttl_seconds: 30
104
+ * })
105
+ */
106
+ createConversationToken(request, requestOptions) {
107
+ return core.HttpResponsePromise.fromPromise(this.__createConversationToken(request, requestOptions));
108
+ }
109
+ __createConversationToken(request, requestOptions) {
110
+ return __awaiter(this, void 0, void 0, function* () {
111
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
112
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
113
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
114
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
115
+ 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)
116
+ .base, "auth/conversation_token"),
117
+ method: "POST",
118
+ headers: _headers,
119
+ contentType: "application/json",
120
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
121
+ requestType: "json",
122
+ body: request,
123
+ timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
124
+ maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
125
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
126
+ fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
127
+ logging: this._options.logging,
128
+ });
129
+ if (_response.ok) {
130
+ return {
131
+ data: _response.body,
132
+ rawResponse: _response.rawResponse,
133
+ };
134
+ }
135
+ if (_response.error.reason === "status-code") {
136
+ switch (_response.error.statusCode) {
137
+ case 400:
138
+ throw new Phonic.BadRequestError(_response.error.body, _response.rawResponse);
139
+ case 401:
140
+ throw new Phonic.UnauthorizedError(_response.error.body, _response.rawResponse);
141
+ case 403:
142
+ throw new Phonic.ForbiddenError(_response.error.body, _response.rawResponse);
143
+ case 404:
144
+ throw new Phonic.NotFoundError(_response.error.body, _response.rawResponse);
145
+ case 500:
146
+ throw new Phonic.InternalServerError(_response.error.body, _response.rawResponse);
147
+ default:
148
+ throw new errors.PhonicError({
149
+ statusCode: _response.error.statusCode,
150
+ body: _response.error.body,
151
+ rawResponse: _response.rawResponse,
152
+ });
153
+ }
154
+ }
155
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/auth/conversation_token");
156
+ });
157
+ }
88
158
  }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * agent_id: "agent_12cf6e88-c254-4d3e-a149-a7f1bdd22783",
5
+ * ttl_seconds: 30
6
+ * }
7
+ */
8
+ export interface CreateConversationTokenRequest {
9
+ /** ID of the agent the conversation token is scoped to. */
10
+ agent_id: string;
11
+ /** Time-to-live for the conversation token in seconds. */
12
+ ttl_seconds?: number;
13
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -1 +1,2 @@
1
+ export type { CreateConversationTokenRequest } from "./CreateConversationTokenRequest.mjs";
1
2
  export type { CreateSessionTokenRequest } from "./CreateSessionTokenRequest.mjs";
@@ -0,0 +1,6 @@
1
+ export interface AuthCreateConversationTokenResponse {
2
+ /** The conversation token to use for authentication. */
3
+ conversation_token: string;
4
+ /** When the conversation token expires. */
5
+ expires_at: string;
6
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -1 +1,2 @@
1
+ export * from "./AuthCreateConversationTokenResponse.mjs";
1
2
  export * from "./AuthCreateSessionTokenResponse.mjs";
@@ -1 +1,2 @@
1
+ export * from "./AuthCreateConversationTokenResponse.mjs";
1
2
  export * from "./AuthCreateSessionTokenResponse.mjs";
@@ -173,8 +173,33 @@ export declare class ConversationsClient {
173
173
  * prompt_id: "conv_eval_prompt_d7cfe45d-35db-4ef6-a254-81ab1da76ce0"
174
174
  * })
175
175
  */
176
- evaluate(id: string, request: Phonic.EvaluateConversationRequest, requestOptions?: ConversationsClient.RequestOptions): core.HttpResponsePromise<Phonic.ConversationEvaluationResult>;
176
+ evaluate(id: string, request: Phonic.EvaluateConversationRequest, requestOptions?: ConversationsClient.RequestOptions): core.HttpResponsePromise<Phonic.ConversationsEvaluateResponse>;
177
177
  private __evaluate;
178
+ /**
179
+ * Replays an ended conversation by re-running its recorded audio through an agent. Requires API key or access
180
+ * token authentication. The conversation must have audio recordings available and an associated agent (or one
181
+ * specified in the request body).
182
+ *
183
+ * @param {string} id - The ID of the conversation to replay.
184
+ * @param {Phonic.ReplayConversationRequest} request
185
+ * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration.
186
+ *
187
+ * @throws {@link Phonic.BadRequestError}
188
+ * @throws {@link Phonic.UnauthorizedError}
189
+ * @throws {@link Phonic.ForbiddenError}
190
+ * @throws {@link Phonic.NotFoundError}
191
+ * @throws {@link Phonic.ConflictError}
192
+ * @throws {@link Phonic.UnprocessableEntityError}
193
+ * @throws {@link Phonic.TooManyRequestsError}
194
+ * @throws {@link Phonic.InternalServerError}
195
+ *
196
+ * @example
197
+ * await client.conversations.replay("id", {
198
+ * agent: "support-agent"
199
+ * })
200
+ */
201
+ replay(id: string, request?: Phonic.ReplayConversationRequest, requestOptions?: ConversationsClient.RequestOptions): core.HttpResponsePromise<Phonic.ConversationsReplayResponse>;
202
+ private __replay;
178
203
  /**
179
204
  * Initiates a call to a given phone number using Phonic's Twilio account.
180
205
  *
@@ -553,6 +553,84 @@ export class ConversationsClient {
553
553
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/conversations/{id}/evals");
554
554
  });
555
555
  }
556
+ /**
557
+ * Replays an ended conversation by re-running its recorded audio through an agent. Requires API key or access
558
+ * token authentication. The conversation must have audio recordings available and an associated agent (or one
559
+ * specified in the request body).
560
+ *
561
+ * @param {string} id - The ID of the conversation to replay.
562
+ * @param {Phonic.ReplayConversationRequest} request
563
+ * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration.
564
+ *
565
+ * @throws {@link Phonic.BadRequestError}
566
+ * @throws {@link Phonic.UnauthorizedError}
567
+ * @throws {@link Phonic.ForbiddenError}
568
+ * @throws {@link Phonic.NotFoundError}
569
+ * @throws {@link Phonic.ConflictError}
570
+ * @throws {@link Phonic.UnprocessableEntityError}
571
+ * @throws {@link Phonic.TooManyRequestsError}
572
+ * @throws {@link Phonic.InternalServerError}
573
+ *
574
+ * @example
575
+ * await client.conversations.replay("id", {
576
+ * agent: "support-agent"
577
+ * })
578
+ */
579
+ replay(id, request = {}, requestOptions) {
580
+ return core.HttpResponsePromise.fromPromise(this.__replay(id, request, requestOptions));
581
+ }
582
+ __replay(id_1) {
583
+ return __awaiter(this, arguments, void 0, function* (id, request = {}, requestOptions) {
584
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
585
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
586
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
587
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
588
+ 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)
589
+ .base, `conversations/${core.url.encodePathParam(id)}/replay`),
590
+ method: "POST",
591
+ headers: _headers,
592
+ contentType: "application/json",
593
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
594
+ requestType: "json",
595
+ body: request,
596
+ timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
597
+ maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
598
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
599
+ fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
600
+ logging: this._options.logging,
601
+ });
602
+ if (_response.ok) {
603
+ return { data: _response.body, rawResponse: _response.rawResponse };
604
+ }
605
+ if (_response.error.reason === "status-code") {
606
+ switch (_response.error.statusCode) {
607
+ case 400:
608
+ throw new Phonic.BadRequestError(_response.error.body, _response.rawResponse);
609
+ case 401:
610
+ throw new Phonic.UnauthorizedError(_response.error.body, _response.rawResponse);
611
+ case 403:
612
+ throw new Phonic.ForbiddenError(_response.error.body, _response.rawResponse);
613
+ case 404:
614
+ throw new Phonic.NotFoundError(_response.error.body, _response.rawResponse);
615
+ case 409:
616
+ throw new Phonic.ConflictError(_response.error.body, _response.rawResponse);
617
+ case 422:
618
+ throw new Phonic.UnprocessableEntityError(_response.error.body, _response.rawResponse);
619
+ case 429:
620
+ throw new Phonic.TooManyRequestsError(_response.error.body, _response.rawResponse);
621
+ case 500:
622
+ throw new Phonic.InternalServerError(_response.error.body, _response.rawResponse);
623
+ default:
624
+ throw new errors.PhonicError({
625
+ statusCode: _response.error.statusCode,
626
+ body: _response.error.body,
627
+ rawResponse: _response.rawResponse,
628
+ });
629
+ }
630
+ }
631
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/conversations/{id}/replay");
632
+ });
633
+ }
556
634
  /**
557
635
  * Initiates a call to a given phone number using Phonic's Twilio account.
558
636
  *
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * agent: "support-agent"
5
+ * }
6
+ */
7
+ export interface ReplayConversationRequest {
8
+ /** Name of the agent to replay the conversation with. Defaults to the agent originally associated with the conversation. */
9
+ agent?: string;
10
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -4,3 +4,4 @@ export type { ConversationsSipOutboundCallRequest } from "./ConversationsSipOutb
4
4
  export type { EvaluateConversationRequest } from "./EvaluateConversationRequest.mjs";
5
5
  export type { ExtractDataRequest } from "./ExtractDataRequest.mjs";
6
6
  export type { OutboundCallRequest } from "./OutboundCallRequest.mjs";
7
+ export type { ReplayConversationRequest } from "./ReplayConversationRequest.mjs";