retell-sdk 1.15.21 → 2.2.2

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 (466) hide show
  1. package/README.md +3 -629
  2. package/example.d.ts +2 -0
  3. package/example.d.ts.map +1 -0
  4. package/example.js +74 -0
  5. package/example.js.map +1 -0
  6. package/index.d.ts +3 -0
  7. package/index.d.ts.map +1 -0
  8. package/{dist/index.js → index.js} +2 -0
  9. package/index.js.map +1 -0
  10. package/lib/base64.d.ts +10 -0
  11. package/lib/base64.d.ts.map +1 -0
  12. package/lib/base64.js +61 -0
  13. package/lib/base64.js.map +1 -0
  14. package/lib/config.d.ts +31 -0
  15. package/lib/config.d.ts.map +1 -0
  16. package/lib/config.js +36 -0
  17. package/lib/config.js.map +1 -0
  18. package/lib/encodings.d.ts +41 -0
  19. package/lib/encodings.d.ts.map +1 -0
  20. package/lib/encodings.js +308 -0
  21. package/lib/encodings.js.map +1 -0
  22. package/lib/http.d.ts +45 -0
  23. package/lib/http.d.ts.map +1 -0
  24. package/lib/http.js +136 -0
  25. package/lib/http.js.map +1 -0
  26. package/lib/retries.d.ts +18 -0
  27. package/lib/retries.d.ts.map +1 -0
  28. package/lib/retries.js +136 -0
  29. package/lib/retries.js.map +1 -0
  30. package/lib/sdks.d.ts +32 -0
  31. package/lib/sdks.d.ts.map +1 -0
  32. package/lib/sdks.js +90 -0
  33. package/lib/sdks.js.map +1 -0
  34. package/lib/security.d.ts +57 -0
  35. package/lib/security.d.ts.map +1 -0
  36. package/lib/security.js +99 -0
  37. package/lib/security.js.map +1 -0
  38. package/lib/url.d.ts +4 -0
  39. package/lib/url.d.ts.map +1 -0
  40. package/lib/url.js +26 -0
  41. package/lib/url.js.map +1 -0
  42. package/models/components/agent.d.ts +180 -0
  43. package/models/components/agent.d.ts.map +1 -0
  44. package/models/components/agent.js +182 -0
  45. package/models/components/agent.js.map +1 -0
  46. package/models/components/agentnodefaultnorequired.d.ts +61 -0
  47. package/models/components/agentnodefaultnorequired.d.ts.map +1 -0
  48. package/models/components/agentnodefaultnorequired.js +66 -0
  49. package/models/components/agentnodefaultnorequired.js.map +1 -0
  50. package/models/components/agentpromptparams.d.ts +25 -0
  51. package/models/components/agentpromptparams.d.ts.map +1 -0
  52. package/models/components/agentpromptparams.js +34 -0
  53. package/models/components/agentpromptparams.js.map +1 -0
  54. package/models/components/calldetail.d.ts +92 -0
  55. package/models/components/calldetail.d.ts.map +1 -0
  56. package/models/components/calldetail.js +94 -0
  57. package/models/components/calldetail.js.map +1 -0
  58. package/models/components/callphonenumber.d.ts +28 -0
  59. package/models/components/callphonenumber.d.ts.map +1 -0
  60. package/models/components/callphonenumber.js +34 -0
  61. package/models/components/callphonenumber.js.map +1 -0
  62. package/{dist/models → models}/components/index.d.ts +1 -1
  63. package/models/components/index.d.ts.map +1 -0
  64. package/{dist/models → models}/components/index.js +1 -1
  65. package/models/components/index.js.map +1 -0
  66. package/{dist/models → models}/components/phonenumber.d.ts +22 -2
  67. package/models/components/phonenumber.d.ts.map +1 -0
  68. package/models/components/phonenumber.js +46 -0
  69. package/models/components/phonenumber.js.map +1 -0
  70. package/models/components/security.d.ts +4 -0
  71. package/models/components/security.d.ts.map +1 -0
  72. package/models/components/security.js +6 -0
  73. package/models/components/security.js.map +1 -0
  74. package/models/errors/createagent.d.ts +146 -0
  75. package/models/errors/createagent.d.ts.map +1 -0
  76. package/models/errors/createagent.js +236 -0
  77. package/models/errors/createagent.js.map +1 -0
  78. package/models/errors/createphonecall.d.ts +218 -0
  79. package/models/errors/createphonecall.d.ts.map +1 -0
  80. package/models/errors/createphonecall.js +350 -0
  81. package/models/errors/createphonecall.js.map +1 -0
  82. package/models/errors/createphonenumber.d.ts +182 -0
  83. package/models/errors/createphonenumber.d.ts.map +1 -0
  84. package/models/errors/createphonenumber.js +295 -0
  85. package/models/errors/createphonenumber.js.map +1 -0
  86. package/models/errors/deleteagent.d.ts +146 -0
  87. package/models/errors/deleteagent.d.ts.map +1 -0
  88. package/models/errors/deleteagent.js +236 -0
  89. package/models/errors/deleteagent.js.map +1 -0
  90. package/models/errors/deletephonenumber.d.ts +146 -0
  91. package/models/errors/deletephonenumber.d.ts.map +1 -0
  92. package/models/errors/deletephonenumber.js +238 -0
  93. package/models/errors/deletephonenumber.js.map +1 -0
  94. package/models/errors/getagent.d.ts +146 -0
  95. package/models/errors/getagent.d.ts.map +1 -0
  96. package/models/errors/getagent.js +236 -0
  97. package/models/errors/getagent.js.map +1 -0
  98. package/models/errors/getcall.d.ts +146 -0
  99. package/models/errors/getcall.d.ts.map +1 -0
  100. package/models/errors/getcall.js +240 -0
  101. package/models/errors/getcall.js.map +1 -0
  102. package/models/errors/getphonenumber.d.ts +146 -0
  103. package/models/errors/getphonenumber.d.ts.map +1 -0
  104. package/models/errors/getphonenumber.js +236 -0
  105. package/models/errors/getphonenumber.js.map +1 -0
  106. package/{dist/models → models}/errors/index.d.ts +1 -0
  107. package/models/errors/index.d.ts.map +1 -0
  108. package/{dist/models → models}/errors/index.js +1 -0
  109. package/models/errors/index.js.map +1 -0
  110. package/models/errors/listagents.d.ts +74 -0
  111. package/models/errors/listagents.d.ts.map +1 -0
  112. package/models/errors/listagents.js +124 -0
  113. package/models/errors/listagents.js.map +1 -0
  114. package/models/errors/listcalls.d.ts +110 -0
  115. package/models/errors/listcalls.d.ts.map +1 -0
  116. package/models/errors/listcalls.js +181 -0
  117. package/models/errors/listcalls.js.map +1 -0
  118. package/models/errors/listphonenumbers.d.ts +110 -0
  119. package/models/errors/listphonenumbers.d.ts.map +1 -0
  120. package/models/errors/listphonenumbers.js +179 -0
  121. package/models/errors/listphonenumbers.js.map +1 -0
  122. package/models/errors/sdkerror.d.ts +7 -0
  123. package/models/errors/sdkerror.d.ts.map +1 -0
  124. package/models/errors/sdkerror.js +22 -0
  125. package/models/errors/sdkerror.js.map +1 -0
  126. package/models/errors/updateagent.d.ts +146 -0
  127. package/models/errors/updateagent.d.ts.map +1 -0
  128. package/models/errors/updateagent.js +236 -0
  129. package/models/errors/updateagent.js.map +1 -0
  130. package/models/errors/updatephoneagent.d.ts +146 -0
  131. package/models/errors/updatephoneagent.d.ts.map +1 -0
  132. package/models/errors/updatephoneagent.js +236 -0
  133. package/models/errors/updatephoneagent.js.map +1 -0
  134. package/models/operations/createagent.d.ts +70 -0
  135. package/models/operations/createagent.d.ts.map +1 -0
  136. package/models/operations/createagent.js +102 -0
  137. package/models/operations/createagent.js.map +1 -0
  138. package/models/operations/createphonecall.d.ts +163 -0
  139. package/models/operations/createphonecall.d.ts.map +1 -0
  140. package/models/operations/createphonecall.js +196 -0
  141. package/models/operations/createphonecall.js.map +1 -0
  142. package/models/operations/createphonenumber.d.ts +61 -0
  143. package/models/operations/createphonenumber.d.ts.map +1 -0
  144. package/models/operations/createphonenumber.js +94 -0
  145. package/models/operations/createphonenumber.js.map +1 -0
  146. package/models/operations/createwebcall.d.ts +16 -0
  147. package/models/operations/createwebcall.d.ts.map +1 -0
  148. package/models/operations/createwebcall.js +3 -0
  149. package/models/operations/createwebcall.js.map +1 -0
  150. package/models/operations/deleteagent.d.ts +48 -0
  151. package/models/operations/deleteagent.d.ts.map +1 -0
  152. package/models/operations/deleteagent.js +62 -0
  153. package/models/operations/deleteagent.js.map +1 -0
  154. package/models/operations/deletephonenumber.d.ts +48 -0
  155. package/models/operations/deletephonenumber.d.ts.map +1 -0
  156. package/models/operations/deletephonenumber.js +62 -0
  157. package/models/operations/deletephonenumber.js.map +1 -0
  158. package/models/operations/getagent.d.ts +55 -0
  159. package/models/operations/getagent.d.ts.map +1 -0
  160. package/models/operations/getagent.js +90 -0
  161. package/models/operations/getagent.js.map +1 -0
  162. package/models/operations/getcall.d.ts +55 -0
  163. package/models/operations/getcall.d.ts.map +1 -0
  164. package/models/operations/getcall.js +90 -0
  165. package/models/operations/getcall.js.map +1 -0
  166. package/models/operations/getphonenumber.d.ts +55 -0
  167. package/models/operations/getphonenumber.d.ts.map +1 -0
  168. package/models/operations/getphonenumber.js +90 -0
  169. package/models/operations/getphonenumber.js.map +1 -0
  170. package/{dist/models → models}/operations/index.d.ts +2 -0
  171. package/models/operations/index.d.ts.map +1 -0
  172. package/{dist/models → models}/operations/index.js +2 -0
  173. package/models/operations/index.js.map +1 -0
  174. package/models/operations/listagents.d.ts +38 -0
  175. package/models/operations/listagents.d.ts.map +1 -0
  176. package/models/operations/listagents.js +68 -0
  177. package/models/operations/listagents.js.map +1 -0
  178. package/models/operations/listcalls.d.ts +127 -0
  179. package/models/operations/listcalls.d.ts.map +1 -0
  180. package/models/operations/listcalls.js +174 -0
  181. package/models/operations/listcalls.js.map +1 -0
  182. package/models/operations/listphonenumbers.d.ts +38 -0
  183. package/models/operations/listphonenumbers.d.ts.map +1 -0
  184. package/models/operations/listphonenumbers.js +68 -0
  185. package/models/operations/listphonenumbers.js.map +1 -0
  186. package/models/operations/updateagent.d.ts +90 -0
  187. package/models/operations/updateagent.d.ts.map +1 -0
  188. package/models/operations/updateagent.js +128 -0
  189. package/models/operations/updateagent.js.map +1 -0
  190. package/models/operations/updatephoneagent.d.ts +75 -0
  191. package/models/operations/updatephoneagent.d.ts.map +1 -0
  192. package/models/operations/updatephoneagent.js +116 -0
  193. package/models/operations/updatephoneagent.js.map +1 -0
  194. package/package.json +27 -30
  195. package/sdk/index.d.ts +3 -0
  196. package/sdk/index.d.ts.map +1 -0
  197. package/{dist/sdk → sdk}/index.js +2 -0
  198. package/sdk/index.js.map +1 -0
  199. package/sdk/liveClient.d.ts +14 -0
  200. package/sdk/liveClient.d.ts.map +1 -0
  201. package/sdk/liveClient.js +98 -0
  202. package/sdk/liveClient.js.map +1 -0
  203. package/sdk/sdk.d.ts +62 -0
  204. package/sdk/sdk.d.ts.map +1 -0
  205. package/sdk/sdk.js +1137 -0
  206. package/sdk/sdk.js.map +1 -0
  207. package/src/example.ts +79 -0
  208. package/src/index.ts +6 -0
  209. package/src/lib/base64.ts +37 -0
  210. package/src/lib/config.ts +57 -0
  211. package/src/lib/encodings.ts +379 -0
  212. package/src/lib/http.ts +203 -0
  213. package/src/lib/retries.ts +207 -0
  214. package/src/lib/sdks.ts +107 -0
  215. package/src/lib/security.ts +164 -0
  216. package/src/lib/url.ts +31 -0
  217. package/src/models/components/agent.ts +356 -0
  218. package/src/models/components/agentpromptparams.ts +53 -0
  219. package/src/models/components/calldetail.ts +160 -0
  220. package/src/models/components/callphonenumber.ts +56 -0
  221. package/src/models/components/index.ts +10 -0
  222. package/src/models/components/phonenumber.ts +83 -0
  223. package/src/models/components/security.ts +7 -0
  224. package/src/models/errors/createagent.ts +394 -0
  225. package/src/models/errors/createphonecall.ts +597 -0
  226. package/src/models/errors/createphonenumber.ts +500 -0
  227. package/src/models/errors/deleteagent.ts +394 -0
  228. package/src/models/errors/deletephonenumber.ts +400 -0
  229. package/src/models/errors/getagent.ts +383 -0
  230. package/src/models/errors/getcall.ts +379 -0
  231. package/src/models/errors/getphonenumber.ts +397 -0
  232. package/src/models/errors/index.ts +18 -0
  233. package/src/models/errors/listagents.ts +192 -0
  234. package/src/models/errors/listcalls.ts +289 -0
  235. package/src/models/errors/listphonenumbers.ts +297 -0
  236. package/src/models/errors/sdkerror.ts +24 -0
  237. package/src/models/errors/updateagent.ts +394 -0
  238. package/src/models/errors/updatephoneagent.ts +397 -0
  239. package/src/models/operations/createagent.ts +145 -0
  240. package/src/models/operations/createphonecall.ts +308 -0
  241. package/src/models/operations/createphonenumber.ts +124 -0
  242. package/src/models/operations/createwebcall.ts +16 -0
  243. package/src/models/operations/deleteagent.ts +103 -0
  244. package/src/models/operations/deletephonenumber.ts +103 -0
  245. package/src/models/operations/getagent.ts +114 -0
  246. package/src/models/operations/getcall.ts +114 -0
  247. package/src/models/operations/getphonenumber.ts +114 -0
  248. package/src/models/operations/index.ts +18 -0
  249. package/src/models/operations/listagents.ts +76 -0
  250. package/src/models/operations/listcalls.ts +255 -0
  251. package/src/models/operations/listphonenumbers.ts +76 -0
  252. package/src/models/operations/updateagent.ts +190 -0
  253. package/src/models/operations/updatephoneagent.ts +159 -0
  254. package/src/sdk/index.ts +6 -0
  255. package/src/sdk/liveClient.ts +109 -0
  256. package/src/sdk/sdk.ts +1191 -0
  257. package/src/types/blobs.ts +30 -0
  258. package/src/types/decimal.ts +5 -0
  259. package/src/types/index.ts +8 -0
  260. package/src/types/operations.ts +6 -0
  261. package/src/types/rfcdate.ts +54 -0
  262. package/types/blobs.d.ts +4 -0
  263. package/types/blobs.d.ts.map +1 -0
  264. package/types/blobs.js +52 -0
  265. package/types/blobs.js.map +1 -0
  266. package/types/decimal.d.ts +2 -0
  267. package/types/decimal.d.ts.map +1 -0
  268. package/{dist/types/index.js → types/decimal.js} +2 -1
  269. package/types/decimal.js.map +1 -0
  270. package/types/index.d.ts +5 -0
  271. package/types/index.d.ts.map +1 -0
  272. package/types/index.js +14 -0
  273. package/types/index.js.map +1 -0
  274. package/types/operations.d.ts +5 -0
  275. package/types/operations.d.ts.map +1 -0
  276. package/types/operations.js +6 -0
  277. package/types/operations.js.map +1 -0
  278. package/types/rfcdate.d.ts +21 -0
  279. package/types/rfcdate.d.ts.map +1 -0
  280. package/types/rfcdate.js +46 -0
  281. package/types/rfcdate.js.map +1 -0
  282. package/dist/index.d.ts +0 -1
  283. package/dist/internal/utils/contenttype.d.ts +0 -1
  284. package/dist/internal/utils/contenttype.js +0 -33
  285. package/dist/internal/utils/headers.d.ts +0 -4
  286. package/dist/internal/utils/headers.js +0 -92
  287. package/dist/internal/utils/index.d.ts +0 -8
  288. package/dist/internal/utils/index.js +0 -27
  289. package/dist/internal/utils/pathparams.d.ts +0 -2
  290. package/dist/internal/utils/pathparams.js +0 -53
  291. package/dist/internal/utils/queryparams.d.ts +0 -2
  292. package/dist/internal/utils/queryparams.js +0 -182
  293. package/dist/internal/utils/requestbody.d.ts +0 -2
  294. package/dist/internal/utils/requestbody.js +0 -328
  295. package/dist/internal/utils/retries.d.ts +0 -20
  296. package/dist/internal/utils/retries.js +0 -250
  297. package/dist/internal/utils/security.d.ts +0 -5
  298. package/dist/internal/utils/security.js +0 -196
  299. package/dist/internal/utils/utils.d.ts +0 -37
  300. package/dist/internal/utils/utils.js +0 -368
  301. package/dist/models/components/agent.d.ts +0 -43
  302. package/dist/models/components/agent.js +0 -90
  303. package/dist/models/components/agentnodefaultnorequired.d.ts +0 -35
  304. package/dist/models/components/agentnodefaultnorequired.js +0 -80
  305. package/dist/models/components/agentpromptparams.d.ts +0 -11
  306. package/dist/models/components/agentpromptparams.js +0 -50
  307. package/dist/models/components/calldetail.d.ts +0 -58
  308. package/dist/models/components/calldetail.js +0 -112
  309. package/dist/models/components/callphonenumber.d.ts +0 -14
  310. package/dist/models/components/callphonenumber.js +0 -53
  311. package/dist/models/components/phonenumber.js +0 -65
  312. package/dist/models/components/security.d.ts +0 -4
  313. package/dist/models/components/security.js +0 -45
  314. package/dist/models/errors/createagent.d.ts +0 -45
  315. package/dist/models/errors/createagent.js +0 -144
  316. package/dist/models/errors/createphonecall.d.ts +0 -67
  317. package/dist/models/errors/createphonecall.js +0 -200
  318. package/dist/models/errors/createphonenumber.d.ts +0 -56
  319. package/dist/models/errors/createphonenumber.js +0 -172
  320. package/dist/models/errors/deleteagent.d.ts +0 -45
  321. package/dist/models/errors/deleteagent.js +0 -144
  322. package/dist/models/errors/deletephonenumber.d.ts +0 -45
  323. package/dist/models/errors/deletephonenumber.js +0 -144
  324. package/dist/models/errors/getagent.d.ts +0 -45
  325. package/dist/models/errors/getagent.js +0 -144
  326. package/dist/models/errors/getcall.d.ts +0 -45
  327. package/dist/models/errors/getcall.js +0 -144
  328. package/dist/models/errors/getphonenumber.d.ts +0 -45
  329. package/dist/models/errors/getphonenumber.js +0 -144
  330. package/dist/models/errors/listagents.d.ts +0 -23
  331. package/dist/models/errors/listagents.js +0 -88
  332. package/dist/models/errors/listcalls.d.ts +0 -34
  333. package/dist/models/errors/listcalls.js +0 -116
  334. package/dist/models/errors/listphonenumbers.d.ts +0 -34
  335. package/dist/models/errors/listphonenumbers.js +0 -116
  336. package/dist/models/errors/sdkerror.d.ts +0 -7
  337. package/dist/models/errors/sdkerror.js +0 -40
  338. package/dist/models/errors/updateagent.d.ts +0 -45
  339. package/dist/models/errors/updateagent.js +0 -144
  340. package/dist/models/errors/updatephoneagent.d.ts +0 -45
  341. package/dist/models/errors/updatephoneagent.js +0 -144
  342. package/dist/models/operations/createagent.d.ts +0 -55
  343. package/dist/models/operations/createagent.js +0 -128
  344. package/dist/models/operations/createphonecall.d.ts +0 -87
  345. package/dist/models/operations/createphonecall.js +0 -187
  346. package/dist/models/operations/createphonenumber.d.ts +0 -31
  347. package/dist/models/operations/createphonenumber.js +0 -98
  348. package/dist/models/operations/deleteagent.d.ts +0 -22
  349. package/dist/models/operations/deleteagent.js +0 -63
  350. package/dist/models/operations/deletephonenumber.d.ts +0 -22
  351. package/dist/models/operations/deletephonenumber.js +0 -63
  352. package/dist/models/operations/getagent.d.ts +0 -27
  353. package/dist/models/operations/getagent.js +0 -91
  354. package/dist/models/operations/getcall.d.ts +0 -27
  355. package/dist/models/operations/getcall.js +0 -91
  356. package/dist/models/operations/getphonenumber.d.ts +0 -27
  357. package/dist/models/operations/getphonenumber.js +0 -91
  358. package/dist/models/operations/listagents.d.ts +0 -21
  359. package/dist/models/operations/listagents.js +0 -79
  360. package/dist/models/operations/listcalls.d.ts +0 -70
  361. package/dist/models/operations/listcalls.js +0 -145
  362. package/dist/models/operations/listphonenumbers.d.ts +0 -21
  363. package/dist/models/operations/listphonenumbers.js +0 -79
  364. package/dist/models/operations/updateagent.d.ts +0 -28
  365. package/dist/models/operations/updateagent.js +0 -95
  366. package/dist/models/operations/updatephoneagent.d.ts +0 -34
  367. package/dist/models/operations/updatephoneagent.js +0 -109
  368. package/dist/sdk/index.d.ts +0 -1
  369. package/dist/sdk/sdk.d.ts +0 -115
  370. package/dist/sdk/sdk.js +0 -1625
  371. package/dist/types/index.d.ts +0 -1
  372. package/dist/types/rfcdate.d.ts +0 -9
  373. package/dist/types/rfcdate.js +0 -59
  374. package/docs/models/components/agent.md +0 -17
  375. package/docs/models/components/agentnodefaultnorequired.md +0 -15
  376. package/docs/models/components/agentpromptparams.md +0 -9
  377. package/docs/models/components/calldetail.md +0 -17
  378. package/docs/models/components/callphonenumber.md +0 -11
  379. package/docs/models/components/callstatus.md +0 -12
  380. package/docs/models/components/calltype.md +0 -12
  381. package/docs/models/components/phonenumber.md +0 -12
  382. package/docs/models/components/security.md +0 -8
  383. package/docs/models/errors/createagentresponse422responsebody.md +0 -11
  384. package/docs/models/errors/createagentresponse500responsebody.md +0 -11
  385. package/docs/models/errors/createagentresponsebody.md +0 -11
  386. package/docs/models/errors/createagentresponseresponsebody.md +0 -11
  387. package/docs/models/errors/createphonecallresponse402responsebody.md +0 -11
  388. package/docs/models/errors/createphonecallresponse422responsebody.md +0 -11
  389. package/docs/models/errors/createphonecallresponse429responsebody.md +0 -11
  390. package/docs/models/errors/createphonecallresponse500responsebody.md +0 -11
  391. package/docs/models/errors/createphonecallresponsebody.md +0 -11
  392. package/docs/models/errors/createphonecallresponseresponsebody.md +0 -11
  393. package/docs/models/errors/createphonenumberresponse402responsebody.md +0 -11
  394. package/docs/models/errors/createphonenumberresponse422responsebody.md +0 -11
  395. package/docs/models/errors/createphonenumberresponse500responsebody.md +0 -11
  396. package/docs/models/errors/createphonenumberresponsebody.md +0 -11
  397. package/docs/models/errors/createphonenumberresponseresponsebody.md +0 -11
  398. package/docs/models/errors/deleteagentresponse422responsebody.md +0 -11
  399. package/docs/models/errors/deleteagentresponse500responsebody.md +0 -11
  400. package/docs/models/errors/deleteagentresponsebody.md +0 -11
  401. package/docs/models/errors/deleteagentresponseresponsebody.md +0 -11
  402. package/docs/models/errors/deletephonenumberresponse422responsebody.md +0 -11
  403. package/docs/models/errors/deletephonenumberresponse500responsebody.md +0 -11
  404. package/docs/models/errors/deletephonenumberresponsebody.md +0 -11
  405. package/docs/models/errors/deletephonenumberresponseresponsebody.md +0 -11
  406. package/docs/models/errors/getagentresponse422responsebody.md +0 -11
  407. package/docs/models/errors/getagentresponse500responsebody.md +0 -11
  408. package/docs/models/errors/getagentresponsebody.md +0 -11
  409. package/docs/models/errors/getagentresponseresponsebody.md +0 -11
  410. package/docs/models/errors/getcallresponse422responsebody.md +0 -11
  411. package/docs/models/errors/getcallresponse500responsebody.md +0 -11
  412. package/docs/models/errors/getcallresponsebody.md +0 -11
  413. package/docs/models/errors/getcallresponseresponsebody.md +0 -11
  414. package/docs/models/errors/getphonenumberresponse422responsebody.md +0 -11
  415. package/docs/models/errors/getphonenumberresponse500responsebody.md +0 -11
  416. package/docs/models/errors/getphonenumberresponsebody.md +0 -11
  417. package/docs/models/errors/getphonenumberresponseresponsebody.md +0 -11
  418. package/docs/models/errors/listagentsresponsebody.md +0 -11
  419. package/docs/models/errors/listagentsresponseresponsebody.md +0 -11
  420. package/docs/models/errors/listcallsresponse500responsebody.md +0 -11
  421. package/docs/models/errors/listcallsresponsebody.md +0 -11
  422. package/docs/models/errors/listcallsresponseresponsebody.md +0 -11
  423. package/docs/models/errors/listphonenumbersresponse500responsebody.md +0 -11
  424. package/docs/models/errors/listphonenumbersresponsebody.md +0 -11
  425. package/docs/models/errors/listphonenumbersresponseresponsebody.md +0 -11
  426. package/docs/models/errors/updateagentresponse422responsebody.md +0 -11
  427. package/docs/models/errors/updateagentresponse500responsebody.md +0 -11
  428. package/docs/models/errors/updateagentresponsebody.md +0 -11
  429. package/docs/models/errors/updateagentresponseresponsebody.md +0 -11
  430. package/docs/models/errors/updatephoneagentresponse422responsebody.md +0 -11
  431. package/docs/models/errors/updatephoneagentresponse500responsebody.md +0 -11
  432. package/docs/models/errors/updatephoneagentresponsebody.md +0 -11
  433. package/docs/models/errors/updatephoneagentresponseresponsebody.md +0 -11
  434. package/docs/models/operations/callstatus.md +0 -12
  435. package/docs/models/operations/calltype.md +0 -10
  436. package/docs/models/operations/createagentrequestbody.md +0 -15
  437. package/docs/models/operations/createagentresponse.md +0 -11
  438. package/docs/models/operations/createphonecallcalltype.md +0 -12
  439. package/docs/models/operations/createphonecallrequestbody.md +0 -9
  440. package/docs/models/operations/createphonecallresponse.md +0 -11
  441. package/docs/models/operations/createphonecallresponsebody.md +0 -16
  442. package/docs/models/operations/createphonenumberrequestbody.md +0 -9
  443. package/docs/models/operations/createphonenumberresponse.md +0 -11
  444. package/docs/models/operations/deleteagentrequest.md +0 -8
  445. package/docs/models/operations/deleteagentresponse.md +0 -10
  446. package/docs/models/operations/deletephonenumberrequest.md +0 -8
  447. package/docs/models/operations/deletephonenumberresponse.md +0 -10
  448. package/docs/models/operations/filtercriteria.md +0 -13
  449. package/docs/models/operations/getagentrequest.md +0 -8
  450. package/docs/models/operations/getagentresponse.md +0 -11
  451. package/docs/models/operations/getcallrequest.md +0 -8
  452. package/docs/models/operations/getcallresponse.md +0 -11
  453. package/docs/models/operations/getphonenumberrequest.md +0 -8
  454. package/docs/models/operations/getphonenumberresponse.md +0 -11
  455. package/docs/models/operations/listagentsresponse.md +0 -11
  456. package/docs/models/operations/listcallsrequest.md +0 -10
  457. package/docs/models/operations/listcallsresponse.md +0 -11
  458. package/docs/models/operations/listphonenumbersresponse.md +0 -11
  459. package/docs/models/operations/phonenumber.md +0 -11
  460. package/docs/models/operations/sortorder.md +0 -11
  461. package/docs/models/operations/updateagentrequest.md +0 -9
  462. package/docs/models/operations/updateagentresponse.md +0 -11
  463. package/docs/models/operations/updatephoneagentrequest.md +0 -9
  464. package/docs/models/operations/updatephoneagentrequestbody.md +0 -8
  465. package/docs/models/operations/updatephoneagentresponse.md +0 -11
  466. package/docs/sdks/retellclient/README.md +0 -673
package/dist/sdk/sdk.js DELETED
@@ -1,1625 +0,0 @@
1
- "use strict";
2
- /*
3
- * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
4
- */
5
- var __extends = (this && this.__extends) || (function () {
6
- var extendStatics = function (d, b) {
7
- extendStatics = Object.setPrototypeOf ||
8
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
9
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
10
- return extendStatics(d, b);
11
- };
12
- return function (d, b) {
13
- if (typeof b !== "function" && b !== null)
14
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
15
- extendStatics(d, b);
16
- function __() { this.constructor = d; }
17
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
18
- };
19
- })();
20
- var __assign = (this && this.__assign) || function () {
21
- __assign = Object.assign || function(t) {
22
- for (var s, i = 1, n = arguments.length; i < n; i++) {
23
- s = arguments[i];
24
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
25
- t[p] = s[p];
26
- }
27
- return t;
28
- };
29
- return __assign.apply(this, arguments);
30
- };
31
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
32
- if (k2 === undefined) k2 = k;
33
- var desc = Object.getOwnPropertyDescriptor(m, k);
34
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
35
- desc = { enumerable: true, get: function() { return m[k]; } };
36
- }
37
- Object.defineProperty(o, k2, desc);
38
- }) : (function(o, m, k, k2) {
39
- if (k2 === undefined) k2 = k;
40
- o[k2] = m[k];
41
- }));
42
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
43
- Object.defineProperty(o, "default", { enumerable: true, value: v });
44
- }) : function(o, v) {
45
- o["default"] = v;
46
- });
47
- var __importStar = (this && this.__importStar) || function (mod) {
48
- if (mod && mod.__esModule) return mod;
49
- var result = {};
50
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
51
- __setModuleDefault(result, mod);
52
- return result;
53
- };
54
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
55
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
56
- return new (P || (P = Promise))(function (resolve, reject) {
57
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
58
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
59
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
60
- step((generator = generator.apply(thisArg, _arguments || [])).next());
61
- });
62
- };
63
- var __generator = (this && this.__generator) || function (thisArg, body) {
64
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
65
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
66
- function verb(n) { return function (v) { return step([n, v]); }; }
67
- function step(op) {
68
- if (f) throw new TypeError("Generator is already executing.");
69
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
70
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
71
- if (y = 0, t) op = [op[0] & 2, t.value];
72
- switch (op[0]) {
73
- case 0: case 1: t = op; break;
74
- case 4: _.label++; return { value: op[1], done: false };
75
- case 5: _.label++; y = op[1]; op = [0]; continue;
76
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
77
- default:
78
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
79
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
80
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
81
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
82
- if (t[2]) _.ops.pop();
83
- _.trys.pop(); continue;
84
- }
85
- op = body.call(thisArg, _);
86
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
87
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
88
- }
89
- };
90
- var __values = (this && this.__values) || function(o) {
91
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
92
- if (m) return m.call(o);
93
- if (o && typeof o.length === "number") return {
94
- next: function () {
95
- if (o && i >= o.length) o = void 0;
96
- return { value: o && o[i++], done: !o };
97
- }
98
- };
99
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
100
- };
101
- var __read = (this && this.__read) || function (o, n) {
102
- var m = typeof Symbol === "function" && o[Symbol.iterator];
103
- if (!m) return o;
104
- var i = m.call(o), r, ar = [], e;
105
- try {
106
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
107
- }
108
- catch (error) { e = { error: error }; }
109
- finally {
110
- try {
111
- if (r && !r.done && (m = i["return"])) m.call(i);
112
- }
113
- finally { if (e) throw e.error; }
114
- }
115
- return ar;
116
- };
117
- var __importDefault = (this && this.__importDefault) || function (mod) {
118
- return (mod && mod.__esModule) ? mod : { "default": mod };
119
- };
120
- Object.defineProperty(exports, "__esModule", { value: true });
121
- exports.RetellClient = exports.convertFloat32ToPCM16 = exports.convertPCM16ToFloat32 = exports.LiveClient = exports.SDKConfiguration = exports.ServerList = void 0;
122
- var utils = __importStar(require("../internal/utils"));
123
- var components = __importStar(require("../models/components"));
124
- var errors = __importStar(require("../models/errors"));
125
- var operations = __importStar(require("../models/operations"));
126
- var axios_1 = __importDefault(require("axios"));
127
- var events_1 = require("events");
128
- /**
129
- * Contains the list of servers available to the SDK
130
- */
131
- exports.ServerList = [
132
- /**
133
- * The production server.
134
- */
135
- "https://api.re-tell.ai",
136
- ];
137
- var SDKConfiguration = /** @class */ (function () {
138
- function SDKConfiguration(init) {
139
- this.language = "typescript";
140
- this.openapiDocVersion = "1.0.0";
141
- this.sdkVersion = "1.15.9";
142
- this.genVersion = "2.207.1";
143
- Object.assign(this, init);
144
- }
145
- return SDKConfiguration;
146
- }());
147
- exports.SDKConfiguration = SDKConfiguration;
148
- var LiveClient = /** @class */ (function (_super) {
149
- __extends(LiveClient, _super);
150
- function LiveClient(apiKey, agentId, sampleRate, agentPromptParams, baseEndpoint) {
151
- var e_1, _a;
152
- var _this = _super.call(this) || this;
153
- var endpoint = baseEndpoint +
154
- "/create-web-call?api_key=" +
155
- apiKey +
156
- "&agent_id=" +
157
- agentId +
158
- "&sample_rate=" +
159
- sampleRate;
160
- try {
161
- for (var agentPromptParams_1 = __values(agentPromptParams), agentPromptParams_1_1 = agentPromptParams_1.next(); !agentPromptParams_1_1.done; agentPromptParams_1_1 = agentPromptParams_1.next()) {
162
- var param = agentPromptParams_1_1.value;
163
- endpoint += "&agent_prompt_params=" + JSON.stringify(param);
164
- }
165
- }
166
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
167
- finally {
168
- try {
169
- if (agentPromptParams_1_1 && !agentPromptParams_1_1.done && (_a = agentPromptParams_1.return)) _a.call(agentPromptParams_1);
170
- }
171
- finally { if (e_1) throw e_1.error; }
172
- }
173
- _this.ws = new WebSocket(endpoint);
174
- _this.ws.binaryType = "arraybuffer";
175
- return _this;
176
- }
177
- LiveClient.prototype.waitForReady = function () {
178
- var _this = this;
179
- return new Promise(function (resolve, reject) {
180
- var onError = function (error) {
181
- reject(error); // Reject on error
182
- };
183
- _this.ws.onerror = onError;
184
- var onClose = function () {
185
- reject("websocket closed before ready.");
186
- };
187
- _this.ws.onclose = onClose;
188
- var onMessage = function (event) {
189
- try {
190
- var data = JSON.parse(event.data);
191
- if (data.status === "ready") {
192
- // Remove all registered listeners for cleaner future processing.
193
- _this.ws.removeEventListener("error", onError);
194
- _this.ws.removeEventListener("close", onClose);
195
- _this.ws.removeEventListener("message", onMessage);
196
- // Emit audio
197
- _this.ws.onmessage = function (event) {
198
- var audio = event.data;
199
- _this.emit("audio", new Uint8Array(audio));
200
- };
201
- _this.ws.onclose = function (event) {
202
- _this.emit("close", event);
203
- };
204
- resolve(); // Resolve when the ready message is received
205
- }
206
- }
207
- catch (error) {
208
- // Handle JSON parsing error
209
- reject("malformed ready event.");
210
- }
211
- };
212
- _this.ws.onmessage = onMessage;
213
- });
214
- };
215
- LiveClient.prototype.send = function (audio) {
216
- if (this.ws.readyState === 1)
217
- this.ws.send(audio);
218
- };
219
- LiveClient.prototype.close = function () {
220
- this.ws.close();
221
- };
222
- return LiveClient;
223
- }(events_1.EventEmitter));
224
- exports.LiveClient = LiveClient;
225
- function convertPCM16ToFloat32(array) {
226
- var targetArray = new Float32Array(array.byteLength / 2);
227
- // A DataView is used to read our 16-bit little-endian samples out of the Uint8Array buffer
228
- var sourceDataView = new DataView(array.buffer);
229
- // Loop through, get values, and divide by 32,768
230
- for (var i = 0; i < targetArray.length; i++) {
231
- targetArray[i] = sourceDataView.getInt16(i * 2, true) / Math.pow(2, 16 - 1);
232
- }
233
- return targetArray;
234
- }
235
- exports.convertPCM16ToFloat32 = convertPCM16ToFloat32;
236
- function convertFloat32ToPCM16(array) {
237
- var buffer = new ArrayBuffer(array.length * 2);
238
- var view = new DataView(buffer);
239
- for (var i = 0; i < array.length; i++) {
240
- var value = array[i] * 32768;
241
- view.setInt16(i * 2, value, true); // true for little-endian
242
- }
243
- return new Uint8Array(buffer);
244
- }
245
- exports.convertFloat32ToPCM16 = convertFloat32ToPCM16;
246
- var RetellClient = /** @class */ (function () {
247
- function RetellClient(props) {
248
- var _a, _b;
249
- var serverURL = props === null || props === void 0 ? void 0 : props.serverURL;
250
- var serverIdx = (_a = props === null || props === void 0 ? void 0 : props.serverIdx) !== null && _a !== void 0 ? _a : 0;
251
- if (!serverURL) {
252
- serverURL = exports.ServerList[serverIdx];
253
- }
254
- var defaultClient = (_b = props === null || props === void 0 ? void 0 : props.defaultClient) !== null && _b !== void 0 ? _b : axios_1.default.create();
255
- this.sdkConfiguration = new SDKConfiguration({
256
- defaultClient: defaultClient,
257
- security: new components.Security({ apiKey: props === null || props === void 0 ? void 0 : props.apiKey }),
258
- serverURL: serverURL,
259
- retryConfig: props === null || props === void 0 ? void 0 : props.retryConfig,
260
- });
261
- }
262
- RetellClient.prototype.createWebCall = function (apikey, agentId, sampleRate, agentPromptParams, websocketEndpoint) {
263
- if (sampleRate === void 0) { sampleRate = 16000; }
264
- if (agentPromptParams === void 0) { agentPromptParams = []; }
265
- if (websocketEndpoint === void 0) { websocketEndpoint = "wss://api.re-tell.ai"; }
266
- return __awaiter(this, void 0, void 0, function () {
267
- var liveClient;
268
- return __generator(this, function (_a) {
269
- switch (_a.label) {
270
- case 0:
271
- liveClient = new LiveClient(apikey, agentId, sampleRate, agentPromptParams, websocketEndpoint);
272
- return [4 /*yield*/, liveClient.waitForReady()];
273
- case 1:
274
- _a.sent();
275
- return [2 /*return*/, liveClient];
276
- }
277
- });
278
- });
279
- };
280
- /**
281
- * Create a new agent
282
- */
283
- RetellClient.prototype.createAgent = function (req, config) {
284
- var _a, _b;
285
- return __awaiter(this, void 0, void 0, function () {
286
- var baseURL, operationUrl, _c, reqBodyHeaders, reqBody, client, globalSecurity, properties, headers, httpRes, responseContentType, res, decodedRes, err, err, err, err;
287
- var _d;
288
- return __generator(this, function (_e) {
289
- switch (_e.label) {
290
- case 0:
291
- if (!(req instanceof utils.SpeakeasyBase)) {
292
- req = new operations.CreateAgentRequestBody(req);
293
- }
294
- baseURL = utils.templateUrl(this.sdkConfiguration.serverURL, this.sdkConfiguration.serverDefaults);
295
- operationUrl = baseURL.replace(/\/$/, "") + "/create-agent";
296
- _c = __read([{}, null], 2), reqBodyHeaders = _c[0], reqBody = _c[1];
297
- try {
298
- _d = __read(utils.serializeRequestBody(req, "request", "json"), 2), reqBodyHeaders = _d[0], reqBody = _d[1];
299
- }
300
- catch (e) {
301
- if (e instanceof Error) {
302
- throw new Error("Error serializing request body, cause: ".concat(e.message));
303
- }
304
- }
305
- client = this.sdkConfiguration.defaultClient;
306
- globalSecurity = this.sdkConfiguration.security;
307
- if (!(typeof globalSecurity === "function")) return [3 /*break*/, 2];
308
- return [4 /*yield*/, globalSecurity()];
309
- case 1:
310
- globalSecurity = _e.sent();
311
- _e.label = 2;
312
- case 2:
313
- if (!(globalSecurity instanceof utils.SpeakeasyBase)) {
314
- globalSecurity = new components.Security(globalSecurity);
315
- }
316
- properties = utils.parseSecurityProperties(globalSecurity);
317
- headers = __assign(__assign(__assign({}, reqBodyHeaders), config === null || config === void 0 ? void 0 : config.headers), properties.headers);
318
- if (reqBody == null)
319
- throw new Error("request body is required");
320
- headers["Accept"] = "application/json";
321
- return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: operationUrl, method: "post", headers: headers, responseType: "arraybuffer", data: reqBody }, config))];
322
- case 3:
323
- httpRes = _e.sent();
324
- responseContentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
325
- if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
326
- throw new Error("status code not found in response: ".concat(httpRes));
327
- }
328
- res = new operations.CreateAgentResponse({
329
- statusCode: httpRes.status,
330
- contentType: responseContentType,
331
- rawResponse: httpRes,
332
- });
333
- decodedRes = new TextDecoder().decode(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data);
334
- switch (true) {
335
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 201:
336
- if (utils.matchContentType(responseContentType, "application/json")) {
337
- res.agent = utils.objectToClass(JSON.parse(decodedRes), components.Agent);
338
- }
339
- else {
340
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
341
- }
342
- break;
343
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 400:
344
- if (utils.matchContentType(responseContentType, "application/json")) {
345
- err = utils.objectToClass(JSON.parse(decodedRes), errors.CreateAgentResponseBody);
346
- err.rawResponse = httpRes;
347
- throw new errors.CreateAgentResponseBody(err);
348
- }
349
- else {
350
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
351
- }
352
- break;
353
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 401:
354
- if (utils.matchContentType(responseContentType, "application/json")) {
355
- err = utils.objectToClass(JSON.parse(decodedRes), errors.CreateAgentResponseResponseBody);
356
- err.rawResponse = httpRes;
357
- throw new errors.CreateAgentResponseResponseBody(err);
358
- }
359
- else {
360
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
361
- }
362
- break;
363
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 422:
364
- if (utils.matchContentType(responseContentType, "application/json")) {
365
- err = utils.objectToClass(JSON.parse(decodedRes), errors.CreateAgentResponse422ResponseBody);
366
- err.rawResponse = httpRes;
367
- throw new errors.CreateAgentResponse422ResponseBody(err);
368
- }
369
- else {
370
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
371
- }
372
- break;
373
- case ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 400 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 500) ||
374
- ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 500 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 600):
375
- throw new errors.SDKError("API error occurred", httpRes.status, decodedRes, httpRes);
376
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 500:
377
- if (utils.matchContentType(responseContentType, "application/json")) {
378
- err = utils.objectToClass(JSON.parse(decodedRes), errors.CreateAgentResponse500ResponseBody);
379
- err.rawResponse = httpRes;
380
- throw new errors.CreateAgentResponse500ResponseBody(err);
381
- }
382
- else {
383
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
384
- }
385
- break;
386
- }
387
- return [2 /*return*/, res];
388
- }
389
- });
390
- });
391
- };
392
- /**
393
- * Initiate an outbound phone call.
394
- */
395
- RetellClient.prototype.createPhoneCall = function (req, config) {
396
- var _a, _b;
397
- return __awaiter(this, void 0, void 0, function () {
398
- var baseURL, operationUrl, _c, reqBodyHeaders, reqBody, client, globalSecurity, properties, headers, httpRes, responseContentType, res, decodedRes, err, err, err, err, err, err;
399
- var _d;
400
- return __generator(this, function (_e) {
401
- switch (_e.label) {
402
- case 0:
403
- if (!(req instanceof utils.SpeakeasyBase)) {
404
- req = new operations.CreatePhoneCallRequestBody(req);
405
- }
406
- baseURL = utils.templateUrl(this.sdkConfiguration.serverURL, this.sdkConfiguration.serverDefaults);
407
- operationUrl = baseURL.replace(/\/$/, "") + "/create-phone-call";
408
- _c = __read([{}, null], 2), reqBodyHeaders = _c[0], reqBody = _c[1];
409
- try {
410
- _d = __read(utils.serializeRequestBody(req, "request", "json"), 2), reqBodyHeaders = _d[0], reqBody = _d[1];
411
- }
412
- catch (e) {
413
- if (e instanceof Error) {
414
- throw new Error("Error serializing request body, cause: ".concat(e.message));
415
- }
416
- }
417
- client = this.sdkConfiguration.defaultClient;
418
- globalSecurity = this.sdkConfiguration.security;
419
- if (!(typeof globalSecurity === "function")) return [3 /*break*/, 2];
420
- return [4 /*yield*/, globalSecurity()];
421
- case 1:
422
- globalSecurity = _e.sent();
423
- _e.label = 2;
424
- case 2:
425
- if (!(globalSecurity instanceof utils.SpeakeasyBase)) {
426
- globalSecurity = new components.Security(globalSecurity);
427
- }
428
- properties = utils.parseSecurityProperties(globalSecurity);
429
- headers = __assign(__assign(__assign({}, reqBodyHeaders), config === null || config === void 0 ? void 0 : config.headers), properties.headers);
430
- if (reqBody == null)
431
- throw new Error("request body is required");
432
- headers["Accept"] = "application/json";
433
- return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: operationUrl, method: "post", headers: headers, responseType: "arraybuffer", data: reqBody }, config))];
434
- case 3:
435
- httpRes = _e.sent();
436
- responseContentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
437
- if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
438
- throw new Error("status code not found in response: ".concat(httpRes));
439
- }
440
- res = new operations.CreatePhoneCallResponse({
441
- statusCode: httpRes.status,
442
- contentType: responseContentType,
443
- rawResponse: httpRes,
444
- });
445
- decodedRes = new TextDecoder().decode(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data);
446
- switch (true) {
447
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 201:
448
- if (utils.matchContentType(responseContentType, "application/json")) {
449
- res.object = utils.objectToClass(JSON.parse(decodedRes), operations.CreatePhoneCallResponseBody);
450
- }
451
- else {
452
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
453
- }
454
- break;
455
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 400:
456
- if (utils.matchContentType(responseContentType, "application/json")) {
457
- err = utils.objectToClass(JSON.parse(decodedRes), errors.CreatePhoneCallResponseBody);
458
- err.rawResponse = httpRes;
459
- throw new errors.CreatePhoneCallResponseBody(err);
460
- }
461
- else {
462
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
463
- }
464
- break;
465
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 401:
466
- if (utils.matchContentType(responseContentType, "application/json")) {
467
- err = utils.objectToClass(JSON.parse(decodedRes), errors.CreatePhoneCallResponseResponseBody);
468
- err.rawResponse = httpRes;
469
- throw new errors.CreatePhoneCallResponseResponseBody(err);
470
- }
471
- else {
472
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
473
- }
474
- break;
475
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 402:
476
- if (utils.matchContentType(responseContentType, "application/json")) {
477
- err = utils.objectToClass(JSON.parse(decodedRes), errors.CreatePhoneCallResponse402ResponseBody);
478
- err.rawResponse = httpRes;
479
- throw new errors.CreatePhoneCallResponse402ResponseBody(err);
480
- }
481
- else {
482
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
483
- }
484
- break;
485
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 422:
486
- if (utils.matchContentType(responseContentType, "application/json")) {
487
- err = utils.objectToClass(JSON.parse(decodedRes), errors.CreatePhoneCallResponse422ResponseBody);
488
- err.rawResponse = httpRes;
489
- throw new errors.CreatePhoneCallResponse422ResponseBody(err);
490
- }
491
- else {
492
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
493
- }
494
- break;
495
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 429:
496
- if (utils.matchContentType(responseContentType, "application/json")) {
497
- err = utils.objectToClass(JSON.parse(decodedRes), errors.CreatePhoneCallResponse429ResponseBody);
498
- err.rawResponse = httpRes;
499
- throw new errors.CreatePhoneCallResponse429ResponseBody(err);
500
- }
501
- else {
502
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
503
- }
504
- break;
505
- case ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 400 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 500) ||
506
- ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 500 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 600):
507
- throw new errors.SDKError("API error occurred", httpRes.status, decodedRes, httpRes);
508
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 500:
509
- if (utils.matchContentType(responseContentType, "application/json")) {
510
- err = utils.objectToClass(JSON.parse(decodedRes), errors.CreatePhoneCallResponse500ResponseBody);
511
- err.rawResponse = httpRes;
512
- throw new errors.CreatePhoneCallResponse500ResponseBody(err);
513
- }
514
- else {
515
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
516
- }
517
- break;
518
- }
519
- return [2 /*return*/, res];
520
- }
521
- });
522
- });
523
- };
524
- /**
525
- * Create a new phone number
526
- */
527
- RetellClient.prototype.createPhoneNumber = function (req, config) {
528
- var _a, _b;
529
- return __awaiter(this, void 0, void 0, function () {
530
- var baseURL, operationUrl, _c, reqBodyHeaders, reqBody, client, globalSecurity, properties, headers, httpRes, responseContentType, res, decodedRes, err, err, err, err, err;
531
- var _d;
532
- return __generator(this, function (_e) {
533
- switch (_e.label) {
534
- case 0:
535
- if (!(req instanceof utils.SpeakeasyBase)) {
536
- req = new operations.CreatePhoneNumberRequestBody(req);
537
- }
538
- baseURL = utils.templateUrl(this.sdkConfiguration.serverURL, this.sdkConfiguration.serverDefaults);
539
- operationUrl = baseURL.replace(/\/$/, "") + "/create-phone-number";
540
- _c = __read([{}, null], 2), reqBodyHeaders = _c[0], reqBody = _c[1];
541
- try {
542
- _d = __read(utils.serializeRequestBody(req, "request", "json"), 2), reqBodyHeaders = _d[0], reqBody = _d[1];
543
- }
544
- catch (e) {
545
- if (e instanceof Error) {
546
- throw new Error("Error serializing request body, cause: ".concat(e.message));
547
- }
548
- }
549
- client = this.sdkConfiguration.defaultClient;
550
- globalSecurity = this.sdkConfiguration.security;
551
- if (!(typeof globalSecurity === "function")) return [3 /*break*/, 2];
552
- return [4 /*yield*/, globalSecurity()];
553
- case 1:
554
- globalSecurity = _e.sent();
555
- _e.label = 2;
556
- case 2:
557
- if (!(globalSecurity instanceof utils.SpeakeasyBase)) {
558
- globalSecurity = new components.Security(globalSecurity);
559
- }
560
- properties = utils.parseSecurityProperties(globalSecurity);
561
- headers = __assign(__assign(__assign({}, reqBodyHeaders), config === null || config === void 0 ? void 0 : config.headers), properties.headers);
562
- if (reqBody == null)
563
- throw new Error("request body is required");
564
- headers["Accept"] = "application/json";
565
- return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: operationUrl, method: "post", headers: headers, responseType: "arraybuffer", data: reqBody }, config))];
566
- case 3:
567
- httpRes = _e.sent();
568
- responseContentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
569
- if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
570
- throw new Error("status code not found in response: ".concat(httpRes));
571
- }
572
- res = new operations.CreatePhoneNumberResponse({
573
- statusCode: httpRes.status,
574
- contentType: responseContentType,
575
- rawResponse: httpRes,
576
- });
577
- decodedRes = new TextDecoder().decode(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data);
578
- switch (true) {
579
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
580
- if (utils.matchContentType(responseContentType, "application/json")) {
581
- res.phoneNumber = utils.objectToClass(JSON.parse(decodedRes), components.PhoneNumber);
582
- }
583
- else {
584
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
585
- }
586
- break;
587
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 400:
588
- if (utils.matchContentType(responseContentType, "application/json")) {
589
- err = utils.objectToClass(JSON.parse(decodedRes), errors.CreatePhoneNumberResponseBody);
590
- err.rawResponse = httpRes;
591
- throw new errors.CreatePhoneNumberResponseBody(err);
592
- }
593
- else {
594
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
595
- }
596
- break;
597
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 401:
598
- if (utils.matchContentType(responseContentType, "application/json")) {
599
- err = utils.objectToClass(JSON.parse(decodedRes), errors.CreatePhoneNumberResponseResponseBody);
600
- err.rawResponse = httpRes;
601
- throw new errors.CreatePhoneNumberResponseResponseBody(err);
602
- }
603
- else {
604
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
605
- }
606
- break;
607
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 402:
608
- if (utils.matchContentType(responseContentType, "application/json")) {
609
- err = utils.objectToClass(JSON.parse(decodedRes), errors.CreatePhoneNumberResponse402ResponseBody);
610
- err.rawResponse = httpRes;
611
- throw new errors.CreatePhoneNumberResponse402ResponseBody(err);
612
- }
613
- else {
614
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
615
- }
616
- break;
617
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 422:
618
- if (utils.matchContentType(responseContentType, "application/json")) {
619
- err = utils.objectToClass(JSON.parse(decodedRes), errors.CreatePhoneNumberResponse422ResponseBody);
620
- err.rawResponse = httpRes;
621
- throw new errors.CreatePhoneNumberResponse422ResponseBody(err);
622
- }
623
- else {
624
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
625
- }
626
- break;
627
- case ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 400 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 500) ||
628
- ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 500 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 600):
629
- throw new errors.SDKError("API error occurred", httpRes.status, decodedRes, httpRes);
630
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 500:
631
- if (utils.matchContentType(responseContentType, "application/json")) {
632
- err = utils.objectToClass(JSON.parse(decodedRes), errors.CreatePhoneNumberResponse500ResponseBody);
633
- err.rawResponse = httpRes;
634
- throw new errors.CreatePhoneNumberResponse500ResponseBody(err);
635
- }
636
- else {
637
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
638
- }
639
- break;
640
- }
641
- return [2 /*return*/, res];
642
- }
643
- });
644
- });
645
- };
646
- /**
647
- * Delete an existing agent
648
- */
649
- RetellClient.prototype.deleteAgent = function (agentId, config) {
650
- var _a, _b;
651
- return __awaiter(this, void 0, void 0, function () {
652
- var req, baseURL, operationUrl, client, globalSecurity, properties, headers, httpRes, responseContentType, res, decodedRes, err, err, err, err;
653
- return __generator(this, function (_c) {
654
- switch (_c.label) {
655
- case 0:
656
- req = new operations.DeleteAgentRequest({
657
- agentId: agentId,
658
- });
659
- baseURL = utils.templateUrl(this.sdkConfiguration.serverURL, this.sdkConfiguration.serverDefaults);
660
- operationUrl = utils.generateURL(baseURL, "/delete-agent/{agent_id}", req);
661
- client = this.sdkConfiguration.defaultClient;
662
- globalSecurity = this.sdkConfiguration.security;
663
- if (!(typeof globalSecurity === "function")) return [3 /*break*/, 2];
664
- return [4 /*yield*/, globalSecurity()];
665
- case 1:
666
- globalSecurity = _c.sent();
667
- _c.label = 2;
668
- case 2:
669
- if (!(globalSecurity instanceof utils.SpeakeasyBase)) {
670
- globalSecurity = new components.Security(globalSecurity);
671
- }
672
- properties = utils.parseSecurityProperties(globalSecurity);
673
- headers = __assign(__assign({}, config === null || config === void 0 ? void 0 : config.headers), properties.headers);
674
- headers["Accept"] = "application/json";
675
- return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: operationUrl, method: "delete", headers: headers, responseType: "arraybuffer" }, config))];
676
- case 3:
677
- httpRes = _c.sent();
678
- responseContentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
679
- if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
680
- throw new Error("status code not found in response: ".concat(httpRes));
681
- }
682
- res = new operations.DeleteAgentResponse({
683
- statusCode: httpRes.status,
684
- contentType: responseContentType,
685
- rawResponse: httpRes,
686
- });
687
- decodedRes = new TextDecoder().decode(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data);
688
- switch (true) {
689
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 204:
690
- break;
691
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 400:
692
- if (utils.matchContentType(responseContentType, "application/json")) {
693
- err = utils.objectToClass(JSON.parse(decodedRes), errors.DeleteAgentResponseBody);
694
- err.rawResponse = httpRes;
695
- throw new errors.DeleteAgentResponseBody(err);
696
- }
697
- else {
698
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
699
- }
700
- break;
701
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 401:
702
- if (utils.matchContentType(responseContentType, "application/json")) {
703
- err = utils.objectToClass(JSON.parse(decodedRes), errors.DeleteAgentResponseResponseBody);
704
- err.rawResponse = httpRes;
705
- throw new errors.DeleteAgentResponseResponseBody(err);
706
- }
707
- else {
708
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
709
- }
710
- break;
711
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 422:
712
- if (utils.matchContentType(responseContentType, "application/json")) {
713
- err = utils.objectToClass(JSON.parse(decodedRes), errors.DeleteAgentResponse422ResponseBody);
714
- err.rawResponse = httpRes;
715
- throw new errors.DeleteAgentResponse422ResponseBody(err);
716
- }
717
- else {
718
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
719
- }
720
- break;
721
- case ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 400 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 500) ||
722
- ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 500 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 600):
723
- throw new errors.SDKError("API error occurred", httpRes.status, decodedRes, httpRes);
724
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 500:
725
- if (utils.matchContentType(responseContentType, "application/json")) {
726
- err = utils.objectToClass(JSON.parse(decodedRes), errors.DeleteAgentResponse500ResponseBody);
727
- err.rawResponse = httpRes;
728
- throw new errors.DeleteAgentResponse500ResponseBody(err);
729
- }
730
- else {
731
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
732
- }
733
- break;
734
- }
735
- return [2 /*return*/, res];
736
- }
737
- });
738
- });
739
- };
740
- /**
741
- * Delete a specific phone number
742
- */
743
- RetellClient.prototype.deletePhoneNumber = function (phoneNumber, config) {
744
- var _a, _b;
745
- return __awaiter(this, void 0, void 0, function () {
746
- var req, baseURL, operationUrl, client, globalSecurity, properties, headers, httpRes, responseContentType, res, decodedRes, err, err, err, err;
747
- return __generator(this, function (_c) {
748
- switch (_c.label) {
749
- case 0:
750
- req = new operations.DeletePhoneNumberRequest({
751
- phoneNumber: phoneNumber,
752
- });
753
- baseURL = utils.templateUrl(this.sdkConfiguration.serverURL, this.sdkConfiguration.serverDefaults);
754
- operationUrl = utils.generateURL(baseURL, "/delete-phone-number/{phone_number}", req);
755
- client = this.sdkConfiguration.defaultClient;
756
- globalSecurity = this.sdkConfiguration.security;
757
- if (!(typeof globalSecurity === "function")) return [3 /*break*/, 2];
758
- return [4 /*yield*/, globalSecurity()];
759
- case 1:
760
- globalSecurity = _c.sent();
761
- _c.label = 2;
762
- case 2:
763
- if (!(globalSecurity instanceof utils.SpeakeasyBase)) {
764
- globalSecurity = new components.Security(globalSecurity);
765
- }
766
- properties = utils.parseSecurityProperties(globalSecurity);
767
- headers = __assign(__assign({}, config === null || config === void 0 ? void 0 : config.headers), properties.headers);
768
- headers["Accept"] = "application/json";
769
- return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: operationUrl, method: "delete", headers: headers, responseType: "arraybuffer" }, config))];
770
- case 3:
771
- httpRes = _c.sent();
772
- responseContentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
773
- if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
774
- throw new Error("status code not found in response: ".concat(httpRes));
775
- }
776
- res = new operations.DeletePhoneNumberResponse({
777
- statusCode: httpRes.status,
778
- contentType: responseContentType,
779
- rawResponse: httpRes,
780
- });
781
- decodedRes = new TextDecoder().decode(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data);
782
- switch (true) {
783
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 204:
784
- break;
785
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 400:
786
- if (utils.matchContentType(responseContentType, "application/json")) {
787
- err = utils.objectToClass(JSON.parse(decodedRes), errors.DeletePhoneNumberResponseBody);
788
- err.rawResponse = httpRes;
789
- throw new errors.DeletePhoneNumberResponseBody(err);
790
- }
791
- else {
792
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
793
- }
794
- break;
795
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 401:
796
- if (utils.matchContentType(responseContentType, "application/json")) {
797
- err = utils.objectToClass(JSON.parse(decodedRes), errors.DeletePhoneNumberResponseResponseBody);
798
- err.rawResponse = httpRes;
799
- throw new errors.DeletePhoneNumberResponseResponseBody(err);
800
- }
801
- else {
802
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
803
- }
804
- break;
805
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 422:
806
- if (utils.matchContentType(responseContentType, "application/json")) {
807
- err = utils.objectToClass(JSON.parse(decodedRes), errors.DeletePhoneNumberResponse422ResponseBody);
808
- err.rawResponse = httpRes;
809
- throw new errors.DeletePhoneNumberResponse422ResponseBody(err);
810
- }
811
- else {
812
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
813
- }
814
- break;
815
- case ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 400 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 500) ||
816
- ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 500 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 600):
817
- throw new errors.SDKError("API error occurred", httpRes.status, decodedRes, httpRes);
818
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 500:
819
- if (utils.matchContentType(responseContentType, "application/json")) {
820
- err = utils.objectToClass(JSON.parse(decodedRes), errors.DeletePhoneNumberResponse500ResponseBody);
821
- err.rawResponse = httpRes;
822
- throw new errors.DeletePhoneNumberResponse500ResponseBody(err);
823
- }
824
- else {
825
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
826
- }
827
- break;
828
- }
829
- return [2 /*return*/, res];
830
- }
831
- });
832
- });
833
- };
834
- /**
835
- * Retrieve details of a specific agent
836
- */
837
- RetellClient.prototype.getAgent = function (agentId, config) {
838
- var _a, _b;
839
- return __awaiter(this, void 0, void 0, function () {
840
- var req, baseURL, operationUrl, client, globalSecurity, properties, headers, httpRes, responseContentType, res, decodedRes, err, err, err, err;
841
- return __generator(this, function (_c) {
842
- switch (_c.label) {
843
- case 0:
844
- req = new operations.GetAgentRequest({
845
- agentId: agentId,
846
- });
847
- baseURL = utils.templateUrl(this.sdkConfiguration.serverURL, this.sdkConfiguration.serverDefaults);
848
- operationUrl = utils.generateURL(baseURL, "/get-agent/{agent_id}", req);
849
- client = this.sdkConfiguration.defaultClient;
850
- globalSecurity = this.sdkConfiguration.security;
851
- if (!(typeof globalSecurity === "function")) return [3 /*break*/, 2];
852
- return [4 /*yield*/, globalSecurity()];
853
- case 1:
854
- globalSecurity = _c.sent();
855
- _c.label = 2;
856
- case 2:
857
- if (!(globalSecurity instanceof utils.SpeakeasyBase)) {
858
- globalSecurity = new components.Security(globalSecurity);
859
- }
860
- properties = utils.parseSecurityProperties(globalSecurity);
861
- headers = __assign(__assign({}, config === null || config === void 0 ? void 0 : config.headers), properties.headers);
862
- headers["Accept"] = "application/json";
863
- return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: operationUrl, method: "get", headers: headers, responseType: "arraybuffer" }, config))];
864
- case 3:
865
- httpRes = _c.sent();
866
- responseContentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
867
- if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
868
- throw new Error("status code not found in response: ".concat(httpRes));
869
- }
870
- res = new operations.GetAgentResponse({
871
- statusCode: httpRes.status,
872
- contentType: responseContentType,
873
- rawResponse: httpRes,
874
- });
875
- decodedRes = new TextDecoder().decode(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data);
876
- switch (true) {
877
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
878
- if (utils.matchContentType(responseContentType, "application/json")) {
879
- res.agent = utils.objectToClass(JSON.parse(decodedRes), components.Agent);
880
- }
881
- else {
882
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
883
- }
884
- break;
885
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 400:
886
- if (utils.matchContentType(responseContentType, "application/json")) {
887
- err = utils.objectToClass(JSON.parse(decodedRes), errors.GetAgentResponseBody);
888
- err.rawResponse = httpRes;
889
- throw new errors.GetAgentResponseBody(err);
890
- }
891
- else {
892
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
893
- }
894
- break;
895
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 401:
896
- if (utils.matchContentType(responseContentType, "application/json")) {
897
- err = utils.objectToClass(JSON.parse(decodedRes), errors.GetAgentResponseResponseBody);
898
- err.rawResponse = httpRes;
899
- throw new errors.GetAgentResponseResponseBody(err);
900
- }
901
- else {
902
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
903
- }
904
- break;
905
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 422:
906
- if (utils.matchContentType(responseContentType, "application/json")) {
907
- err = utils.objectToClass(JSON.parse(decodedRes), errors.GetAgentResponse422ResponseBody);
908
- err.rawResponse = httpRes;
909
- throw new errors.GetAgentResponse422ResponseBody(err);
910
- }
911
- else {
912
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
913
- }
914
- break;
915
- case ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 400 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 500) ||
916
- ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 500 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 600):
917
- throw new errors.SDKError("API error occurred", httpRes.status, decodedRes, httpRes);
918
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 500:
919
- if (utils.matchContentType(responseContentType, "application/json")) {
920
- err = utils.objectToClass(JSON.parse(decodedRes), errors.GetAgentResponse500ResponseBody);
921
- err.rawResponse = httpRes;
922
- throw new errors.GetAgentResponse500ResponseBody(err);
923
- }
924
- else {
925
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
926
- }
927
- break;
928
- }
929
- return [2 /*return*/, res];
930
- }
931
- });
932
- });
933
- };
934
- /**
935
- * Retrieve details of a specific call
936
- */
937
- RetellClient.prototype.getCall = function (callId, config) {
938
- var _a, _b;
939
- return __awaiter(this, void 0, void 0, function () {
940
- var req, baseURL, operationUrl, client, globalSecurity, properties, headers, httpRes, responseContentType, res, decodedRes, err, err, err, err;
941
- return __generator(this, function (_c) {
942
- switch (_c.label) {
943
- case 0:
944
- req = new operations.GetCallRequest({
945
- callId: callId,
946
- });
947
- baseURL = utils.templateUrl(this.sdkConfiguration.serverURL, this.sdkConfiguration.serverDefaults);
948
- operationUrl = utils.generateURL(baseURL, "/get-call/{call_id}", req);
949
- client = this.sdkConfiguration.defaultClient;
950
- globalSecurity = this.sdkConfiguration.security;
951
- if (!(typeof globalSecurity === "function")) return [3 /*break*/, 2];
952
- return [4 /*yield*/, globalSecurity()];
953
- case 1:
954
- globalSecurity = _c.sent();
955
- _c.label = 2;
956
- case 2:
957
- if (!(globalSecurity instanceof utils.SpeakeasyBase)) {
958
- globalSecurity = new components.Security(globalSecurity);
959
- }
960
- properties = utils.parseSecurityProperties(globalSecurity);
961
- headers = __assign(__assign({}, config === null || config === void 0 ? void 0 : config.headers), properties.headers);
962
- headers["Accept"] = "application/json";
963
- return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: operationUrl, method: "get", headers: headers, responseType: "arraybuffer" }, config))];
964
- case 3:
965
- httpRes = _c.sent();
966
- responseContentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
967
- if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
968
- throw new Error("status code not found in response: ".concat(httpRes));
969
- }
970
- res = new operations.GetCallResponse({
971
- statusCode: httpRes.status,
972
- contentType: responseContentType,
973
- rawResponse: httpRes,
974
- });
975
- decodedRes = new TextDecoder().decode(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data);
976
- switch (true) {
977
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
978
- if (utils.matchContentType(responseContentType, "application/json")) {
979
- res.callDetail = utils.objectToClass(JSON.parse(decodedRes), components.CallDetail);
980
- }
981
- else {
982
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
983
- }
984
- break;
985
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 400:
986
- if (utils.matchContentType(responseContentType, "application/json")) {
987
- err = utils.objectToClass(JSON.parse(decodedRes), errors.GetCallResponseBody);
988
- err.rawResponse = httpRes;
989
- throw new errors.GetCallResponseBody(err);
990
- }
991
- else {
992
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
993
- }
994
- break;
995
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 401:
996
- if (utils.matchContentType(responseContentType, "application/json")) {
997
- err = utils.objectToClass(JSON.parse(decodedRes), errors.GetCallResponseResponseBody);
998
- err.rawResponse = httpRes;
999
- throw new errors.GetCallResponseResponseBody(err);
1000
- }
1001
- else {
1002
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
1003
- }
1004
- break;
1005
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 422:
1006
- if (utils.matchContentType(responseContentType, "application/json")) {
1007
- err = utils.objectToClass(JSON.parse(decodedRes), errors.GetCallResponse422ResponseBody);
1008
- err.rawResponse = httpRes;
1009
- throw new errors.GetCallResponse422ResponseBody(err);
1010
- }
1011
- else {
1012
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
1013
- }
1014
- break;
1015
- case ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 400 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 500) ||
1016
- ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 500 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 600):
1017
- throw new errors.SDKError("API error occurred", httpRes.status, decodedRes, httpRes);
1018
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 500:
1019
- if (utils.matchContentType(responseContentType, "application/json")) {
1020
- err = utils.objectToClass(JSON.parse(decodedRes), errors.GetCallResponse500ResponseBody);
1021
- err.rawResponse = httpRes;
1022
- throw new errors.GetCallResponse500ResponseBody(err);
1023
- }
1024
- else {
1025
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
1026
- }
1027
- break;
1028
- }
1029
- return [2 /*return*/, res];
1030
- }
1031
- });
1032
- });
1033
- };
1034
- /**
1035
- * Retrieve info about a specific number
1036
- */
1037
- RetellClient.prototype.getPhoneNumber = function (phoneNumber, config) {
1038
- var _a, _b;
1039
- return __awaiter(this, void 0, void 0, function () {
1040
- var req, baseURL, operationUrl, client, globalSecurity, properties, headers, httpRes, responseContentType, res, decodedRes, err, err, err, err;
1041
- return __generator(this, function (_c) {
1042
- switch (_c.label) {
1043
- case 0:
1044
- req = new operations.GetPhoneNumberRequest({
1045
- phoneNumber: phoneNumber,
1046
- });
1047
- baseURL = utils.templateUrl(this.sdkConfiguration.serverURL, this.sdkConfiguration.serverDefaults);
1048
- operationUrl = utils.generateURL(baseURL, "/get-phone-number/{phone_number}", req);
1049
- client = this.sdkConfiguration.defaultClient;
1050
- globalSecurity = this.sdkConfiguration.security;
1051
- if (!(typeof globalSecurity === "function")) return [3 /*break*/, 2];
1052
- return [4 /*yield*/, globalSecurity()];
1053
- case 1:
1054
- globalSecurity = _c.sent();
1055
- _c.label = 2;
1056
- case 2:
1057
- if (!(globalSecurity instanceof utils.SpeakeasyBase)) {
1058
- globalSecurity = new components.Security(globalSecurity);
1059
- }
1060
- properties = utils.parseSecurityProperties(globalSecurity);
1061
- headers = __assign(__assign({}, config === null || config === void 0 ? void 0 : config.headers), properties.headers);
1062
- headers["Accept"] = "application/json";
1063
- return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: operationUrl, method: "get", headers: headers, responseType: "arraybuffer" }, config))];
1064
- case 3:
1065
- httpRes = _c.sent();
1066
- responseContentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
1067
- if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
1068
- throw new Error("status code not found in response: ".concat(httpRes));
1069
- }
1070
- res = new operations.GetPhoneNumberResponse({
1071
- statusCode: httpRes.status,
1072
- contentType: responseContentType,
1073
- rawResponse: httpRes,
1074
- });
1075
- decodedRes = new TextDecoder().decode(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data);
1076
- switch (true) {
1077
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
1078
- if (utils.matchContentType(responseContentType, "application/json")) {
1079
- res.phoneNumber = utils.objectToClass(JSON.parse(decodedRes), components.PhoneNumber);
1080
- }
1081
- else {
1082
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
1083
- }
1084
- break;
1085
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 400:
1086
- if (utils.matchContentType(responseContentType, "application/json")) {
1087
- err = utils.objectToClass(JSON.parse(decodedRes), errors.GetPhoneNumberResponseBody);
1088
- err.rawResponse = httpRes;
1089
- throw new errors.GetPhoneNumberResponseBody(err);
1090
- }
1091
- else {
1092
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
1093
- }
1094
- break;
1095
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 401:
1096
- if (utils.matchContentType(responseContentType, "application/json")) {
1097
- err = utils.objectToClass(JSON.parse(decodedRes), errors.GetPhoneNumberResponseResponseBody);
1098
- err.rawResponse = httpRes;
1099
- throw new errors.GetPhoneNumberResponseResponseBody(err);
1100
- }
1101
- else {
1102
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
1103
- }
1104
- break;
1105
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 422:
1106
- if (utils.matchContentType(responseContentType, "application/json")) {
1107
- err = utils.objectToClass(JSON.parse(decodedRes), errors.GetPhoneNumberResponse422ResponseBody);
1108
- err.rawResponse = httpRes;
1109
- throw new errors.GetPhoneNumberResponse422ResponseBody(err);
1110
- }
1111
- else {
1112
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
1113
- }
1114
- break;
1115
- case ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 400 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 500) ||
1116
- ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 500 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 600):
1117
- throw new errors.SDKError("API error occurred", httpRes.status, decodedRes, httpRes);
1118
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 500:
1119
- if (utils.matchContentType(responseContentType, "application/json")) {
1120
- err = utils.objectToClass(JSON.parse(decodedRes), errors.GetPhoneNumberResponse500ResponseBody);
1121
- err.rawResponse = httpRes;
1122
- throw new errors.GetPhoneNumberResponse500ResponseBody(err);
1123
- }
1124
- else {
1125
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
1126
- }
1127
- break;
1128
- }
1129
- return [2 /*return*/, res];
1130
- }
1131
- });
1132
- });
1133
- };
1134
- /**
1135
- * List all agents
1136
- */
1137
- RetellClient.prototype.listAgents = function (config) {
1138
- var _a, _b;
1139
- return __awaiter(this, void 0, void 0, function () {
1140
- var baseURL, operationUrl, client, globalSecurity, properties, headers, httpRes, responseContentType, res, decodedRes, resFieldDepth, err, err;
1141
- return __generator(this, function (_c) {
1142
- switch (_c.label) {
1143
- case 0:
1144
- baseURL = utils.templateUrl(this.sdkConfiguration.serverURL, this.sdkConfiguration.serverDefaults);
1145
- operationUrl = baseURL.replace(/\/$/, "") + "/list-agents";
1146
- client = this.sdkConfiguration.defaultClient;
1147
- globalSecurity = this.sdkConfiguration.security;
1148
- if (!(typeof globalSecurity === "function")) return [3 /*break*/, 2];
1149
- return [4 /*yield*/, globalSecurity()];
1150
- case 1:
1151
- globalSecurity = _c.sent();
1152
- _c.label = 2;
1153
- case 2:
1154
- if (!(globalSecurity instanceof utils.SpeakeasyBase)) {
1155
- globalSecurity = new components.Security(globalSecurity);
1156
- }
1157
- properties = utils.parseSecurityProperties(globalSecurity);
1158
- headers = __assign(__assign({}, config === null || config === void 0 ? void 0 : config.headers), properties.headers);
1159
- headers["Accept"] = "application/json";
1160
- return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: operationUrl, method: "get", headers: headers, responseType: "arraybuffer" }, config))];
1161
- case 3:
1162
- httpRes = _c.sent();
1163
- responseContentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
1164
- if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
1165
- throw new Error("status code not found in response: ".concat(httpRes));
1166
- }
1167
- res = new operations.ListAgentsResponse({
1168
- statusCode: httpRes.status,
1169
- contentType: responseContentType,
1170
- rawResponse: httpRes,
1171
- });
1172
- decodedRes = new TextDecoder().decode(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data);
1173
- switch (true) {
1174
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
1175
- if (utils.matchContentType(responseContentType, "application/json")) {
1176
- res.classes = [];
1177
- resFieldDepth = utils.getResFieldDepth(res);
1178
- res.classes = utils.objectToClass(JSON.parse(decodedRes), components.Agent, resFieldDepth);
1179
- }
1180
- else {
1181
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
1182
- }
1183
- break;
1184
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 401:
1185
- if (utils.matchContentType(responseContentType, "application/json")) {
1186
- err = utils.objectToClass(JSON.parse(decodedRes), errors.ListAgentsResponseBody);
1187
- err.rawResponse = httpRes;
1188
- throw new errors.ListAgentsResponseBody(err);
1189
- }
1190
- else {
1191
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
1192
- }
1193
- break;
1194
- case ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 400 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 500) ||
1195
- ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 500 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 600):
1196
- throw new errors.SDKError("API error occurred", httpRes.status, decodedRes, httpRes);
1197
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 500:
1198
- if (utils.matchContentType(responseContentType, "application/json")) {
1199
- err = utils.objectToClass(JSON.parse(decodedRes), errors.ListAgentsResponseResponseBody);
1200
- err.rawResponse = httpRes;
1201
- throw new errors.ListAgentsResponseResponseBody(err);
1202
- }
1203
- else {
1204
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
1205
- }
1206
- break;
1207
- }
1208
- return [2 /*return*/, res];
1209
- }
1210
- });
1211
- });
1212
- };
1213
- /**
1214
- * Retrieve call details
1215
- */
1216
- RetellClient.prototype.listCalls = function (filterCriteria, limit, sortOrder, config) {
1217
- var _a, _b;
1218
- return __awaiter(this, void 0, void 0, function () {
1219
- var req, baseURL, operationUrl, client, globalSecurity, properties, headers, queryParams, httpRes, responseContentType, res, decodedRes, resFieldDepth, err, err, err;
1220
- return __generator(this, function (_c) {
1221
- switch (_c.label) {
1222
- case 0:
1223
- req = new operations.ListCallsRequest({
1224
- filterCriteria: filterCriteria,
1225
- limit: limit,
1226
- sortOrder: sortOrder,
1227
- });
1228
- baseURL = utils.templateUrl(this.sdkConfiguration.serverURL, this.sdkConfiguration.serverDefaults);
1229
- operationUrl = baseURL.replace(/\/$/, "") + "/list-calls";
1230
- client = this.sdkConfiguration.defaultClient;
1231
- globalSecurity = this.sdkConfiguration.security;
1232
- if (!(typeof globalSecurity === "function")) return [3 /*break*/, 2];
1233
- return [4 /*yield*/, globalSecurity()];
1234
- case 1:
1235
- globalSecurity = _c.sent();
1236
- _c.label = 2;
1237
- case 2:
1238
- if (!(globalSecurity instanceof utils.SpeakeasyBase)) {
1239
- globalSecurity = new components.Security(globalSecurity);
1240
- }
1241
- properties = utils.parseSecurityProperties(globalSecurity);
1242
- headers = __assign(__assign({}, config === null || config === void 0 ? void 0 : config.headers), properties.headers);
1243
- queryParams = utils.serializeQueryParams(req);
1244
- headers["Accept"] = "application/json";
1245
- return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: operationUrl + queryParams, method: "get", headers: headers, responseType: "arraybuffer" }, config))];
1246
- case 3:
1247
- httpRes = _c.sent();
1248
- responseContentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
1249
- if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
1250
- throw new Error("status code not found in response: ".concat(httpRes));
1251
- }
1252
- res = new operations.ListCallsResponse({
1253
- statusCode: httpRes.status,
1254
- contentType: responseContentType,
1255
- rawResponse: httpRes,
1256
- });
1257
- decodedRes = new TextDecoder().decode(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data);
1258
- switch (true) {
1259
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
1260
- if (utils.matchContentType(responseContentType, "application/json")) {
1261
- res.classes = [];
1262
- resFieldDepth = utils.getResFieldDepth(res);
1263
- res.classes = utils.objectToClass(JSON.parse(decodedRes), components.CallDetail, resFieldDepth);
1264
- }
1265
- else {
1266
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
1267
- }
1268
- break;
1269
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 400:
1270
- if (utils.matchContentType(responseContentType, "application/json")) {
1271
- err = utils.objectToClass(JSON.parse(decodedRes), errors.ListCallsResponseBody);
1272
- err.rawResponse = httpRes;
1273
- throw new errors.ListCallsResponseBody(err);
1274
- }
1275
- else {
1276
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
1277
- }
1278
- break;
1279
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 401:
1280
- if (utils.matchContentType(responseContentType, "application/json")) {
1281
- err = utils.objectToClass(JSON.parse(decodedRes), errors.ListCallsResponseResponseBody);
1282
- err.rawResponse = httpRes;
1283
- throw new errors.ListCallsResponseResponseBody(err);
1284
- }
1285
- else {
1286
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
1287
- }
1288
- break;
1289
- case ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 400 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 500) ||
1290
- ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 500 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 600):
1291
- throw new errors.SDKError("API error occurred", httpRes.status, decodedRes, httpRes);
1292
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 500:
1293
- if (utils.matchContentType(responseContentType, "application/json")) {
1294
- err = utils.objectToClass(JSON.parse(decodedRes), errors.ListCallsResponse500ResponseBody);
1295
- err.rawResponse = httpRes;
1296
- throw new errors.ListCallsResponse500ResponseBody(err);
1297
- }
1298
- else {
1299
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
1300
- }
1301
- break;
1302
- }
1303
- return [2 /*return*/, res];
1304
- }
1305
- });
1306
- });
1307
- };
1308
- /**
1309
- * List all purchased and active phone numbers
1310
- */
1311
- RetellClient.prototype.listPhoneNumbers = function (config) {
1312
- var _a, _b;
1313
- return __awaiter(this, void 0, void 0, function () {
1314
- var baseURL, operationUrl, client, globalSecurity, properties, headers, httpRes, responseContentType, res, decodedRes, resFieldDepth, err, err, err;
1315
- return __generator(this, function (_c) {
1316
- switch (_c.label) {
1317
- case 0:
1318
- baseURL = utils.templateUrl(this.sdkConfiguration.serverURL, this.sdkConfiguration.serverDefaults);
1319
- operationUrl = baseURL.replace(/\/$/, "") + "/list-phone-numbers";
1320
- client = this.sdkConfiguration.defaultClient;
1321
- globalSecurity = this.sdkConfiguration.security;
1322
- if (!(typeof globalSecurity === "function")) return [3 /*break*/, 2];
1323
- return [4 /*yield*/, globalSecurity()];
1324
- case 1:
1325
- globalSecurity = _c.sent();
1326
- _c.label = 2;
1327
- case 2:
1328
- if (!(globalSecurity instanceof utils.SpeakeasyBase)) {
1329
- globalSecurity = new components.Security(globalSecurity);
1330
- }
1331
- properties = utils.parseSecurityProperties(globalSecurity);
1332
- headers = __assign(__assign({}, config === null || config === void 0 ? void 0 : config.headers), properties.headers);
1333
- headers["Accept"] = "application/json";
1334
- return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: operationUrl, method: "get", headers: headers, responseType: "arraybuffer" }, config))];
1335
- case 3:
1336
- httpRes = _c.sent();
1337
- responseContentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
1338
- if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
1339
- throw new Error("status code not found in response: ".concat(httpRes));
1340
- }
1341
- res = new operations.ListPhoneNumbersResponse({
1342
- statusCode: httpRes.status,
1343
- contentType: responseContentType,
1344
- rawResponse: httpRes,
1345
- });
1346
- decodedRes = new TextDecoder().decode(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data);
1347
- switch (true) {
1348
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
1349
- if (utils.matchContentType(responseContentType, "application/json")) {
1350
- res.classes = [];
1351
- resFieldDepth = utils.getResFieldDepth(res);
1352
- res.classes = utils.objectToClass(JSON.parse(decodedRes), components.PhoneNumber, resFieldDepth);
1353
- }
1354
- else {
1355
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
1356
- }
1357
- break;
1358
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 400:
1359
- if (utils.matchContentType(responseContentType, "application/json")) {
1360
- err = utils.objectToClass(JSON.parse(decodedRes), errors.ListPhoneNumbersResponseBody);
1361
- err.rawResponse = httpRes;
1362
- throw new errors.ListPhoneNumbersResponseBody(err);
1363
- }
1364
- else {
1365
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
1366
- }
1367
- break;
1368
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 401:
1369
- if (utils.matchContentType(responseContentType, "application/json")) {
1370
- err = utils.objectToClass(JSON.parse(decodedRes), errors.ListPhoneNumbersResponseResponseBody);
1371
- err.rawResponse = httpRes;
1372
- throw new errors.ListPhoneNumbersResponseResponseBody(err);
1373
- }
1374
- else {
1375
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
1376
- }
1377
- break;
1378
- case ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 400 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 500) ||
1379
- ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 500 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 600):
1380
- throw new errors.SDKError("API error occurred", httpRes.status, decodedRes, httpRes);
1381
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 500:
1382
- if (utils.matchContentType(responseContentType, "application/json")) {
1383
- err = utils.objectToClass(JSON.parse(decodedRes), errors.ListPhoneNumbersResponse500ResponseBody);
1384
- err.rawResponse = httpRes;
1385
- throw new errors.ListPhoneNumbersResponse500ResponseBody(err);
1386
- }
1387
- else {
1388
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
1389
- }
1390
- break;
1391
- }
1392
- return [2 /*return*/, res];
1393
- }
1394
- });
1395
- });
1396
- };
1397
- /**
1398
- * Update an existing agent
1399
- */
1400
- RetellClient.prototype.updateAgent = function (agentNoDefaultNoRequired, agentId, config) {
1401
- var _a, _b;
1402
- return __awaiter(this, void 0, void 0, function () {
1403
- var req, baseURL, operationUrl, _c, reqBodyHeaders, reqBody, client, globalSecurity, properties, headers, httpRes, responseContentType, res, decodedRes, err, err, err, err;
1404
- var _d;
1405
- return __generator(this, function (_e) {
1406
- switch (_e.label) {
1407
- case 0:
1408
- req = new operations.UpdateAgentRequest({
1409
- agentNoDefaultNoRequired: agentNoDefaultNoRequired,
1410
- agentId: agentId,
1411
- });
1412
- baseURL = utils.templateUrl(this.sdkConfiguration.serverURL, this.sdkConfiguration.serverDefaults);
1413
- operationUrl = utils.generateURL(baseURL, "/update-agent/{agent_id}", req);
1414
- _c = __read([{}, null], 2), reqBodyHeaders = _c[0], reqBody = _c[1];
1415
- try {
1416
- _d = __read(utils.serializeRequestBody(req, "agentNoDefaultNoRequired", "json"), 2), reqBodyHeaders = _d[0], reqBody = _d[1];
1417
- }
1418
- catch (e) {
1419
- if (e instanceof Error) {
1420
- throw new Error("Error serializing request body, cause: ".concat(e.message));
1421
- }
1422
- }
1423
- client = this.sdkConfiguration.defaultClient;
1424
- globalSecurity = this.sdkConfiguration.security;
1425
- if (!(typeof globalSecurity === "function")) return [3 /*break*/, 2];
1426
- return [4 /*yield*/, globalSecurity()];
1427
- case 1:
1428
- globalSecurity = _e.sent();
1429
- _e.label = 2;
1430
- case 2:
1431
- if (!(globalSecurity instanceof utils.SpeakeasyBase)) {
1432
- globalSecurity = new components.Security(globalSecurity);
1433
- }
1434
- properties = utils.parseSecurityProperties(globalSecurity);
1435
- headers = __assign(__assign(__assign({}, reqBodyHeaders), config === null || config === void 0 ? void 0 : config.headers), properties.headers);
1436
- if (reqBody == null)
1437
- throw new Error("request body is required");
1438
- headers["Accept"] = "application/json";
1439
- return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: operationUrl, method: "patch", headers: headers, responseType: "arraybuffer", data: reqBody }, config))];
1440
- case 3:
1441
- httpRes = _e.sent();
1442
- responseContentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
1443
- if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
1444
- throw new Error("status code not found in response: ".concat(httpRes));
1445
- }
1446
- res = new operations.UpdateAgentResponse({
1447
- statusCode: httpRes.status,
1448
- contentType: responseContentType,
1449
- rawResponse: httpRes,
1450
- });
1451
- decodedRes = new TextDecoder().decode(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data);
1452
- switch (true) {
1453
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
1454
- if (utils.matchContentType(responseContentType, "application/json")) {
1455
- res.agent = utils.objectToClass(JSON.parse(decodedRes), components.Agent);
1456
- }
1457
- else {
1458
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
1459
- }
1460
- break;
1461
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 400:
1462
- if (utils.matchContentType(responseContentType, "application/json")) {
1463
- err = utils.objectToClass(JSON.parse(decodedRes), errors.UpdateAgentResponseBody);
1464
- err.rawResponse = httpRes;
1465
- throw new errors.UpdateAgentResponseBody(err);
1466
- }
1467
- else {
1468
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
1469
- }
1470
- break;
1471
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 401:
1472
- if (utils.matchContentType(responseContentType, "application/json")) {
1473
- err = utils.objectToClass(JSON.parse(decodedRes), errors.UpdateAgentResponseResponseBody);
1474
- err.rawResponse = httpRes;
1475
- throw new errors.UpdateAgentResponseResponseBody(err);
1476
- }
1477
- else {
1478
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
1479
- }
1480
- break;
1481
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 422:
1482
- if (utils.matchContentType(responseContentType, "application/json")) {
1483
- err = utils.objectToClass(JSON.parse(decodedRes), errors.UpdateAgentResponse422ResponseBody);
1484
- err.rawResponse = httpRes;
1485
- throw new errors.UpdateAgentResponse422ResponseBody(err);
1486
- }
1487
- else {
1488
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
1489
- }
1490
- break;
1491
- case ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 400 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 500) ||
1492
- ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 500 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 600):
1493
- throw new errors.SDKError("API error occurred", httpRes.status, decodedRes, httpRes);
1494
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 500:
1495
- if (utils.matchContentType(responseContentType, "application/json")) {
1496
- err = utils.objectToClass(JSON.parse(decodedRes), errors.UpdateAgentResponse500ResponseBody);
1497
- err.rawResponse = httpRes;
1498
- throw new errors.UpdateAgentResponse500ResponseBody(err);
1499
- }
1500
- else {
1501
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
1502
- }
1503
- break;
1504
- }
1505
- return [2 /*return*/, res];
1506
- }
1507
- });
1508
- });
1509
- };
1510
- /**
1511
- * Update an existing phone number
1512
- */
1513
- RetellClient.prototype.updatePhoneAgent = function (requestBody, phoneNumber, config) {
1514
- var _a, _b;
1515
- return __awaiter(this, void 0, void 0, function () {
1516
- var req, baseURL, operationUrl, _c, reqBodyHeaders, reqBody, client, globalSecurity, properties, headers, httpRes, responseContentType, res, decodedRes, err, err, err, err;
1517
- var _d;
1518
- return __generator(this, function (_e) {
1519
- switch (_e.label) {
1520
- case 0:
1521
- req = new operations.UpdatePhoneAgentRequest({
1522
- requestBody: requestBody,
1523
- phoneNumber: phoneNumber,
1524
- });
1525
- baseURL = utils.templateUrl(this.sdkConfiguration.serverURL, this.sdkConfiguration.serverDefaults);
1526
- operationUrl = utils.generateURL(baseURL, "/update-phone-agent/{phone_number}", req);
1527
- _c = __read([{}, null], 2), reqBodyHeaders = _c[0], reqBody = _c[1];
1528
- try {
1529
- _d = __read(utils.serializeRequestBody(req, "requestBody", "json"), 2), reqBodyHeaders = _d[0], reqBody = _d[1];
1530
- }
1531
- catch (e) {
1532
- if (e instanceof Error) {
1533
- throw new Error("Error serializing request body, cause: ".concat(e.message));
1534
- }
1535
- }
1536
- client = this.sdkConfiguration.defaultClient;
1537
- globalSecurity = this.sdkConfiguration.security;
1538
- if (!(typeof globalSecurity === "function")) return [3 /*break*/, 2];
1539
- return [4 /*yield*/, globalSecurity()];
1540
- case 1:
1541
- globalSecurity = _e.sent();
1542
- _e.label = 2;
1543
- case 2:
1544
- if (!(globalSecurity instanceof utils.SpeakeasyBase)) {
1545
- globalSecurity = new components.Security(globalSecurity);
1546
- }
1547
- properties = utils.parseSecurityProperties(globalSecurity);
1548
- headers = __assign(__assign(__assign({}, reqBodyHeaders), config === null || config === void 0 ? void 0 : config.headers), properties.headers);
1549
- if (reqBody == null)
1550
- throw new Error("request body is required");
1551
- headers["Accept"] = "application/json";
1552
- return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: operationUrl, method: "patch", headers: headers, responseType: "arraybuffer", data: reqBody }, config))];
1553
- case 3:
1554
- httpRes = _e.sent();
1555
- responseContentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
1556
- if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
1557
- throw new Error("status code not found in response: ".concat(httpRes));
1558
- }
1559
- res = new operations.UpdatePhoneAgentResponse({
1560
- statusCode: httpRes.status,
1561
- contentType: responseContentType,
1562
- rawResponse: httpRes,
1563
- });
1564
- decodedRes = new TextDecoder().decode(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data);
1565
- switch (true) {
1566
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
1567
- if (utils.matchContentType(responseContentType, "application/json")) {
1568
- res.phoneNumber = utils.objectToClass(JSON.parse(decodedRes), components.PhoneNumber);
1569
- }
1570
- else {
1571
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
1572
- }
1573
- break;
1574
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 400:
1575
- if (utils.matchContentType(responseContentType, "application/json")) {
1576
- err = utils.objectToClass(JSON.parse(decodedRes), errors.UpdatePhoneAgentResponseBody);
1577
- err.rawResponse = httpRes;
1578
- throw new errors.UpdatePhoneAgentResponseBody(err);
1579
- }
1580
- else {
1581
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
1582
- }
1583
- break;
1584
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 401:
1585
- if (utils.matchContentType(responseContentType, "application/json")) {
1586
- err = utils.objectToClass(JSON.parse(decodedRes), errors.UpdatePhoneAgentResponseResponseBody);
1587
- err.rawResponse = httpRes;
1588
- throw new errors.UpdatePhoneAgentResponseResponseBody(err);
1589
- }
1590
- else {
1591
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
1592
- }
1593
- break;
1594
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 422:
1595
- if (utils.matchContentType(responseContentType, "application/json")) {
1596
- err = utils.objectToClass(JSON.parse(decodedRes), errors.UpdatePhoneAgentResponse422ResponseBody);
1597
- err.rawResponse = httpRes;
1598
- throw new errors.UpdatePhoneAgentResponse422ResponseBody(err);
1599
- }
1600
- else {
1601
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
1602
- }
1603
- break;
1604
- case ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 400 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 500) ||
1605
- ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 500 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 600):
1606
- throw new errors.SDKError("API error occurred", httpRes.status, decodedRes, httpRes);
1607
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 500:
1608
- if (utils.matchContentType(responseContentType, "application/json")) {
1609
- err = utils.objectToClass(JSON.parse(decodedRes), errors.UpdatePhoneAgentResponse500ResponseBody);
1610
- err.rawResponse = httpRes;
1611
- throw new errors.UpdatePhoneAgentResponse500ResponseBody(err);
1612
- }
1613
- else {
1614
- throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
1615
- }
1616
- break;
1617
- }
1618
- return [2 /*return*/, res];
1619
- }
1620
- });
1621
- });
1622
- };
1623
- return RetellClient;
1624
- }());
1625
- exports.RetellClient = RetellClient;