sessions.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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.Sessions = 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 Sessions extends resource_1.APIResource {
  9. /**
  10. * Create a ChatKit session
  11. *
  12. * @example
  13. * ```ts
  14. * const chatSession =
  15. * await client.beta.chatkit.sessions.create({
  16. * user: 'x',
  17. * workflow: { id: 'id' },
  18. * });
  19. * ```
  20. */
  21. create(body, options) {
  22. return this._client.post('/chatkit/sessions', {
  23. body,
  24. ...options,
  25. headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
  26. });
  27. }
  28. /**
  29. * Cancel a ChatKit session
  30. *
  31. * @example
  32. * ```ts
  33. * const chatSession =
  34. * await client.beta.chatkit.sessions.cancel('cksess_123');
  35. * ```
  36. */
  37. cancel(sessionID, options) {
  38. return this._client.post((0, path_1.path) `/chatkit/sessions/${sessionID}/cancel`, {
  39. ...options,
  40. headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
  41. });
  42. }
  43. }
  44. exports.Sessions = Sessions;
  45. //# sourceMappingURL=sessions.js.map