@sentdm/sentdm 0.37.0 → 0.39.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 (88) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +31 -0
  3. package/client.d.mts +22 -8
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +22 -8
  6. package/client.d.ts.map +1 -1
  7. package/client.js +10 -0
  8. package/client.js.map +1 -1
  9. package/client.mjs +10 -0
  10. package/client.mjs.map +1 -1
  11. package/core/pagination.d.mts +164 -0
  12. package/core/pagination.d.mts.map +1 -0
  13. package/core/pagination.d.ts +164 -0
  14. package/core/pagination.d.ts.map +1 -0
  15. package/core/pagination.js +212 -0
  16. package/core/pagination.js.map +1 -0
  17. package/core/pagination.mjs +202 -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/tslib.js +17 -17
  28. package/package.json +11 -1
  29. package/pagination.d.mts +3 -0
  30. package/pagination.d.mts.map +1 -0
  31. package/pagination.d.ts +3 -0
  32. package/pagination.d.ts.map +1 -0
  33. package/pagination.js +6 -0
  34. package/pagination.js.map +1 -0
  35. package/pagination.mjs +3 -0
  36. package/pagination.mjs.map +1 -0
  37. package/resources/contacts.d.mts +9 -52
  38. package/resources/contacts.d.mts.map +1 -1
  39. package/resources/contacts.d.ts +9 -52
  40. package/resources/contacts.d.ts.map +1 -1
  41. package/resources/contacts.js +8 -7
  42. package/resources/contacts.js.map +1 -1
  43. package/resources/contacts.mjs +8 -7
  44. package/resources/contacts.mjs.map +1 -1
  45. package/resources/conversations.d.mts +17 -32
  46. package/resources/conversations.d.mts.map +1 -1
  47. package/resources/conversations.d.ts +17 -32
  48. package/resources/conversations.d.ts.map +1 -1
  49. package/resources/conversations.js +17 -16
  50. package/resources/conversations.js.map +1 -1
  51. package/resources/conversations.mjs +17 -16
  52. package/resources/conversations.mjs.map +1 -1
  53. package/resources/index.d.mts +4 -4
  54. package/resources/index.d.mts.map +1 -1
  55. package/resources/index.d.ts +4 -4
  56. package/resources/index.d.ts.map +1 -1
  57. package/resources/index.js.map +1 -1
  58. package/resources/index.mjs.map +1 -1
  59. package/resources/templates.d.mts +162 -65
  60. package/resources/templates.d.mts.map +1 -1
  61. package/resources/templates.d.ts +162 -65
  62. package/resources/templates.d.ts.map +1 -1
  63. package/resources/templates.js +36 -9
  64. package/resources/templates.js.map +1 -1
  65. package/resources/templates.mjs +36 -9
  66. package/resources/templates.mjs.map +1 -1
  67. package/resources/webhooks.d.mts +340 -134
  68. package/resources/webhooks.d.mts.map +1 -1
  69. package/resources/webhooks.d.ts +340 -134
  70. package/resources/webhooks.d.ts.map +1 -1
  71. package/resources/webhooks.js +16 -13
  72. package/resources/webhooks.js.map +1 -1
  73. package/resources/webhooks.mjs +16 -13
  74. package/resources/webhooks.mjs.map +1 -1
  75. package/src/client.ts +80 -6
  76. package/src/core/pagination.ts +428 -0
  77. package/src/index.ts +1 -0
  78. package/src/pagination.ts +2 -0
  79. package/src/resources/contacts.ts +15 -62
  80. package/src/resources/conversations.ts +36 -48
  81. package/src/resources/index.ts +9 -3
  82. package/src/resources/templates.ts +169 -75
  83. package/src/resources/webhooks.ts +404 -163
  84. package/src/version.ts +1 -1
  85. package/version.d.mts +1 -1
  86. package/version.d.ts +1 -1
  87. package/version.js +1 -1
  88. package/version.mjs +1 -1
@@ -0,0 +1,428 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { SentError } from './error';
4
+ import { FinalRequestOptions } from '../internal/request-options';
5
+ import { defaultParseResponse } from '../internal/parse';
6
+ import { type Sent } 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: Sent;
15
+ protected options: FinalRequestOptions;
16
+
17
+ protected response: Response;
18
+ protected body: unknown;
19
+
20
+ constructor(client: Sent, 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 SentError(
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: Sent,
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 ContactsPageResponse<Item> {
111
+ data: ContactsPageResponse.Data<Item>;
112
+ }
113
+
114
+ export namespace ContactsPageResponse {
115
+ export interface Data<Item> {
116
+ contacts?: Array<Item>;
117
+
118
+ pagination?: Data.Pagination;
119
+ }
120
+
121
+ export namespace Data {
122
+ export interface Pagination {
123
+ has_more?: boolean;
124
+ }
125
+ }
126
+ }
127
+
128
+ export interface ContactsPageParams {
129
+ page?: number;
130
+
131
+ page_size?: number;
132
+ }
133
+
134
+ export class ContactsPage<Item> extends AbstractPage<Item> implements ContactsPageResponse<Item> {
135
+ data: ContactsPageResponse.Data<Item>;
136
+
137
+ constructor(
138
+ client: Sent,
139
+ response: Response,
140
+ body: ContactsPageResponse<Item>,
141
+ options: FinalRequestOptions,
142
+ ) {
143
+ super(client, response, body, options);
144
+
145
+ this.data = body.data || {};
146
+ }
147
+
148
+ getPaginatedItems(): Item[] {
149
+ return this.data?.contacts ?? [];
150
+ }
151
+
152
+ override hasNextPage(): boolean {
153
+ if (this.data?.pagination?.has_more === false) {
154
+ return false;
155
+ }
156
+
157
+ return super.hasNextPage();
158
+ }
159
+
160
+ nextPageRequestOptions(): PageRequestOptions | null {
161
+ const query = this.options.query as ContactsPageParams;
162
+ const currentPage = query?.page ?? 1;
163
+
164
+ return {
165
+ ...this.options,
166
+ query: {
167
+ ...maybeObj(this.options.query),
168
+ page: currentPage + 1,
169
+ },
170
+ };
171
+ }
172
+ }
173
+
174
+ export interface ConversationsPageResponse<Item> {
175
+ data: ConversationsPageResponse.Data<Item>;
176
+ }
177
+
178
+ export namespace ConversationsPageResponse {
179
+ export interface Data<Item> {
180
+ messages?: Array<Item>;
181
+
182
+ pagination?: Data.Pagination;
183
+ }
184
+
185
+ export namespace Data {
186
+ export interface Pagination {
187
+ has_more?: boolean;
188
+ }
189
+ }
190
+ }
191
+
192
+ export interface ConversationsPageParams {
193
+ page?: number;
194
+
195
+ page_size?: number;
196
+ }
197
+
198
+ export class ConversationsPage<Item> extends AbstractPage<Item> implements ConversationsPageResponse<Item> {
199
+ data: ConversationsPageResponse.Data<Item>;
200
+
201
+ constructor(
202
+ client: Sent,
203
+ response: Response,
204
+ body: ConversationsPageResponse<Item>,
205
+ options: FinalRequestOptions,
206
+ ) {
207
+ super(client, response, body, options);
208
+
209
+ this.data = body.data || {};
210
+ }
211
+
212
+ getPaginatedItems(): Item[] {
213
+ return this.data?.messages ?? [];
214
+ }
215
+
216
+ override hasNextPage(): boolean {
217
+ if (this.data?.pagination?.has_more === false) {
218
+ return false;
219
+ }
220
+
221
+ return super.hasNextPage();
222
+ }
223
+
224
+ nextPageRequestOptions(): PageRequestOptions | null {
225
+ const query = this.options.query as ConversationsPageParams;
226
+ const currentPage = query?.page ?? 1;
227
+
228
+ return {
229
+ ...this.options,
230
+ query: {
231
+ ...maybeObj(this.options.query),
232
+ page: currentPage + 1,
233
+ },
234
+ };
235
+ }
236
+ }
237
+
238
+ export interface TemplatesPageResponse<Item> {
239
+ data: TemplatesPageResponse.Data<Item>;
240
+ }
241
+
242
+ export namespace TemplatesPageResponse {
243
+ export interface Data<Item> {
244
+ pagination?: Data.Pagination;
245
+
246
+ templates?: Array<Item>;
247
+ }
248
+
249
+ export namespace Data {
250
+ export interface Pagination {
251
+ has_more?: boolean;
252
+ }
253
+ }
254
+ }
255
+
256
+ export interface TemplatesPageParams {
257
+ page?: number;
258
+
259
+ page_size?: number;
260
+ }
261
+
262
+ export class TemplatesPage<Item> extends AbstractPage<Item> implements TemplatesPageResponse<Item> {
263
+ data: TemplatesPageResponse.Data<Item>;
264
+
265
+ constructor(
266
+ client: Sent,
267
+ response: Response,
268
+ body: TemplatesPageResponse<Item>,
269
+ options: FinalRequestOptions,
270
+ ) {
271
+ super(client, response, body, options);
272
+
273
+ this.data = body.data || {};
274
+ }
275
+
276
+ getPaginatedItems(): Item[] {
277
+ return this.data?.templates ?? [];
278
+ }
279
+
280
+ override hasNextPage(): boolean {
281
+ if (this.data?.pagination?.has_more === false) {
282
+ return false;
283
+ }
284
+
285
+ return super.hasNextPage();
286
+ }
287
+
288
+ nextPageRequestOptions(): PageRequestOptions | null {
289
+ const query = this.options.query as TemplatesPageParams;
290
+ const currentPage = query?.page ?? 1;
291
+
292
+ return {
293
+ ...this.options,
294
+ query: {
295
+ ...maybeObj(this.options.query),
296
+ page: currentPage + 1,
297
+ },
298
+ };
299
+ }
300
+ }
301
+
302
+ export interface WebhooksPageResponse<Item> {
303
+ data: WebhooksPageResponse.Data<Item>;
304
+ }
305
+
306
+ export namespace WebhooksPageResponse {
307
+ export interface Data<Item> {
308
+ pagination?: Data.Pagination;
309
+
310
+ webhooks?: Array<Item>;
311
+ }
312
+
313
+ export namespace Data {
314
+ export interface Pagination {
315
+ has_more?: boolean;
316
+ }
317
+ }
318
+ }
319
+
320
+ export interface WebhooksPageParams {
321
+ page?: number;
322
+
323
+ page_size?: number;
324
+ }
325
+
326
+ export class WebhooksPage<Item> extends AbstractPage<Item> implements WebhooksPageResponse<Item> {
327
+ data: WebhooksPageResponse.Data<Item>;
328
+
329
+ constructor(
330
+ client: Sent,
331
+ response: Response,
332
+ body: WebhooksPageResponse<Item>,
333
+ options: FinalRequestOptions,
334
+ ) {
335
+ super(client, response, body, options);
336
+
337
+ this.data = body.data || {};
338
+ }
339
+
340
+ getPaginatedItems(): Item[] {
341
+ return this.data?.webhooks ?? [];
342
+ }
343
+
344
+ override hasNextPage(): boolean {
345
+ if (this.data?.pagination?.has_more === false) {
346
+ return false;
347
+ }
348
+
349
+ return super.hasNextPage();
350
+ }
351
+
352
+ nextPageRequestOptions(): PageRequestOptions | null {
353
+ const query = this.options.query as WebhooksPageParams;
354
+ const currentPage = query?.page ?? 1;
355
+
356
+ return {
357
+ ...this.options,
358
+ query: {
359
+ ...maybeObj(this.options.query),
360
+ page: currentPage + 1,
361
+ },
362
+ };
363
+ }
364
+ }
365
+
366
+ export interface WebhookEventsPageResponse<Item> {
367
+ data: WebhookEventsPageResponse.Data<Item>;
368
+ }
369
+
370
+ export namespace WebhookEventsPageResponse {
371
+ export interface Data<Item> {
372
+ events?: Array<Item>;
373
+
374
+ pagination?: Data.Pagination;
375
+ }
376
+
377
+ export namespace Data {
378
+ export interface Pagination {
379
+ has_more?: boolean;
380
+ }
381
+ }
382
+ }
383
+
384
+ export interface WebhookEventsPageParams {
385
+ page?: number;
386
+
387
+ page_size?: number;
388
+ }
389
+
390
+ export class WebhookEventsPage<Item> extends AbstractPage<Item> implements WebhookEventsPageResponse<Item> {
391
+ data: WebhookEventsPageResponse.Data<Item>;
392
+
393
+ constructor(
394
+ client: Sent,
395
+ response: Response,
396
+ body: WebhookEventsPageResponse<Item>,
397
+ options: FinalRequestOptions,
398
+ ) {
399
+ super(client, response, body, options);
400
+
401
+ this.data = body.data || {};
402
+ }
403
+
404
+ getPaginatedItems(): Item[] {
405
+ return this.data?.events ?? [];
406
+ }
407
+
408
+ override hasNextPage(): boolean {
409
+ if (this.data?.pagination?.has_more === false) {
410
+ return false;
411
+ }
412
+
413
+ return super.hasNextPage();
414
+ }
415
+
416
+ nextPageRequestOptions(): PageRequestOptions | null {
417
+ const query = this.options.query as WebhookEventsPageParams;
418
+ const currentPage = query?.page ?? 1;
419
+
420
+ return {
421
+ ...this.options,
422
+ query: {
423
+ ...maybeObj(this.options.query),
424
+ page: currentPage + 1,
425
+ },
426
+ };
427
+ }
428
+ }
package/src/index.ts CHANGED
@@ -5,6 +5,7 @@ export { Sent as default } from './client';
5
5
  export { type Uploadable, toFile } from './core/uploads';
6
6
  export { APIPromise } from './core/api-promise';
7
7
  export { Sent, type ClientOptions } from './client';
8
+ export { PagePromise } from './core/pagination';
8
9
  export {
9
10
  SentError,
10
11
  APIError,
@@ -0,0 +1,2 @@
1
+ /** @deprecated Import from ./core/pagination instead */
2
+ export * from './core/pagination';
@@ -1,9 +1,9 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  import { APIResource } from '../core/resource';
4
- import * as ContactsAPI from './contacts';
5
4
  import * as WebhooksAPI from './webhooks';
6
5
  import { APIPromise } from '../core/api-promise';
6
+ import { ContactsPage, type ContactsPageParams, PagePromise } from '../core/pagination';
7
7
  import { buildHeaders } from '../internal/headers';
8
8
  import { RequestOptions } from '../internal/request-options';
9
9
  import { path } from '../internal/utils/path';
@@ -104,15 +104,18 @@ export class Contacts extends APIResource {
104
104
  *
105
105
  * @example
106
106
  * ```ts
107
- * const contacts = await client.contacts.list({
108
- * page: 0,
109
- * page_size: 0,
110
- * });
107
+ * // Automatically fetches more pages as needed.
108
+ * for await (const contactResponse of client.contacts.list()) {
109
+ * // ...
110
+ * }
111
111
  * ```
112
112
  */
113
- list(params: ContactListParams, options?: RequestOptions): APIPromise<ContactListResponse> {
114
- const { 'x-profile-id': xProfileID, ...query } = params;
115
- return this._client.get('/v3/contacts', {
113
+ list(
114
+ params: ContactListParams | null | undefined = {},
115
+ options?: RequestOptions,
116
+ ): PagePromise<ContactResponsesContactsPage, ContactResponse> {
117
+ const { 'x-profile-id': xProfileID, ...query } = params ?? {};
118
+ return this._client.getAPIList('/v3/contacts', ContactsPage<ContactResponse>, {
116
119
  query,
117
120
  ...options,
118
121
  headers: buildHeaders([
@@ -178,6 +181,8 @@ export class Contacts extends APIResource {
178
181
  }
179
182
  }
180
183
 
184
+ export type ContactResponsesContactsPage = ContactsPage<ContactResponse>;
185
+
181
186
  /**
182
187
  * Standard API response envelope for all v3 endpoints
183
188
  */
@@ -343,48 +348,6 @@ export interface ContactResponse {
343
348
  updated_at?: string | null;
344
349
  }
345
350
 
346
- /**
347
- * Standard API response envelope for all v3 endpoints
348
- */
349
- export interface ContactListResponse {
350
- /**
351
- * A paginated list of contacts.
352
- */
353
- data?: ContactListResponse.Data | null;
354
-
355
- /**
356
- * Error information
357
- */
358
- error?: WebhooksAPI.ErrorDetail | null;
359
-
360
- /**
361
- * Request and response metadata
362
- */
363
- meta?: WebhooksAPI.APIMeta;
364
-
365
- /**
366
- * Indicates whether the request was successful
367
- */
368
- success?: boolean;
369
- }
370
-
371
- export namespace ContactListResponse {
372
- /**
373
- * A paginated list of contacts.
374
- */
375
- export interface Data {
376
- /**
377
- * The contacts on this page.
378
- */
379
- contacts?: Array<ContactsAPI.ContactResponse>;
380
-
381
- /**
382
- * Pagination metadata for list responses
383
- */
384
- pagination?: WebhooksAPI.PaginationMeta;
385
- }
386
- }
387
-
388
351
  export interface ContactCreateParams {
389
352
  /**
390
353
  * Body param: Phone number of the contact to create
@@ -453,17 +416,7 @@ export interface ContactUpdateParams {
453
416
  'x-profile-id'?: string;
454
417
  }
455
418
 
456
- export interface ContactListParams {
457
- /**
458
- * Query param: Page number (1-indexed)
459
- */
460
- page: number;
461
-
462
- /**
463
- * Query param: Number of items per page
464
- */
465
- page_size: number;
466
-
419
+ export interface ContactListParams extends ContactsPageParams {
467
420
  /**
468
421
  * Query param: Optional channel filter (sms, whatsapp)
469
422
  */
@@ -516,7 +469,7 @@ export declare namespace Contacts {
516
469
  type APIResponseOfContactMessageSummary as APIResponseOfContactMessageSummary,
517
470
  type ContactMessageSummary as ContactMessageSummary,
518
471
  type ContactResponse as ContactResponse,
519
- type ContactListResponse as ContactListResponse,
472
+ type ContactResponsesContactsPage as ContactResponsesContactsPage,
520
473
  type ContactCreateParams as ContactCreateParams,
521
474
  type ContactRetrieveParams as ContactRetrieveParams,
522
475
  type ContactUpdateParams as ContactUpdateParams,
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { APIResource } from '../core/resource';
4
4
  import * as WebhooksAPI from './webhooks';
5
- import { APIPromise } from '../core/api-promise';
5
+ import { ConversationsPage, type ConversationsPageParams, PagePromise } from '../core/pagination';
6
6
  import { buildHeaders } from '../internal/headers';
7
7
  import { RequestOptions } from '../internal/request-options';
8
8
  import { path } from '../internal/utils/path';
@@ -21,19 +21,18 @@ export class Conversations extends APIResource {
21
21
  *
22
22
  * @example
23
23
  * ```ts
24
- * const apiResponseOfConversationMessagesList =
25
- * await client.conversations.list({
26
- * page: 0,
27
- * page_size: 0,
28
- * });
24
+ * // Automatically fetches more pages as needed.
25
+ * for await (const conversation of client.conversations.list()) {
26
+ * // ...
27
+ * }
29
28
  * ```
30
29
  */
31
30
  list(
32
- params: ConversationListParams,
31
+ params: ConversationListParams | null | undefined = {},
33
32
  options?: RequestOptions,
34
- ): APIPromise<APIResponseOfConversationMessagesList> {
35
- const { 'x-profile-id': xProfileID, ...query } = params;
36
- return this._client.get('/v3/conversations', {
33
+ ): PagePromise<ConversationMessagesListMessagesConversationsPage, ConversationMessagesList.Message> {
34
+ const { 'x-profile-id': xProfileID, ...query } = params ?? {};
35
+ return this._client.getAPIList('/v3/conversations', ConversationsPage<ConversationMessagesList.Message>, {
37
36
  query,
38
37
  ...options,
39
38
  headers: buildHeaders([
@@ -49,30 +48,38 @@ export class Conversations extends APIResource {
49
48
  *
50
49
  * @example
51
50
  * ```ts
52
- * const apiResponseOfConversationMessagesList =
53
- * await client.conversations.listMessages(
54
- * '08fab313-c9e2-502c-975e-08b0356c432e',
55
- * { page: 0, page_size: 0 },
56
- * );
51
+ * // Automatically fetches more pages as needed.
52
+ * for await (const conversation of client.conversations.listMessages(
53
+ * '08fab313-c9e2-502c-975e-08b0356c432e',
54
+ * )) {
55
+ * // ...
56
+ * }
57
57
  * ```
58
58
  */
59
59
  listMessages(
60
60
  id: string,
61
- params: ConversationListMessagesParams,
61
+ params: ConversationListMessagesParams | null | undefined = {},
62
62
  options?: RequestOptions,
63
- ): APIPromise<APIResponseOfConversationMessagesList> {
64
- const { 'x-profile-id': xProfileID, ...query } = params;
65
- return this._client.get(path`/v3/conversations/${id}`, {
66
- query,
67
- ...options,
68
- headers: buildHeaders([
69
- { ...(xProfileID != null ? { 'x-profile-id': xProfileID } : undefined) },
70
- options?.headers,
71
- ]),
72
- });
63
+ ): PagePromise<ConversationMessagesListMessagesConversationsPage, ConversationMessagesList.Message> {
64
+ const { 'x-profile-id': xProfileID, ...query } = params ?? {};
65
+ return this._client.getAPIList(
66
+ path`/v3/conversations/${id}`,
67
+ ConversationsPage<ConversationMessagesList.Message>,
68
+ {
69
+ query,
70
+ ...options,
71
+ headers: buildHeaders([
72
+ { ...(xProfileID != null ? { 'x-profile-id': xProfileID } : undefined) },
73
+ options?.headers,
74
+ ]),
75
+ },
76
+ );
73
77
  }
74
78
  }
75
79
 
80
+ export type ConversationMessagesListMessagesConversationsPage =
81
+ ConversationsPage<ConversationMessagesList.Message>;
82
+
76
83
  /**
77
84
  * Standard API response envelope for all v3 endpoints
78
85
  */
@@ -197,17 +204,7 @@ export namespace ConversationMessagesList {
197
204
  }
198
205
  }
199
206
 
200
- export interface ConversationListParams {
201
- /**
202
- * Query param
203
- */
204
- page: number;
205
-
206
- /**
207
- * Query param
208
- */
209
- page_size: number;
210
-
207
+ export interface ConversationListParams extends ConversationsPageParams {
211
208
  /**
212
209
  * Header param: Profile UUID to scope the request to a child profile. Only
213
210
  * organization API keys can use this header. The profile must belong to the
@@ -216,17 +213,7 @@ export interface ConversationListParams {
216
213
  'x-profile-id'?: string;
217
214
  }
218
215
 
219
- export interface ConversationListMessagesParams {
220
- /**
221
- * Query param
222
- */
223
- page: number;
224
-
225
- /**
226
- * Query param
227
- */
228
- page_size: number;
229
-
216
+ export interface ConversationListMessagesParams extends ConversationsPageParams {
230
217
  /**
231
218
  * Header param: Profile UUID to scope the request to a child profile. Only
232
219
  * organization API keys can use this header. The profile must belong to the
@@ -239,6 +226,7 @@ export declare namespace Conversations {
239
226
  export {
240
227
  type APIResponseOfConversationMessagesList as APIResponseOfConversationMessagesList,
241
228
  type ConversationMessagesList as ConversationMessagesList,
229
+ type ConversationMessagesListMessagesConversationsPage as ConversationMessagesListMessagesConversationsPage,
242
230
  type ConversationListParams as ConversationListParams,
243
231
  type ConversationListMessagesParams as ConversationListMessagesParams,
244
232
  };