@surgeapi/node 0.34.0 → 0.36.0

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 (116) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +31 -0
  3. package/client.d.mts +18 -8
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +18 -8
  6. package/client.d.ts.map +1 -1
  7. package/client.js +21 -2
  8. package/client.js.map +1 -1
  9. package/client.mjs +24 -5
  10. package/client.mjs.map +1 -1
  11. package/core/pagination.d.mts +60 -0
  12. package/core/pagination.d.mts.map +1 -0
  13. package/core/pagination.d.ts +60 -0
  14. package/core/pagination.d.ts.map +1 -0
  15. package/core/pagination.js +115 -0
  16. package/core/pagination.js.map +1 -0
  17. package/core/pagination.mjs +109 -0
  18. package/core/pagination.mjs.map +1 -0
  19. package/index.d.mts +1 -0
  20. package/index.d.mts.map +1 -1
  21. package/index.d.ts +1 -0
  22. package/index.d.ts.map +1 -1
  23. package/index.js +3 -1
  24. package/index.js.map +1 -1
  25. package/index.mjs +1 -0
  26. package/index.mjs.map +1 -1
  27. package/internal/parse.d.mts.map +1 -1
  28. package/internal/parse.d.ts.map +1 -1
  29. package/internal/parse.js +5 -0
  30. package/internal/parse.js.map +1 -1
  31. package/internal/parse.mjs +5 -0
  32. package/internal/parse.mjs.map +1 -1
  33. package/internal/tslib.js +17 -17
  34. package/package.json +11 -1
  35. package/pagination.d.mts +2 -0
  36. package/pagination.d.mts.map +1 -0
  37. package/pagination.d.ts +2 -0
  38. package/pagination.d.ts.map +1 -0
  39. package/pagination.js +6 -0
  40. package/pagination.js.map +1 -0
  41. package/pagination.mjs +2 -0
  42. package/pagination.mjs.map +1 -0
  43. package/resources/blasts.d.mts +4 -4
  44. package/resources/blasts.d.mts.map +1 -1
  45. package/resources/blasts.d.ts +4 -4
  46. package/resources/blasts.d.ts.map +1 -1
  47. package/resources/campaigns.d.mts +15 -0
  48. package/resources/campaigns.d.mts.map +1 -1
  49. package/resources/campaigns.d.ts +15 -0
  50. package/resources/campaigns.d.ts.map +1 -1
  51. package/resources/campaigns.js +13 -0
  52. package/resources/campaigns.js.map +1 -1
  53. package/resources/campaigns.mjs +13 -0
  54. package/resources/campaigns.mjs.map +1 -1
  55. package/resources/contacts.d.mts +19 -1
  56. package/resources/contacts.d.mts.map +1 -1
  57. package/resources/contacts.d.ts +19 -1
  58. package/resources/contacts.d.ts.map +1 -1
  59. package/resources/contacts.js +20 -0
  60. package/resources/contacts.js.map +1 -1
  61. package/resources/contacts.mjs +20 -0
  62. package/resources/contacts.mjs.map +1 -1
  63. package/resources/index.d.mts +5 -4
  64. package/resources/index.d.mts.map +1 -1
  65. package/resources/index.d.ts +5 -4
  66. package/resources/index.d.ts.map +1 -1
  67. package/resources/index.js +3 -1
  68. package/resources/index.js.map +1 -1
  69. package/resources/index.mjs +4 -3
  70. package/resources/index.mjs.map +1 -1
  71. package/resources/messages.d.mts +21 -3
  72. package/resources/messages.d.mts.map +1 -1
  73. package/resources/messages.d.ts +21 -3
  74. package/resources/messages.d.ts.map +1 -1
  75. package/resources/messages.js +20 -0
  76. package/resources/messages.js.map +1 -1
  77. package/resources/messages.mjs +20 -0
  78. package/resources/messages.mjs.map +1 -1
  79. package/resources/phone-numbers.d.mts +19 -1
  80. package/resources/phone-numbers.d.mts.map +1 -1
  81. package/resources/phone-numbers.d.ts +19 -1
  82. package/resources/phone-numbers.d.ts.map +1 -1
  83. package/resources/phone-numbers.js +20 -0
  84. package/resources/phone-numbers.js.map +1 -1
  85. package/resources/phone-numbers.mjs +20 -0
  86. package/resources/phone-numbers.mjs.map +1 -1
  87. package/resources/recordings.d.mts +31 -0
  88. package/resources/recordings.d.mts.map +1 -0
  89. package/resources/recordings.d.ts +31 -0
  90. package/resources/recordings.d.ts.map +1 -0
  91. package/resources/recordings.js +24 -0
  92. package/resources/recordings.js.map +1 -0
  93. package/resources/recordings.mjs +20 -0
  94. package/resources/recordings.mjs.map +1 -0
  95. package/resources/webhooks.d.mts +138 -6
  96. package/resources/webhooks.d.mts.map +1 -1
  97. package/resources/webhooks.d.ts +138 -6
  98. package/resources/webhooks.d.ts.map +1 -1
  99. package/src/client.ts +80 -6
  100. package/src/core/pagination.ts +176 -0
  101. package/src/index.ts +1 -0
  102. package/src/internal/parse.ts +6 -0
  103. package/src/pagination.ts +2 -0
  104. package/src/resources/blasts.ts +4 -4
  105. package/src/resources/campaigns.ts +19 -0
  106. package/src/resources/contacts.ts +31 -0
  107. package/src/resources/index.ts +25 -3
  108. package/src/resources/messages.ts +37 -3
  109. package/src/resources/phone-numbers.ts +35 -1
  110. package/src/resources/recordings.ts +38 -0
  111. package/src/resources/webhooks.ts +184 -5
  112. package/src/version.ts +1 -1
  113. package/version.d.mts +1 -1
  114. package/version.d.ts +1 -1
  115. package/version.js +1 -1
  116. package/version.mjs +1 -1
@@ -0,0 +1,176 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { SurgeError } from './error';
4
+ import { FinalRequestOptions } from '../internal/request-options';
5
+ import { defaultParseResponse } from '../internal/parse';
6
+ import { type Surge } from '../client';
7
+ import { APIPromise } from './api-promise';
8
+ import { type APIResponseProps } from '../internal/parse';
9
+ import { maybeObj } from '../internal/utils/values';
10
+
11
+ export type PageRequestOptions = Pick<FinalRequestOptions, 'query' | 'headers' | 'body' | 'path' | 'method'>;
12
+
13
+ export abstract class AbstractPage<Item> implements AsyncIterable<Item> {
14
+ #client: Surge;
15
+ protected options: FinalRequestOptions;
16
+
17
+ protected response: Response;
18
+ protected body: unknown;
19
+
20
+ constructor(client: Surge, response: Response, body: unknown, options: FinalRequestOptions) {
21
+ this.#client = client;
22
+ this.options = options;
23
+ this.response = response;
24
+ this.body = body;
25
+ }
26
+
27
+ abstract nextPageRequestOptions(): PageRequestOptions | null;
28
+
29
+ abstract getPaginatedItems(): Item[];
30
+
31
+ hasNextPage(): boolean {
32
+ const items = this.getPaginatedItems();
33
+ if (!items.length) return false;
34
+ return this.nextPageRequestOptions() != null;
35
+ }
36
+
37
+ async getNextPage(): Promise<this> {
38
+ const nextOptions = this.nextPageRequestOptions();
39
+ if (!nextOptions) {
40
+ throw new SurgeError(
41
+ 'No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.',
42
+ );
43
+ }
44
+
45
+ return await this.#client.requestAPIList(this.constructor as any, nextOptions);
46
+ }
47
+
48
+ async *iterPages(): AsyncGenerator<this> {
49
+ let page: this = this;
50
+ yield page;
51
+ while (page.hasNextPage()) {
52
+ page = await page.getNextPage();
53
+ yield page;
54
+ }
55
+ }
56
+
57
+ async *[Symbol.asyncIterator](): AsyncGenerator<Item> {
58
+ for await (const page of this.iterPages()) {
59
+ for (const item of page.getPaginatedItems()) {
60
+ yield item;
61
+ }
62
+ }
63
+ }
64
+ }
65
+
66
+ /**
67
+ * This subclass of Promise will resolve to an instantiated Page once the request completes.
68
+ *
69
+ * It also implements AsyncIterable to allow auto-paginating iteration on an unawaited list call, eg:
70
+ *
71
+ * for await (const item of client.items.list()) {
72
+ * console.log(item)
73
+ * }
74
+ */
75
+ export class PagePromise<
76
+ PageClass extends AbstractPage<Item>,
77
+ Item = ReturnType<PageClass['getPaginatedItems']>[number],
78
+ >
79
+ extends APIPromise<PageClass>
80
+ implements AsyncIterable<Item>
81
+ {
82
+ constructor(
83
+ client: Surge,
84
+ request: Promise<APIResponseProps>,
85
+ Page: new (...args: ConstructorParameters<typeof AbstractPage>) => PageClass,
86
+ ) {
87
+ super(
88
+ client,
89
+ request,
90
+ async (client, props) =>
91
+ new Page(client, props.response, await defaultParseResponse(client, props), props.options),
92
+ );
93
+ }
94
+
95
+ /**
96
+ * Allow auto-paginating iteration on an unawaited list call, eg:
97
+ *
98
+ * for await (const item of client.items.list()) {
99
+ * console.log(item)
100
+ * }
101
+ */
102
+ async *[Symbol.asyncIterator](): AsyncGenerator<Item> {
103
+ const page = await this;
104
+ for await (const item of page) {
105
+ yield item;
106
+ }
107
+ }
108
+ }
109
+
110
+ export interface CursorResponse<Item> {
111
+ data: Array<Item>;
112
+
113
+ pagination: CursorResponse.Pagination;
114
+ }
115
+
116
+ export namespace CursorResponse {
117
+ export interface Pagination {
118
+ next_cursor?: string;
119
+
120
+ previous_cursor?: string;
121
+ }
122
+ }
123
+
124
+ export interface CursorParams {
125
+ after?: string;
126
+
127
+ before?: string;
128
+ }
129
+
130
+ export class Cursor<Item> extends AbstractPage<Item> implements CursorResponse<Item> {
131
+ data: Array<Item>;
132
+
133
+ pagination: CursorResponse.Pagination;
134
+
135
+ constructor(client: Surge, response: Response, body: CursorResponse<Item>, options: FinalRequestOptions) {
136
+ super(client, response, body, options);
137
+
138
+ this.data = body.data || [];
139
+ this.pagination = body.pagination || {};
140
+ }
141
+
142
+ getPaginatedItems(): Item[] {
143
+ return this.data ?? [];
144
+ }
145
+
146
+ nextPageRequestOptions(): PageRequestOptions | null {
147
+ if ((this.options.query as Record<string, unknown>)?.['before']) {
148
+ // in reverse
149
+ const previous_cursor = this.pagination?.previous_cursor;
150
+ if (!previous_cursor) {
151
+ return null;
152
+ }
153
+
154
+ return {
155
+ ...this.options,
156
+ query: {
157
+ ...maybeObj(this.options.query),
158
+ before: previous_cursor,
159
+ },
160
+ };
161
+ }
162
+
163
+ const cursor = this.pagination?.next_cursor;
164
+ if (!cursor) {
165
+ return null;
166
+ }
167
+
168
+ return {
169
+ ...this.options,
170
+ query: {
171
+ ...maybeObj(this.options.query),
172
+ after: cursor,
173
+ },
174
+ };
175
+ }
176
+ }
package/src/index.ts CHANGED
@@ -5,6 +5,7 @@ export { Surge as default } from './client';
5
5
  export { type Uploadable, toFile } from './core/uploads';
6
6
  export { APIPromise } from './core/api-promise';
7
7
  export { Surge, type ClientOptions } from './client';
8
+ export { PagePromise } from './core/pagination';
8
9
  export {
9
10
  SurgeError,
10
11
  APIError,
@@ -29,6 +29,12 @@ export async function defaultParseResponse<T>(client: Surge, props: APIResponseP
29
29
  const mediaType = contentType?.split(';')[0]?.trim();
30
30
  const isJSON = mediaType?.includes('application/json') || mediaType?.endsWith('+json');
31
31
  if (isJSON) {
32
+ const contentLength = response.headers.get('content-length');
33
+ if (contentLength === '0') {
34
+ // if there is no content we can't do anything
35
+ return undefined as T;
36
+ }
37
+
32
38
  const json = await response.json();
33
39
  return json as T;
34
40
  }
@@ -0,0 +1,2 @@
1
+ /** @deprecated Import from ./core/pagination instead */
2
+ export * from './core/pagination';
@@ -35,7 +35,7 @@ export interface Blast {
35
35
  /**
36
36
  * The message body.
37
37
  */
38
- body?: string;
38
+ body?: string | null;
39
39
 
40
40
  /**
41
41
  * Optional name for the blast.
@@ -63,10 +63,10 @@ export interface BlastCreateParams {
63
63
  /**
64
64
  * The message body.
65
65
  */
66
- body?: string;
66
+ body?: string | null;
67
67
 
68
68
  /**
69
- * @deprecated Deprecated. Use `to` instead.
69
+ * @deprecated Use `to` to specify recipients instead.
70
70
  */
71
71
  contacts?: Array<string>;
72
72
 
@@ -83,7 +83,7 @@ export interface BlastCreateParams {
83
83
  name?: string;
84
84
 
85
85
  /**
86
- * @deprecated Deprecated. Use `to` instead.
86
+ * @deprecated Use `to` to specify recipients instead.
87
87
  */
88
88
  segments?: Array<string>;
89
89
 
@@ -37,6 +37,20 @@ export class Campaigns extends APIResource {
37
37
  create(accountID: string, body: CampaignCreateParams, options?: RequestOptions): APIPromise<Campaign> {
38
38
  return this._client.post(path`/accounts/${accountID}/campaigns`, { body, ...options });
39
39
  }
40
+
41
+ /**
42
+ * Retrieves a Campaign object.
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * const campaign = await client.campaigns.retrieve(
47
+ * 'cpn_01k0qczvhbet4azgn5xm2ccfst',
48
+ * );
49
+ * ```
50
+ */
51
+ retrieve(id: string, options?: RequestOptions): APIPromise<Campaign> {
52
+ return this._client.get(path`/campaigns/${id}`, options);
53
+ }
40
54
  }
41
55
 
42
56
  /**
@@ -94,6 +108,11 @@ export interface Campaign {
94
108
  */
95
109
  privacy_policy_url: string;
96
110
 
111
+ /**
112
+ * The current status of the campaign.
113
+ */
114
+ status: 'active' | 'canceled' | 'created' | 'deactivated' | 'in_review' | 'pending' | 'rejected';
115
+
97
116
  /**
98
117
  * A list containing 1-5 types of messages that will be sent with this campaign.
99
118
  *
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { APIResource } from '../core/resource';
4
4
  import { APIPromise } from '../core/api-promise';
5
+ import { Cursor, type CursorParams, PagePromise } from '../core/pagination';
5
6
  import { RequestOptions } from '../internal/request-options';
6
7
  import { path } from '../internal/utils/path';
7
8
 
@@ -50,8 +51,34 @@ export class Contacts extends APIResource {
50
51
  update(id: string, body: ContactUpdateParams, options?: RequestOptions): APIPromise<Contact> {
51
52
  return this._client.patch(path`/contacts/${id}`, { body, ...options });
52
53
  }
54
+
55
+ /**
56
+ * List all contacts for an account with cursor-based pagination.
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * // Automatically fetches more pages as needed.
61
+ * for await (const contact of client.contacts.list(
62
+ * 'acct_01j9a43avnfqzbjfch6pygv1td',
63
+ * )) {
64
+ * // ...
65
+ * }
66
+ * ```
67
+ */
68
+ list(
69
+ accountID: string,
70
+ query: ContactListParams | null | undefined = {},
71
+ options?: RequestOptions,
72
+ ): PagePromise<ContactsCursor, Contact> {
73
+ return this._client.getAPIList(path`/accounts/${accountID}/contacts`, Cursor<Contact>, {
74
+ query,
75
+ ...options,
76
+ });
77
+ }
53
78
  }
54
79
 
80
+ export type ContactsCursor = Cursor<Contact>;
81
+
55
82
  /**
56
83
  * A contact who has consented to receive messages
57
84
  */
@@ -141,10 +168,14 @@ export interface ContactUpdateParams {
141
168
  metadata?: { [key: string]: string };
142
169
  }
143
170
 
171
+ export interface ContactListParams extends CursorParams {}
172
+
144
173
  export declare namespace Contacts {
145
174
  export {
146
175
  type Contact as Contact,
176
+ type ContactsCursor as ContactsCursor,
147
177
  type ContactCreateParams as ContactCreateParams,
148
178
  type ContactUpdateParams as ContactUpdateParams,
179
+ type ContactListParams as ContactListParams,
149
180
  };
150
181
  }
@@ -12,9 +12,29 @@ export {
12
12
  } from './accounts';
13
13
  export { Blasts, type Blast, type BlastCreateParams } from './blasts';
14
14
  export { Campaigns, type Campaign, type CampaignCreateParams } from './campaigns';
15
- export { Contacts, type Contact, type ContactCreateParams, type ContactUpdateParams } from './contacts';
16
- export { Messages, type Message, type MessageCreateParams } from './messages';
17
- export { PhoneNumbers, type PhoneNumber, type PhoneNumberPurchaseParams } from './phone-numbers';
15
+ export {
16
+ Contacts,
17
+ type Contact,
18
+ type ContactCreateParams,
19
+ type ContactUpdateParams,
20
+ type ContactListParams,
21
+ type ContactsCursor,
22
+ } from './contacts';
23
+ export {
24
+ Messages,
25
+ type Message,
26
+ type MessageCreateParams,
27
+ type MessageListParams,
28
+ type MessagesCursor,
29
+ } from './messages';
30
+ export {
31
+ PhoneNumbers,
32
+ type PhoneNumber,
33
+ type PhoneNumberListParams,
34
+ type PhoneNumberPurchaseParams,
35
+ type PhoneNumbersCursor,
36
+ } from './phone-numbers';
37
+ export { Recordings, type RecordingGetFileResponse } from './recordings';
18
38
  export {
19
39
  Users,
20
40
  type User,
@@ -42,5 +62,7 @@ export {
42
62
  type MessageFailedWebhookEvent,
43
63
  type MessageReceivedWebhookEvent,
44
64
  type MessageSentWebhookEvent,
65
+ type RecordingCompletedWebhookEvent,
66
+ type VoicemailReceivedWebhookEvent,
45
67
  type UnwrapWebhookEvent,
46
68
  } from './webhooks';
@@ -3,6 +3,7 @@
3
3
  import { APIResource } from '../core/resource';
4
4
  import * as ContactsAPI from './contacts';
5
5
  import { APIPromise } from '../core/api-promise';
6
+ import { Cursor, type CursorParams, PagePromise } from '../core/pagination';
6
7
  import { RequestOptions } from '../internal/request-options';
7
8
  import { path } from '../internal/utils/path';
8
9
 
@@ -63,8 +64,34 @@ export class Messages extends APIResource {
63
64
  retrieve(id: string, options?: RequestOptions): APIPromise<Message> {
64
65
  return this._client.get(path`/messages/${id}`, options);
65
66
  }
67
+
68
+ /**
69
+ * List all messages for an account with cursor-based pagination.
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * // Automatically fetches more pages as needed.
74
+ * for await (const message of client.messages.list(
75
+ * 'acct_01j9a43avnfqzbjfch6pygv1td',
76
+ * )) {
77
+ * // ...
78
+ * }
79
+ * ```
80
+ */
81
+ list(
82
+ accountID: string,
83
+ query: MessageListParams | null | undefined = {},
84
+ options?: RequestOptions,
85
+ ): PagePromise<MessagesCursor, Message> {
86
+ return this._client.getAPIList(path`/accounts/${accountID}/messages`, Cursor<Message>, {
87
+ query,
88
+ ...options,
89
+ });
90
+ }
66
91
  }
67
92
 
93
+ export type MessagesCursor = Cursor<Message>;
94
+
68
95
  /**
69
96
  * A Message is a communication sent to a Contact.
70
97
  */
@@ -80,12 +107,12 @@ export interface Message {
80
107
  * The ID of the blast this message belongs to, if any. This can be used to
81
108
  * attribute messages back to a specific blast.
82
109
  */
83
- blast_id?: string;
110
+ blast_id?: string | null;
84
111
 
85
112
  /**
86
113
  * The message body.
87
114
  */
88
- body?: string;
115
+ body?: string | null;
89
116
 
90
117
  /**
91
118
  * A conversation with a Contact
@@ -299,6 +326,13 @@ export declare namespace MessageCreateParams {
299
326
  }
300
327
  }
301
328
 
329
+ export interface MessageListParams extends CursorParams {}
330
+
302
331
  export declare namespace Messages {
303
- export { type Message as Message, type MessageCreateParams as MessageCreateParams };
332
+ export {
333
+ type Message as Message,
334
+ type MessagesCursor as MessagesCursor,
335
+ type MessageCreateParams as MessageCreateParams,
336
+ type MessageListParams as MessageListParams,
337
+ };
304
338
  }
@@ -2,10 +2,35 @@
2
2
 
3
3
  import { APIResource } from '../core/resource';
4
4
  import { APIPromise } from '../core/api-promise';
5
+ import { Cursor, type CursorParams, PagePromise } from '../core/pagination';
5
6
  import { RequestOptions } from '../internal/request-options';
6
7
  import { path } from '../internal/utils/path';
7
8
 
8
9
  export class PhoneNumbers extends APIResource {
10
+ /**
11
+ * List all phone numbers for an account with cursor-based pagination.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * // Automatically fetches more pages as needed.
16
+ * for await (const phoneNumber of client.phoneNumbers.list(
17
+ * 'acct_01j9a43avnfqzbjfch6pygv1td',
18
+ * )) {
19
+ * // ...
20
+ * }
21
+ * ```
22
+ */
23
+ list(
24
+ accountID: string,
25
+ query: PhoneNumberListParams | null | undefined = {},
26
+ options?: RequestOptions,
27
+ ): PagePromise<PhoneNumbersCursor, PhoneNumber> {
28
+ return this._client.getAPIList(path`/accounts/${accountID}/phone_numbers`, Cursor<PhoneNumber>, {
29
+ query,
30
+ ...options,
31
+ });
32
+ }
33
+
9
34
  /**
10
35
  * Purchase a new phone number for the account. You can specify search criteria or
11
36
  * let the system select a random number.
@@ -26,6 +51,8 @@ export class PhoneNumbers extends APIResource {
26
51
  }
27
52
  }
28
53
 
54
+ export type PhoneNumbersCursor = Cursor<PhoneNumber>;
55
+
29
56
  /**
30
57
  * A phone number that can be used to send and receive messages and calls
31
58
  */
@@ -46,6 +73,8 @@ export interface PhoneNumber {
46
73
  type: 'local' | 'short_code' | 'toll_free';
47
74
  }
48
75
 
76
+ export interface PhoneNumberListParams extends CursorParams {}
77
+
49
78
  export interface PhoneNumberPurchaseParams {
50
79
  /**
51
80
  * The desired area code for this phone number. If provided without type, the type
@@ -73,5 +102,10 @@ export interface PhoneNumberPurchaseParams {
73
102
  }
74
103
 
75
104
  export declare namespace PhoneNumbers {
76
- export { type PhoneNumber as PhoneNumber, type PhoneNumberPurchaseParams as PhoneNumberPurchaseParams };
105
+ export {
106
+ type PhoneNumber as PhoneNumber,
107
+ type PhoneNumbersCursor as PhoneNumbersCursor,
108
+ type PhoneNumberListParams as PhoneNumberListParams,
109
+ type PhoneNumberPurchaseParams as PhoneNumberPurchaseParams,
110
+ };
77
111
  }
@@ -0,0 +1,38 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../core/resource';
4
+ import * as Shared from './shared';
5
+ import { APIPromise } from '../core/api-promise';
6
+ import { RequestOptions } from '../internal/request-options';
7
+ import { path } from '../internal/utils/path';
8
+
9
+ export class Recordings extends APIResource {
10
+ /**
11
+ * Redirects to a signed URL where the recording audio file can be downloaded. URL
12
+ * is short-lived, so redirect should be followed immediately.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const response = await client.recordings.getFile(
17
+ * 'rec_01kfyc9dgdec1avkgs7tng8htg',
18
+ * );
19
+ * ```
20
+ */
21
+ getFile(recordingID: string, options?: RequestOptions): APIPromise<RecordingGetFileResponse> {
22
+ return this._client.get(path`/recordings/${recordingID}/file`, options);
23
+ }
24
+ }
25
+
26
+ /**
27
+ * An error response
28
+ */
29
+ export interface RecordingGetFileResponse {
30
+ /**
31
+ * An error response
32
+ */
33
+ error: Shared.Error;
34
+ }
35
+
36
+ export declare namespace Recordings {
37
+ export { type RecordingGetFileResponse as RecordingGetFileResponse };
38
+ }