calls.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. "use strict";
  2. // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
  3. Object.defineProperty(exports, "__esModule", { value: true });
  4. exports.Calls = void 0;
  5. const resource_1 = require("../../core/resource.js");
  6. const headers_1 = require("../../internal/headers.js");
  7. const path_1 = require("../../internal/utils/path.js");
  8. class Calls extends resource_1.APIResource {
  9. /**
  10. * Accept an incoming SIP call and configure the realtime session that will handle
  11. * it.
  12. *
  13. * @example
  14. * ```ts
  15. * await client.realtime.calls.accept('call_id', {
  16. * type: 'realtime',
  17. * });
  18. * ```
  19. */
  20. accept(callID, body, options) {
  21. return this._client.post((0, path_1.path) `/realtime/calls/${callID}/accept`, {
  22. body,
  23. ...options,
  24. headers: (0, headers_1.buildHeaders)([{ Accept: '*/*' }, options?.headers]),
  25. });
  26. }
  27. /**
  28. * End an active Realtime API call, whether it was initiated over SIP or WebRTC.
  29. *
  30. * @example
  31. * ```ts
  32. * await client.realtime.calls.hangup('call_id');
  33. * ```
  34. */
  35. hangup(callID, options) {
  36. return this._client.post((0, path_1.path) `/realtime/calls/${callID}/hangup`, {
  37. ...options,
  38. headers: (0, headers_1.buildHeaders)([{ Accept: '*/*' }, options?.headers]),
  39. });
  40. }
  41. /**
  42. * Transfer an active SIP call to a new destination using the SIP REFER verb.
  43. *
  44. * @example
  45. * ```ts
  46. * await client.realtime.calls.refer('call_id', {
  47. * target_uri: 'tel:+14155550123',
  48. * });
  49. * ```
  50. */
  51. refer(callID, body, options) {
  52. return this._client.post((0, path_1.path) `/realtime/calls/${callID}/refer`, {
  53. body,
  54. ...options,
  55. headers: (0, headers_1.buildHeaders)([{ Accept: '*/*' }, options?.headers]),
  56. });
  57. }
  58. /**
  59. * Decline an incoming SIP call by returning a SIP status code to the caller.
  60. *
  61. * @example
  62. * ```ts
  63. * await client.realtime.calls.reject('call_id');
  64. * ```
  65. */
  66. reject(callID, body = {}, options) {
  67. return this._client.post((0, path_1.path) `/realtime/calls/${callID}/reject`, {
  68. body,
  69. ...options,
  70. headers: (0, headers_1.buildHeaders)([{ Accept: '*/*' }, options?.headers]),
  71. });
  72. }
  73. }
  74. exports.Calls = Calls;
  75. //# sourceMappingURL=calls.js.map