@surgeapi/node 0.33.0 → 0.35.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 (97) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +31 -0
  3. package/client.d.mts +12 -6
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +12 -6
  6. package/client.d.ts.map +1 -1
  7. package/client.js +11 -2
  8. package/client.js.map +1 -1
  9. package/client.mjs +14 -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 +10 -4
  44. package/resources/blasts.d.mts.map +1 -1
  45. package/resources/blasts.d.ts +10 -4
  46. package/resources/blasts.d.ts.map +1 -1
  47. package/resources/contacts.d.mts +19 -1
  48. package/resources/contacts.d.mts.map +1 -1
  49. package/resources/contacts.d.ts +19 -1
  50. package/resources/contacts.d.ts.map +1 -1
  51. package/resources/contacts.js +20 -0
  52. package/resources/contacts.js.map +1 -1
  53. package/resources/contacts.mjs +20 -0
  54. package/resources/contacts.mjs.map +1 -1
  55. package/resources/index.d.mts +3 -3
  56. package/resources/index.d.mts.map +1 -1
  57. package/resources/index.d.ts +3 -3
  58. package/resources/index.d.ts.map +1 -1
  59. package/resources/index.js.map +1 -1
  60. package/resources/index.mjs +3 -3
  61. package/resources/index.mjs.map +1 -1
  62. package/resources/messages.d.mts +25 -2
  63. package/resources/messages.d.mts.map +1 -1
  64. package/resources/messages.d.ts +25 -2
  65. package/resources/messages.d.ts.map +1 -1
  66. package/resources/messages.js +20 -0
  67. package/resources/messages.js.map +1 -1
  68. package/resources/messages.mjs +20 -0
  69. package/resources/messages.mjs.map +1 -1
  70. package/resources/phone-numbers.d.mts +20 -2
  71. package/resources/phone-numbers.d.mts.map +1 -1
  72. package/resources/phone-numbers.d.ts +20 -2
  73. package/resources/phone-numbers.d.ts.map +1 -1
  74. package/resources/phone-numbers.js +20 -0
  75. package/resources/phone-numbers.js.map +1 -1
  76. package/resources/phone-numbers.mjs +20 -0
  77. package/resources/phone-numbers.mjs.map +1 -1
  78. package/resources/webhooks.d.mts +24 -4
  79. package/resources/webhooks.d.mts.map +1 -1
  80. package/resources/webhooks.d.ts +24 -4
  81. package/resources/webhooks.d.ts.map +1 -1
  82. package/src/client.ts +60 -6
  83. package/src/core/pagination.ts +176 -0
  84. package/src/index.ts +1 -0
  85. package/src/internal/parse.ts +6 -0
  86. package/src/pagination.ts +2 -0
  87. package/src/resources/blasts.ts +11 -4
  88. package/src/resources/contacts.ts +31 -0
  89. package/src/resources/index.ts +22 -3
  90. package/src/resources/messages.ts +42 -2
  91. package/src/resources/phone-numbers.ts +36 -2
  92. package/src/resources/webhooks.ts +28 -4
  93. package/src/version.ts +1 -1
  94. package/version.d.mts +1 -1
  95. package/version.d.ts +1 -1
  96. package/version.js +1 -1
  97. package/version.mjs +1 -1
@@ -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,28 @@ 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';
18
37
  export {
19
38
  Users,
20
39
  type User,
@@ -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
  */
@@ -76,10 +103,16 @@ export interface Message {
76
103
 
77
104
  attachments?: Array<Message.Attachment>;
78
105
 
106
+ /**
107
+ * The ID of the blast this message belongs to, if any. This can be used to
108
+ * attribute messages back to a specific blast.
109
+ */
110
+ blast_id?: string;
111
+
79
112
  /**
80
113
  * The message body.
81
114
  */
82
- body?: string;
115
+ body?: string | null;
83
116
 
84
117
  /**
85
118
  * A conversation with a Contact
@@ -293,6 +326,13 @@ export declare namespace MessageCreateParams {
293
326
  }
294
327
  }
295
328
 
329
+ export interface MessageListParams extends CursorParams {}
330
+
296
331
  export declare namespace Messages {
297
- 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
+ };
298
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
  */
@@ -43,9 +70,11 @@ export interface PhoneNumber {
43
70
  /**
44
71
  * Whether the phone number is local, toll-free, or short code
45
72
  */
46
- type: 'local' | 'toll_free';
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
  }
@@ -313,7 +313,7 @@ export namespace MessageDeliveredWebhookEvent {
313
313
  /**
314
314
  * The content of the message
315
315
  */
316
- body: string;
316
+ body: string | null;
317
317
 
318
318
  /**
319
319
  * The conversation this message belongs to
@@ -329,6 +329,12 @@ export namespace MessageDeliveredWebhookEvent {
329
329
  * Attachments included with the message
330
330
  */
331
331
  attachments?: Array<Data.Attachment>;
332
+
333
+ /**
334
+ * The ID of the blast this message belongs to, if any. This can be used to
335
+ * attribute messages back to a specific blast.
336
+ */
337
+ blast_id?: string;
332
338
  }
333
339
 
334
340
  export namespace Data {
@@ -406,7 +412,7 @@ export namespace MessageFailedWebhookEvent {
406
412
  /**
407
413
  * The content of the message
408
414
  */
409
- body: string;
415
+ body: string | null;
410
416
 
411
417
  /**
412
418
  * The conversation this message belongs to
@@ -427,6 +433,12 @@ export namespace MessageFailedWebhookEvent {
427
433
  * Attachments included with the message
428
434
  */
429
435
  attachments?: Array<Data.Attachment>;
436
+
437
+ /**
438
+ * The ID of the blast this message belongs to, if any. This can be used to
439
+ * attribute messages back to a specific blast.
440
+ */
441
+ blast_id?: string;
430
442
  }
431
443
 
432
444
  export namespace Data {
@@ -504,7 +516,7 @@ export namespace MessageReceivedWebhookEvent {
504
516
  /**
505
517
  * The content of the message
506
518
  */
507
- body: string;
519
+ body: string | null;
508
520
 
509
521
  /**
510
522
  * The conversation this message belongs to
@@ -520,6 +532,12 @@ export namespace MessageReceivedWebhookEvent {
520
532
  * Attachments included with the message
521
533
  */
522
534
  attachments?: Array<Data.Attachment>;
535
+
536
+ /**
537
+ * The ID of the blast this message belongs to, if any. This can be used to
538
+ * attribute messages back to a specific blast.
539
+ */
540
+ blast_id?: string;
523
541
  }
524
542
 
525
543
  export namespace Data {
@@ -597,7 +615,7 @@ export namespace MessageSentWebhookEvent {
597
615
  /**
598
616
  * The content of the message
599
617
  */
600
- body: string;
618
+ body: string | null;
601
619
 
602
620
  /**
603
621
  * The conversation this message belongs to
@@ -613,6 +631,12 @@ export namespace MessageSentWebhookEvent {
613
631
  * Attachments included with the message
614
632
  */
615
633
  attachments?: Array<Data.Attachment>;
634
+
635
+ /**
636
+ * The ID of the blast this message belongs to, if any. This can be used to
637
+ * attribute messages back to a specific blast.
638
+ */
639
+ blast_id?: string;
616
640
  }
617
641
 
618
642
  export namespace Data {
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.33.0'; // x-release-please-version
1
+ export const VERSION = '0.35.0'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.33.0";
1
+ export declare const VERSION = "0.35.0";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.33.0";
1
+ export declare const VERSION = "0.35.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '0.33.0'; // x-release-please-version
4
+ exports.VERSION = '0.35.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.33.0'; // x-release-please-version
1
+ export const VERSION = '0.35.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map