sendblue 2.0.1 → 2.0.2

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 (65) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/client.d.mts +6 -3
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +6 -3
  5. package/client.d.ts.map +1 -1
  6. package/client.js +5 -2
  7. package/client.js.map +1 -1
  8. package/client.mjs +5 -2
  9. package/client.mjs.map +1 -1
  10. package/internal/to-file.d.mts +1 -1
  11. package/internal/to-file.d.ts +1 -1
  12. package/internal/to-file.js +1 -1
  13. package/internal/to-file.mjs +1 -1
  14. package/internal/utils/values.js +3 -3
  15. package/internal/utils/values.js.map +1 -1
  16. package/internal/utils/values.mjs +3 -3
  17. package/internal/utils/values.mjs.map +1 -1
  18. package/package.json +4 -1
  19. package/resources/contacts/contacts.d.mts +2 -28
  20. package/resources/contacts/contacts.d.mts.map +1 -1
  21. package/resources/contacts/contacts.d.ts +2 -28
  22. package/resources/contacts/contacts.d.ts.map +1 -1
  23. package/resources/contacts/contacts.js +2 -2
  24. package/resources/contacts/contacts.js.map +1 -1
  25. package/resources/contacts/contacts.mjs +2 -2
  26. package/resources/contacts/contacts.mjs.map +1 -1
  27. package/resources/contacts/index.d.mts +1 -1
  28. package/resources/contacts/index.d.mts.map +1 -1
  29. package/resources/contacts/index.d.ts +1 -1
  30. package/resources/contacts/index.d.ts.map +1 -1
  31. package/resources/contacts/index.js.map +1 -1
  32. package/resources/contacts/index.mjs.map +1 -1
  33. package/resources/index.d.mts +2 -1
  34. package/resources/index.d.mts.map +1 -1
  35. package/resources/index.d.ts +2 -1
  36. package/resources/index.d.ts.map +1 -1
  37. package/resources/index.js +3 -1
  38. package/resources/index.js.map +1 -1
  39. package/resources/index.mjs +1 -0
  40. package/resources/index.mjs.map +1 -1
  41. package/resources/messages.d.mts +0 -8
  42. package/resources/messages.d.mts.map +1 -1
  43. package/resources/messages.d.ts +0 -8
  44. package/resources/messages.d.ts.map +1 -1
  45. package/resources/webhooks.d.mts +224 -0
  46. package/resources/webhooks.d.mts.map +1 -0
  47. package/resources/webhooks.d.ts +224 -0
  48. package/resources/webhooks.d.ts.map +1 -0
  49. package/resources/webhooks.js +82 -0
  50. package/resources/webhooks.js.map +1 -0
  51. package/resources/webhooks.mjs +78 -0
  52. package/resources/webhooks.mjs.map +1 -0
  53. package/src/client.ts +30 -5
  54. package/src/internal/to-file.ts +1 -1
  55. package/src/internal/utils/values.ts +3 -3
  56. package/src/resources/contacts/contacts.ts +2 -38
  57. package/src/resources/contacts/index.ts +0 -1
  58. package/src/resources/index.ts +11 -1
  59. package/src/resources/messages.ts +0 -10
  60. package/src/resources/webhooks.ts +284 -0
  61. package/src/version.ts +1 -1
  62. package/version.d.mts +1 -1
  63. package/version.d.ts +1 -1
  64. package/version.js +1 -1
  65. package/version.mjs +1 -1
package/src/client.ts CHANGED
@@ -34,13 +34,23 @@ import {
34
34
  TypingIndicatorSendResponse,
35
35
  TypingIndicators,
36
36
  } from './resources/typing-indicators';
37
+ import {
38
+ WebhookConfiguration,
39
+ WebhookCreateParams,
40
+ WebhookCreateResponse,
41
+ WebhookDeleteParams,
42
+ WebhookDeleteResponse,
43
+ WebhookListResponse,
44
+ WebhookUpdateParams,
45
+ WebhookUpdateResponse,
46
+ Webhooks,
47
+ } from './resources/webhooks';
37
48
  import {
38
49
  Contact,
39
50
  ContactCountResponse,
40
51
  ContactCreateParams,
41
52
  ContactCreateResponse,
42
53
  ContactDeleteResponse,
43
- ContactListParams,
44
54
  ContactListResponse,
45
55
  ContactRetrieveResponse,
46
56
  ContactUpdateParams,
@@ -152,7 +162,7 @@ export class SendblueAPI {
152
162
  baseURL: string;
153
163
  maxRetries: number;
154
164
  timeout: number;
155
- logger: Logger | undefined;
165
+ logger: Logger;
156
166
  logLevel: LogLevel | undefined;
157
167
  fetchOptions: MergedRequestInit | undefined;
158
168
 
@@ -424,7 +434,7 @@ export class SendblueAPI {
424
434
  const response = await this.fetchWithTimeout(url, req, timeout, controller).catch(castToError);
425
435
  const headersTime = Date.now();
426
436
 
427
- if (response instanceof Error) {
437
+ if (response instanceof globalThis.Error) {
428
438
  const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
429
439
  if (options.signal?.aborted) {
430
440
  throw new Errors.APIUserAbortError();
@@ -731,7 +741,7 @@ export class SendblueAPI {
731
741
  // Preserve legacy string encoding behavior for now
732
742
  headers.values.has('content-type')) ||
733
743
  // `Blob` is superset of `File`
734
- body instanceof Blob ||
744
+ ((globalThis as any).Blob && body instanceof (globalThis as any).Blob) ||
735
745
  // `FormData` -> `multipart/form-data`
736
746
  body instanceof FormData ||
737
747
  // `URLSearchParams` -> `application/x-www-form-urlencoded`
@@ -776,13 +786,17 @@ export class SendblueAPI {
776
786
  lookups: API.Lookups = new API.Lookups(this);
777
787
  typingIndicators: API.TypingIndicators = new API.TypingIndicators(this);
778
788
  contacts: API.Contacts = new API.Contacts(this);
789
+ webhooks: API.Webhooks = new API.Webhooks(this);
779
790
  }
791
+
780
792
  SendblueAPI.Messages = Messages;
781
793
  SendblueAPI.Groups = Groups;
782
794
  SendblueAPI.MediaObjects = MediaObjects;
783
795
  SendblueAPI.Lookups = Lookups;
784
796
  SendblueAPI.TypingIndicators = TypingIndicators;
785
797
  SendblueAPI.Contacts = Contacts;
798
+ SendblueAPI.Webhooks = Webhooks;
799
+
786
800
  export declare namespace SendblueAPI {
787
801
  export type RequestOptions = Opts.RequestOptions;
788
802
 
@@ -834,7 +848,18 @@ export declare namespace SendblueAPI {
834
848
  type ContactVerifyResponse as ContactVerifyResponse,
835
849
  type ContactCreateParams as ContactCreateParams,
836
850
  type ContactUpdateParams as ContactUpdateParams,
837
- type ContactListParams as ContactListParams,
838
851
  type ContactVerifyParams as ContactVerifyParams,
839
852
  };
853
+
854
+ export {
855
+ Webhooks as Webhooks,
856
+ type WebhookConfiguration as WebhookConfiguration,
857
+ type WebhookCreateResponse as WebhookCreateResponse,
858
+ type WebhookUpdateResponse as WebhookUpdateResponse,
859
+ type WebhookListResponse as WebhookListResponse,
860
+ type WebhookDeleteResponse as WebhookDeleteResponse,
861
+ type WebhookCreateParams as WebhookCreateParams,
862
+ type WebhookUpdateParams as WebhookUpdateParams,
863
+ type WebhookDeleteParams as WebhookDeleteParams,
864
+ };
840
865
  }
@@ -73,7 +73,7 @@ export type ToFileInput =
73
73
 
74
74
  /**
75
75
  * Helper for creating a {@link File} to pass to an SDK upload method from a variety of different data formats
76
- * @param value the raw content of the file. Can be an {@link Uploadable}, {@link BlobLikePart}, or {@link AsyncIterable} of {@link BlobLikePart}s
76
+ * @param value the raw content of the file. Can be an {@link Uploadable}, BlobLikePart, or AsyncIterable of BlobLikeParts
77
77
  * @param {string=} name the name of the file. If omitted, toFile will try to determine a file name from bits if possible
78
78
  * @param {Object=} options additional properties
79
79
  * @param {string=} options.type the MIME type of the content
@@ -76,21 +76,21 @@ export const coerceBoolean = (value: unknown): boolean => {
76
76
  };
77
77
 
78
78
  export const maybeCoerceInteger = (value: unknown): number | undefined => {
79
- if (value === undefined) {
79
+ if (value == null) {
80
80
  return undefined;
81
81
  }
82
82
  return coerceInteger(value);
83
83
  };
84
84
 
85
85
  export const maybeCoerceFloat = (value: unknown): number | undefined => {
86
- if (value === undefined) {
86
+ if (value == null) {
87
87
  return undefined;
88
88
  }
89
89
  return coerceFloat(value);
90
90
  };
91
91
 
92
92
  export const maybeCoerceBoolean = (value: unknown): boolean | undefined => {
93
- if (value === undefined) {
93
+ if (value == null) {
94
94
  return undefined;
95
95
  }
96
96
  return coerceBoolean(value);
@@ -62,11 +62,8 @@ export class Contacts extends APIResource {
62
62
  * const contacts = await client.contacts.list();
63
63
  * ```
64
64
  */
65
- list(
66
- query: ContactListParams | null | undefined = {},
67
- options?: RequestOptions,
68
- ): APIPromise<ContactListResponse> {
69
- return this._client.get('/api/v2/contacts', { query, ...options });
65
+ list(options?: RequestOptions): APIPromise<ContactListResponse> {
66
+ return this._client.get('/api/v2/contacts', options);
70
67
  }
71
68
 
72
69
  /**
@@ -271,38 +268,6 @@ export interface ContactUpdateParams {
271
268
  tags?: Array<string>;
272
269
  }
273
270
 
274
- export interface ContactListParams {
275
- /**
276
- * Filter by contact ID
277
- */
278
- cid?: string;
279
-
280
- /**
281
- * Maximum number of contacts to return
282
- */
283
- limit?: number;
284
-
285
- /**
286
- * Number of contacts to skip
287
- */
288
- offset?: number;
289
-
290
- /**
291
- * Field to sort by
292
- */
293
- order_by?: string;
294
-
295
- /**
296
- * Sort direction
297
- */
298
- order_direction?: 'asc' | 'desc';
299
-
300
- /**
301
- * Filter by phone number
302
- */
303
- phone_number?: string;
304
- }
305
-
306
271
  export interface ContactVerifyParams {
307
272
  /**
308
273
  * Phone number to verify
@@ -324,7 +289,6 @@ export declare namespace Contacts {
324
289
  type ContactVerifyResponse as ContactVerifyResponse,
325
290
  type ContactCreateParams as ContactCreateParams,
326
291
  type ContactUpdateParams as ContactUpdateParams,
327
- type ContactListParams as ContactListParams,
328
292
  type ContactVerifyParams as ContactVerifyParams,
329
293
  };
330
294
 
@@ -19,6 +19,5 @@ export {
19
19
  type ContactVerifyResponse,
20
20
  type ContactCreateParams,
21
21
  type ContactUpdateParams,
22
- type ContactListParams,
23
22
  type ContactVerifyParams,
24
23
  } from './contacts';
@@ -12,7 +12,6 @@ export {
12
12
  type ContactVerifyResponse,
13
13
  type ContactCreateParams,
14
14
  type ContactUpdateParams,
15
- type ContactListParams,
16
15
  type ContactVerifyParams,
17
16
  } from './contacts/contacts';
18
17
  export {
@@ -38,3 +37,14 @@ export {
38
37
  type TypingIndicatorSendResponse,
39
38
  type TypingIndicatorSendParams,
40
39
  } from './typing-indicators';
40
+ export {
41
+ Webhooks,
42
+ type WebhookConfiguration,
43
+ type WebhookCreateResponse,
44
+ type WebhookUpdateResponse,
45
+ type WebhookListResponse,
46
+ type WebhookDeleteResponse,
47
+ type WebhookCreateParams,
48
+ type WebhookUpdateParams,
49
+ type WebhookDeleteParams,
50
+ } from './webhooks';
@@ -577,11 +577,6 @@ export interface MessageListParams {
577
577
  */
578
578
  message_type?: 'message' | 'group';
579
579
 
580
- /**
581
- * Filter by any phone number (from or to)
582
- */
583
- number?: string;
584
-
585
580
  /**
586
581
  * Number of messages to skip
587
582
  */
@@ -597,11 +592,6 @@ export interface MessageListParams {
597
592
  */
598
593
  order_direction?: 'asc' | 'desc';
599
594
 
600
- /**
601
- * Filter by Sendblue phone number
602
- */
603
- sendblue_number?: string;
604
-
605
595
  /**
606
596
  * Filter messages sent after this date (ISO 8601 format)
607
597
  */
@@ -0,0 +1,284 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../core/resource';
4
+ import { APIPromise } from '../core/api-promise';
5
+ import { RequestOptions } from '../internal/request-options';
6
+
7
+ export class Webhooks extends APIResource {
8
+ /**
9
+ * Add new webhooks to your account. This endpoint appends webhooks to the existing
10
+ * list.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * const webhook = await client.webhooks.create({
15
+ * webhooks: [
16
+ * 'https://example.com/new-webhook',
17
+ * {
18
+ * url: 'https://example.com/webhook-with-secret',
19
+ * secret: 'my-webhook-secret',
20
+ * },
21
+ * ],
22
+ * globalSecret: 'optional-global-secret',
23
+ * type: 'receive',
24
+ * });
25
+ * ```
26
+ */
27
+ create(body: WebhookCreateParams, options?: RequestOptions): APIPromise<WebhookCreateResponse> {
28
+ return this._client.post('/api/v2/account/webhooks', { body, ...options });
29
+ }
30
+
31
+ /**
32
+ * Replace all webhooks for your account. This endpoint completely replaces the
33
+ * existing webhook configuration.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * const webhook = await client.webhooks.update({
38
+ * webhooks: {
39
+ * receive: [
40
+ * 'https://example.com/webhook1',
41
+ * {
42
+ * url: 'https://example.com/webhook2',
43
+ * secret: 'webhook-secret',
44
+ * },
45
+ * ],
46
+ * call_log: ['https://example.com/call-webhook'],
47
+ * contact_created: [
48
+ * 'https://example.com/contact-webhook',
49
+ * ],
50
+ * globalSecret: 'my-global-secret',
51
+ * },
52
+ * });
53
+ * ```
54
+ */
55
+ update(body: WebhookUpdateParams, options?: RequestOptions): APIPromise<WebhookUpdateResponse> {
56
+ return this._client.put('/api/v2/account/webhooks', { body, ...options });
57
+ }
58
+
59
+ /**
60
+ * Get all webhooks configured for your account.
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * const webhooks = await client.webhooks.list();
65
+ * ```
66
+ */
67
+ list(options?: RequestOptions): APIPromise<WebhookListResponse> {
68
+ return this._client.get('/api/v2/account/webhooks', options);
69
+ }
70
+
71
+ /**
72
+ * Delete specific webhooks from your account.
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * const webhook = await client.webhooks.delete({
77
+ * webhooks: ['https://example.com'],
78
+ * });
79
+ * ```
80
+ */
81
+ delete(body: WebhookDeleteParams, options?: RequestOptions): APIPromise<WebhookDeleteResponse> {
82
+ return this._client.delete('/api/v2/account/webhooks', { body, ...options });
83
+ }
84
+ }
85
+
86
+ export interface WebhookConfiguration {
87
+ /**
88
+ * Webhooks for call logs
89
+ */
90
+ call_log?: Array<string | WebhookConfiguration.WebhookObject>;
91
+
92
+ /**
93
+ * Webhooks for contact creation (URL strings only)
94
+ */
95
+ contact_created?: Array<string>;
96
+
97
+ /**
98
+ * Global secret applied to all webhooks
99
+ */
100
+ globalSecret?: string;
101
+
102
+ /**
103
+ * Webhooks for line assignment
104
+ */
105
+ line_assigned?: Array<string | WebhookConfiguration.WebhookObject>;
106
+
107
+ /**
108
+ * Webhooks for blocked lines
109
+ */
110
+ line_blocked?: Array<string | WebhookConfiguration.WebhookObject>;
111
+
112
+ /**
113
+ * Webhooks for outbound messages
114
+ */
115
+ outbound?: Array<string | WebhookConfiguration.WebhookObject>;
116
+
117
+ /**
118
+ * Webhooks for inbound messages
119
+ */
120
+ receive?: Array<string | WebhookConfiguration.WebhookObject>;
121
+
122
+ /**
123
+ * Legacy secret field
124
+ */
125
+ secret?: string;
126
+ }
127
+
128
+ export namespace WebhookConfiguration {
129
+ export interface WebhookObject {
130
+ /**
131
+ * Webhook URL (HTTPS only)
132
+ */
133
+ url: string;
134
+
135
+ /**
136
+ * Secret for webhook verification
137
+ */
138
+ secret?: string;
139
+ }
140
+
141
+ export interface WebhookObject {
142
+ /**
143
+ * Webhook URL (HTTPS only)
144
+ */
145
+ url: string;
146
+
147
+ /**
148
+ * Secret for webhook verification
149
+ */
150
+ secret?: string;
151
+ }
152
+
153
+ export interface WebhookObject {
154
+ /**
155
+ * Webhook URL (HTTPS only)
156
+ */
157
+ url: string;
158
+
159
+ /**
160
+ * Secret for webhook verification
161
+ */
162
+ secret?: string;
163
+ }
164
+
165
+ export interface WebhookObject {
166
+ /**
167
+ * Webhook URL (HTTPS only)
168
+ */
169
+ url: string;
170
+
171
+ /**
172
+ * Secret for webhook verification
173
+ */
174
+ secret?: string;
175
+ }
176
+
177
+ export interface WebhookObject {
178
+ /**
179
+ * Webhook URL (HTTPS only)
180
+ */
181
+ url: string;
182
+
183
+ /**
184
+ * Secret for webhook verification
185
+ */
186
+ secret?: string;
187
+ }
188
+ }
189
+
190
+ export interface WebhookCreateResponse {
191
+ status: 'OK' | 'ERROR';
192
+
193
+ message?: string;
194
+
195
+ /**
196
+ * Updated webhook configration (partial)
197
+ */
198
+ webhooks?: WebhookConfiguration;
199
+ }
200
+
201
+ export interface WebhookUpdateResponse {
202
+ status: 'OK' | 'ERROR';
203
+
204
+ message?: string;
205
+
206
+ /**
207
+ * Updated webhook configration (partial)
208
+ */
209
+ webhooks?: WebhookConfiguration;
210
+ }
211
+
212
+ export interface WebhookListResponse {
213
+ status: 'OK' | 'ERROR';
214
+
215
+ message?: string;
216
+
217
+ webhooks?: WebhookConfiguration;
218
+ }
219
+
220
+ export interface WebhookDeleteResponse {
221
+ status: 'OK' | 'ERROR';
222
+
223
+ message?: string;
224
+ }
225
+
226
+ export interface WebhookCreateParams {
227
+ /**
228
+ * Array of webhook URLs or webhook objects to add
229
+ */
230
+ webhooks: Array<string | WebhookCreateParams.WebhookObject>;
231
+
232
+ /**
233
+ * Optional global secret to apply to all webhooks
234
+ */
235
+ globalSecret?: string;
236
+
237
+ /**
238
+ * Webhook type (default to 'receive')
239
+ */
240
+ type?: 'receive' | 'call_log' | 'line_blocked' | 'line_assigned' | 'outbound' | 'contact_created';
241
+ }
242
+
243
+ export namespace WebhookCreateParams {
244
+ export interface WebhookObject {
245
+ /**
246
+ * Webhook URL (HTTPS only)
247
+ */
248
+ url: string;
249
+
250
+ /**
251
+ * Secret for webhook verification
252
+ */
253
+ secret?: string;
254
+ }
255
+ }
256
+
257
+ export interface WebhookUpdateParams {
258
+ webhooks: WebhookConfiguration;
259
+ }
260
+
261
+ export interface WebhookDeleteParams {
262
+ /**
263
+ * Array of webhook URLs to delete
264
+ */
265
+ webhooks: Array<string>;
266
+
267
+ /**
268
+ * Webhook type (default to 'receive')
269
+ */
270
+ type?: 'receive' | 'call_log' | 'line_blocked' | 'line_assigned' | 'outbound' | 'contact_created';
271
+ }
272
+
273
+ export declare namespace Webhooks {
274
+ export {
275
+ type WebhookConfiguration as WebhookConfiguration,
276
+ type WebhookCreateResponse as WebhookCreateResponse,
277
+ type WebhookUpdateResponse as WebhookUpdateResponse,
278
+ type WebhookListResponse as WebhookListResponse,
279
+ type WebhookDeleteResponse as WebhookDeleteResponse,
280
+ type WebhookCreateParams as WebhookCreateParams,
281
+ type WebhookUpdateParams as WebhookUpdateParams,
282
+ type WebhookDeleteParams as WebhookDeleteParams,
283
+ };
284
+ }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '2.0.1'; // x-release-please-version
1
+ export const VERSION = '2.0.2'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.0.1";
1
+ export declare const VERSION = "2.0.2";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.0.1";
1
+ export declare const VERSION = "2.0.2";
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 = '2.0.1'; // x-release-please-version
4
+ exports.VERSION = '2.0.2'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '2.0.1'; // x-release-please-version
1
+ export const VERSION = '2.0.2'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map