@surgeapi/node 0.26.0 → 0.27.1

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 (77) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/client.d.mts +16 -16
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +16 -16
  5. package/client.d.ts.map +1 -1
  6. package/client.js.map +1 -1
  7. package/client.mjs +2 -2
  8. package/client.mjs.map +1 -1
  9. package/internal/to-file.d.mts +1 -1
  10. package/internal/to-file.d.ts +1 -1
  11. package/internal/to-file.js +1 -1
  12. package/internal/to-file.mjs +1 -1
  13. package/package.json +1 -1
  14. package/resources/accounts.d.mts +306 -191
  15. package/resources/accounts.d.mts.map +1 -1
  16. package/resources/accounts.d.ts +306 -191
  17. package/resources/accounts.d.ts.map +1 -1
  18. package/resources/blasts.d.mts +11 -32
  19. package/resources/blasts.d.mts.map +1 -1
  20. package/resources/blasts.d.ts +11 -32
  21. package/resources/blasts.d.ts.map +1 -1
  22. package/resources/blasts.js.map +1 -1
  23. package/resources/blasts.mjs.map +1 -1
  24. package/resources/campaigns.d.mts +108 -201
  25. package/resources/campaigns.d.mts.map +1 -1
  26. package/resources/campaigns.d.ts +108 -201
  27. package/resources/campaigns.d.ts.map +1 -1
  28. package/resources/contacts.d.mts +1 -28
  29. package/resources/contacts.d.mts.map +1 -1
  30. package/resources/contacts.d.ts +1 -28
  31. package/resources/contacts.d.ts.map +1 -1
  32. package/resources/index.d.mts +8 -8
  33. package/resources/index.d.mts.map +1 -1
  34. package/resources/index.d.ts +8 -8
  35. package/resources/index.d.ts.map +1 -1
  36. package/resources/index.js.map +1 -1
  37. package/resources/index.mjs +2 -2
  38. package/resources/index.mjs.map +1 -1
  39. package/resources/messages.d.mts +49 -81
  40. package/resources/messages.d.mts.map +1 -1
  41. package/resources/messages.d.ts +49 -81
  42. package/resources/messages.d.ts.map +1 -1
  43. package/resources/messages.js.map +1 -1
  44. package/resources/messages.mjs.map +1 -1
  45. package/resources/phone-numbers.d.mts +0 -30
  46. package/resources/phone-numbers.d.mts.map +1 -1
  47. package/resources/phone-numbers.d.ts +0 -30
  48. package/resources/phone-numbers.d.ts.map +1 -1
  49. package/resources/users.d.mts +1 -33
  50. package/resources/users.d.mts.map +1 -1
  51. package/resources/users.d.ts +1 -33
  52. package/resources/users.d.ts.map +1 -1
  53. package/resources/verifications.d.mts +1 -19
  54. package/resources/verifications.d.mts.map +1 -1
  55. package/resources/verifications.d.ts +1 -19
  56. package/resources/verifications.d.ts.map +1 -1
  57. package/resources/webhooks.d.mts +60 -41
  58. package/resources/webhooks.d.mts.map +1 -1
  59. package/resources/webhooks.d.ts +60 -41
  60. package/resources/webhooks.d.ts.map +1 -1
  61. package/src/client.ts +12 -43
  62. package/src/internal/to-file.ts +1 -1
  63. package/src/resources/accounts.ts +489 -284
  64. package/src/resources/blasts.ts +11 -42
  65. package/src/resources/campaigns.ts +121 -234
  66. package/src/resources/contacts.ts +0 -31
  67. package/src/resources/index.ts +8 -23
  68. package/src/resources/messages.ts +54 -99
  69. package/src/resources/phone-numbers.ts +0 -34
  70. package/src/resources/users.ts +0 -37
  71. package/src/resources/verifications.ts +1 -22
  72. package/src/resources/webhooks.ts +72 -39
  73. package/src/version.ts +1 -1
  74. package/version.d.mts +1 -1
  75. package/version.d.ts +1 -1
  76. package/version.js +1 -1
  77. package/version.mjs +1 -1
@@ -1,7 +1,6 @@
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 MessagesAPI from './messages';
5
4
  import * as ContactsAPI from './contacts';
6
5
  import { APIPromise } from '../core/api-promise';
7
6
  import { RequestOptions } from '../internal/request-options';
@@ -52,16 +51,6 @@ export class Messages extends APIResource {
52
51
  }
53
52
  }
54
53
 
55
- /**
56
- * Params for creating an attachment
57
- */
58
- export interface AttachmentParams {
59
- /**
60
- * The URL of the attachment.
61
- */
62
- url: string;
63
- }
64
-
65
54
  /**
66
55
  * A Message is a communication sent to a Contact.
67
56
  */
@@ -148,18 +137,11 @@ export namespace Message {
148
137
  }
149
138
  }
150
139
 
151
- /**
152
- * Payload for creating a message. Either an attachment or the body must be given.
153
- * You can specify the recipient either using the 'conversation' parameter or the
154
- * 'to'/'from' parameters, but not both.
155
- */
156
- export type MessageParams = MessageParams.MessageParamsWithConversation | MessageParams.SimpleMessageParams;
140
+ export type MessageCreateParams =
141
+ | MessageCreateParams.MessageParamsWithConversation
142
+ | MessageCreateParams.SimpleMessageParams;
157
143
 
158
- export namespace MessageParams {
159
- /**
160
- * Create a message while including parameters for the conversation in which the
161
- * message should be sent.
162
- */
144
+ export declare namespace MessageCreateParams {
163
145
  export interface MessageParamsWithConversation {
164
146
  /**
165
147
  * Params for selecting or creating a new conversation. Either the id or the
@@ -167,7 +149,7 @@ export namespace MessageParams {
167
149
  */
168
150
  conversation: MessageParamsWithConversation.Conversation;
169
151
 
170
- attachments?: Array<MessagesAPI.AttachmentParams>;
152
+ attachments?: Array<MessageParamsWithConversation.Attachment>;
171
153
 
172
154
  /**
173
155
  * The message body.
@@ -190,7 +172,7 @@ export namespace MessageParams {
190
172
  /**
191
173
  * Parameters for creating a contact
192
174
  */
193
- contact: ContactsAPI.ContactParams;
175
+ contact: Conversation.Contact;
194
176
 
195
177
  /**
196
178
  * The phone number from which to send the message. This can be either the phone
@@ -198,81 +180,47 @@ export namespace MessageParams {
198
180
  */
199
181
  phone_number?: string;
200
182
  }
201
- }
202
-
203
- /**
204
- * Create a basic message by specifying just the to/from phone numbers.
205
- */
206
- export interface SimpleMessageParams {
207
- /**
208
- * The recipient's phone number in E.164 format. Cannot be used together with
209
- * 'conversation'.
210
- */
211
- to: string;
212
-
213
- attachments?: Array<MessagesAPI.AttachmentParams>;
214
-
215
- /**
216
- * The message body.
217
- */
218
- body?: string;
219
-
220
- /**
221
- * The sender's phone number in E.164 format or phone number ID. If omitted, uses
222
- * the account's default phone number. Cannot be used together with 'conversation'.
223
- */
224
- from?: string;
225
-
226
- /**
227
- * An optional datetime for scheduling message up to a couple of months in the
228
- * future.
229
- */
230
- send_at?: string;
231
- }
232
- }
233
183
 
234
- export type MessageCreateParams =
235
- | MessageCreateParams.MessageParamsWithConversation
236
- | MessageCreateParams.SimpleMessageParams;
237
-
238
- export declare namespace MessageCreateParams {
239
- export interface MessageParamsWithConversation {
240
- /**
241
- * Params for selecting or creating a new conversation. Either the id or the
242
- * Contact must be given.
243
- */
244
- conversation: MessageParamsWithConversation.Conversation;
245
-
246
- attachments?: Array<AttachmentParams>;
247
-
248
- /**
249
- * The message body.
250
- */
251
- body?: string;
252
-
253
- /**
254
- * An optional datetime for scheduling message up to a couple of months in the
255
- * future.
256
- */
257
- send_at?: string;
258
- }
259
-
260
- export namespace MessageParamsWithConversation {
261
- /**
262
- * Params for selecting or creating a new conversation. Either the id or the
263
- * Contact must be given.
264
- */
265
- export interface Conversation {
184
+ export namespace Conversation {
266
185
  /**
267
186
  * Parameters for creating a contact
268
187
  */
269
- contact: ContactsAPI.ContactParams;
188
+ export interface Contact {
189
+ /**
190
+ * The contact's phone number in E.164 format.
191
+ */
192
+ phone_number: string;
193
+
194
+ /**
195
+ * The contact's email address.
196
+ */
197
+ email?: string;
198
+
199
+ /**
200
+ * The contact's first name.
201
+ */
202
+ first_name?: string;
203
+
204
+ /**
205
+ * The contact's last name.
206
+ */
207
+ last_name?: string;
208
+
209
+ /**
210
+ * Set of key-value pairs that will be stored with the object.
211
+ */
212
+ metadata?: { [key: string]: string };
213
+ }
214
+ }
270
215
 
216
+ /**
217
+ * Params for creating an attachment
218
+ */
219
+ export interface Attachment {
271
220
  /**
272
- * The phone number from which to send the message. This can be either the phone
273
- * number in E.164 format or a Surge phone number id.
221
+ * The URL of the attachment.
274
222
  */
275
- phone_number?: string;
223
+ url: string;
276
224
  }
277
225
  }
278
226
 
@@ -283,7 +231,7 @@ export declare namespace MessageCreateParams {
283
231
  */
284
232
  to: string;
285
233
 
286
- attachments?: Array<AttachmentParams>;
234
+ attachments?: Array<SimpleMessageParams.Attachment>;
287
235
 
288
236
  /**
289
237
  * The message body.
@@ -302,13 +250,20 @@ export declare namespace MessageCreateParams {
302
250
  */
303
251
  send_at?: string;
304
252
  }
253
+
254
+ export namespace SimpleMessageParams {
255
+ /**
256
+ * Params for creating an attachment
257
+ */
258
+ export interface Attachment {
259
+ /**
260
+ * The URL of the attachment.
261
+ */
262
+ url: string;
263
+ }
264
+ }
305
265
  }
306
266
 
307
267
  export declare namespace Messages {
308
- export {
309
- type AttachmentParams as AttachmentParams,
310
- type Message as Message,
311
- type MessageParams as MessageParams,
312
- type MessageCreateParams as MessageCreateParams,
313
- };
268
+ export { type Message as Message, type MessageCreateParams as MessageCreateParams };
314
269
  }
@@ -46,40 +46,6 @@ export interface PhoneNumber {
46
46
  type: 'local' | 'toll_free';
47
47
  }
48
48
 
49
- /**
50
- * Parameters for purchasing a new phone number. The system will automatically
51
- * infer the type in certain cases:
52
- *
53
- * - If only area_code is provided, type is inferred from the area code
54
- * - If only latitude/longitude are provided, type is inferred as 'local'
55
- * - Otherwise, type must be explicitly specified
56
- */
57
- export interface PhoneNumberPurchaseParams {
58
- /**
59
- * The desired area code for this phone number. If provided without type, the type
60
- * will be inferred.
61
- */
62
- area_code?: string;
63
-
64
- /**
65
- * Latitude to search for nearby phone numbers. Must be used with longitude. If
66
- * provided without type, type will be inferred as 'local'.
67
- */
68
- latitude?: number;
69
-
70
- /**
71
- * Longitude to search for nearby phone numbers. Must be used with latitude. If
72
- * provided without type, type will be inferred as 'local'.
73
- */
74
- longitude?: number;
75
-
76
- /**
77
- * Whether the phone number is local or toll-free. Can be omitted if area_code or
78
- * latitude/longitude are provided.
79
- */
80
- type?: 'local' | 'toll_free';
81
- }
82
-
83
49
  export interface PhoneNumberPurchaseParams {
84
50
  /**
85
51
  * The desired area code for this phone number. If provided without type, the type
@@ -100,41 +100,6 @@ export interface User {
100
100
  photo_url?: string;
101
101
  }
102
102
 
103
- /**
104
- * POST body for creating a user
105
- */
106
- export interface UserParams {
107
- /**
108
- * The user's first name.
109
- */
110
- first_name: string;
111
-
112
- /**
113
- * The user's last name.
114
- */
115
- last_name?: string;
116
-
117
- /**
118
- * Set of key-value pairs that will be stored with the object.
119
- */
120
- metadata?: { [key: string]: string };
121
-
122
- /**
123
- * URL of a photo to be used as the user's avatar.
124
- */
125
- photo_url?: string;
126
- }
127
-
128
- /**
129
- * A request to create a token
130
- */
131
- export interface UserTokenParams {
132
- /**
133
- * For how many seconds the token should be accepted. Defaults to 15 minutes.
134
- */
135
- duration_seconds?: number;
136
- }
137
-
138
103
  /**
139
104
  * Response when token has been created successfully
140
105
  */
@@ -199,8 +164,6 @@ export interface UserCreateTokenParams {
199
164
  export declare namespace Users {
200
165
  export {
201
166
  type User as User,
202
- type UserParams as UserParams,
203
- type UserTokenParams as UserTokenParams,
204
167
  type UserTokenResponse as UserTokenResponse,
205
168
  type UserCreateParams as UserCreateParams,
206
169
  type UserUpdateParams as UserUpdateParams,
@@ -76,26 +76,6 @@ export interface VerificationCheck {
76
76
  verification?: Verification;
77
77
  }
78
78
 
79
- /**
80
- * Parameters for checking a Verification code
81
- */
82
- export interface VerificationCheckParams {
83
- /**
84
- * The Verification code that was received.
85
- */
86
- code: string;
87
- }
88
-
89
- /**
90
- * Parameters for creating a Verification
91
- */
92
- export interface VerificationParams {
93
- /**
94
- * The phone number to be verified. In E.164 format.
95
- */
96
- phone_number: string;
97
- }
98
-
99
79
  export interface VerificationCreateParams {
100
80
  /**
101
81
  * The phone number to be verified. In E.164 format.
@@ -114,8 +94,7 @@ export declare namespace Verifications {
114
94
  export {
115
95
  type Verification as Verification,
116
96
  type VerificationCheck as VerificationCheck,
117
- type VerificationCheckParams as VerificationCheckParams,
118
- type VerificationParams as VerificationParams,
119
97
  type VerificationCreateParams as VerificationCreateParams,
98
+ type VerificationCheckParams as VerificationCheckParams,
120
99
  };
121
100
  }
@@ -20,10 +20,6 @@ export class Webhooks extends APIResource {
20
20
  }
21
21
  }
22
22
 
23
- /**
24
- * The `call.ended` event is delivered whenever a call is completed between a Surge
25
- * number you own and another phone number.
26
- */
27
23
  export interface CallEndedWebhookEvent {
28
24
  /**
29
25
  * The ID of the account in which this event occurred
@@ -87,10 +83,6 @@ export namespace CallEndedWebhookEvent {
87
83
  }
88
84
  }
89
85
 
90
- /**
91
- * The `campaign.approved` event is delivered whenever a campaign is approved by
92
- * all of the US carriers and able to start sending text messages.
93
- */
94
86
  export interface CampaignApprovedWebhookEvent {
95
87
  /**
96
88
  * The ID of the account in which this event occurred
@@ -130,13 +122,74 @@ export namespace CampaignApprovedWebhookEvent {
130
122
  }
131
123
  }
132
124
 
133
- /**
134
- * The `conversation.created` event is delivered whenever a new conversation is
135
- * started with a contact. This could be when either the contact sends a message to
136
- * your Surge number or when you create a conversation, whether by sending an
137
- * initial message to the contact or by manually creating the conversation using
138
- * the API.
139
- */
125
+ export interface ContactOptedInWebhookEvent {
126
+ /**
127
+ * The ID of the account in which this event occurred
128
+ */
129
+ account_id: string;
130
+
131
+ /**
132
+ * The data associated with the event
133
+ */
134
+ data: ContactOptedInWebhookEvent.Data;
135
+
136
+ /**
137
+ * The timestamp when this event occurred, in ISO8601 format
138
+ */
139
+ timestamp: string;
140
+
141
+ /**
142
+ * The type of the event. Always `contact.opted_in` for this event.
143
+ */
144
+ type: 'contact.opted_in';
145
+ }
146
+
147
+ export namespace ContactOptedInWebhookEvent {
148
+ /**
149
+ * The data associated with the event
150
+ */
151
+ export interface Data {
152
+ /**
153
+ * The unique identifier for the contact
154
+ */
155
+ id: string;
156
+ }
157
+ }
158
+
159
+ export interface ContactOptedOutWebhookEvent {
160
+ /**
161
+ * The ID of the account in which this event occurred
162
+ */
163
+ account_id: string;
164
+
165
+ /**
166
+ * The data associated with the event
167
+ */
168
+ data: ContactOptedOutWebhookEvent.Data;
169
+
170
+ /**
171
+ * The timestamp when this event occurred, in ISO8601 format
172
+ */
173
+ timestamp: string;
174
+
175
+ /**
176
+ * The type of the event. Always `contact.opted_out` for this event.
177
+ */
178
+ type: 'contact.opted_out';
179
+ }
180
+
181
+ export namespace ContactOptedOutWebhookEvent {
182
+ /**
183
+ * The data associated with the event
184
+ */
185
+ export interface Data {
186
+ /**
187
+ * The unique identifier for the contact
188
+ */
189
+ id: string;
190
+ }
191
+ }
192
+
140
193
  export interface ConversationCreatedWebhookEvent {
141
194
  /**
142
195
  * The ID of the account in which this event occurred
@@ -181,14 +234,6 @@ export namespace ConversationCreatedWebhookEvent {
181
234
  }
182
235
  }
183
236
 
184
- /**
185
- * The `message.delivered` event is delivered whenever a message sent from a Surge
186
- * number is successfully delivered to the recipient. When the message is sent from
187
- * a short code or toll-free number, this means that the message arrived on the
188
- * recipient's device. When sent from a local number, this means that the message
189
- * was successfully handed off to the recipient's mobile carrier, but does not
190
- * guarantee that it arrived on the recipient's device.
191
- */
192
237
  export interface MessageDeliveredWebhookEvent {
193
238
  /**
194
239
  * The ID of the account in which this event occurred
@@ -282,10 +327,6 @@ export namespace MessageDeliveredWebhookEvent {
282
327
  }
283
328
  }
284
329
 
285
- /**
286
- * The `message.failed` event is delivered whenever a message sent from your Surge
287
- * number fails to be delivered.
288
- */
289
330
  export interface MessageFailedWebhookEvent {
290
331
  /**
291
332
  * The ID of the account in which this event occurred
@@ -384,10 +425,6 @@ export namespace MessageFailedWebhookEvent {
384
425
  }
385
426
  }
386
427
 
387
- /**
388
- * The `message.received` event is delivered whenever a message is received at a
389
- * Surge number from a contact.
390
- */
391
428
  export interface MessageReceivedWebhookEvent {
392
429
  /**
393
430
  * The ID of the account in which this event occurred
@@ -481,10 +518,6 @@ export namespace MessageReceivedWebhookEvent {
481
518
  }
482
519
  }
483
520
 
484
- /**
485
- * The `message.sent` event is delivered whenever a message is sent from a Surge
486
- * number to a contact.
487
- */
488
521
  export interface MessageSentWebhookEvent {
489
522
  /**
490
523
  * The ID of the account in which this event occurred
@@ -578,13 +611,11 @@ export namespace MessageSentWebhookEvent {
578
611
  }
579
612
  }
580
613
 
581
- /**
582
- * The `call.ended` event is delivered whenever a call is completed between a Surge
583
- * number you own and another phone number.
584
- */
585
614
  export type UnwrapWebhookEvent =
586
615
  | CallEndedWebhookEvent
587
616
  | CampaignApprovedWebhookEvent
617
+ | ContactOptedInWebhookEvent
618
+ | ContactOptedOutWebhookEvent
588
619
  | ConversationCreatedWebhookEvent
589
620
  | MessageDeliveredWebhookEvent
590
621
  | MessageFailedWebhookEvent
@@ -595,6 +626,8 @@ export declare namespace Webhooks {
595
626
  export {
596
627
  type CallEndedWebhookEvent as CallEndedWebhookEvent,
597
628
  type CampaignApprovedWebhookEvent as CampaignApprovedWebhookEvent,
629
+ type ContactOptedInWebhookEvent as ContactOptedInWebhookEvent,
630
+ type ContactOptedOutWebhookEvent as ContactOptedOutWebhookEvent,
598
631
  type ConversationCreatedWebhookEvent as ConversationCreatedWebhookEvent,
599
632
  type MessageDeliveredWebhookEvent as MessageDeliveredWebhookEvent,
600
633
  type MessageFailedWebhookEvent as MessageFailedWebhookEvent,
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.26.0'; // x-release-please-version
1
+ export const VERSION = '0.27.1'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.26.0";
1
+ export declare const VERSION = "0.27.1";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.26.0";
1
+ export declare const VERSION = "0.27.1";
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.26.0'; // x-release-please-version
4
+ exports.VERSION = '0.27.1'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.26.0'; // x-release-please-version
1
+ export const VERSION = '0.27.1'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map