@surgeapi/node 0.36.0 → 0.37.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 (53) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +8 -8
  3. package/client.d.mts +4 -4
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +4 -4
  6. package/client.d.ts.map +1 -1
  7. package/client.js +7 -0
  8. package/client.js.map +1 -1
  9. package/client.mjs +8 -1
  10. package/client.mjs.map +1 -1
  11. package/package.json +1 -1
  12. package/resources/campaigns.d.mts +19 -1
  13. package/resources/campaigns.d.mts.map +1 -1
  14. package/resources/campaigns.d.ts +19 -1
  15. package/resources/campaigns.d.ts.map +1 -1
  16. package/resources/campaigns.js +20 -0
  17. package/resources/campaigns.js.map +1 -1
  18. package/resources/campaigns.mjs +20 -0
  19. package/resources/campaigns.mjs.map +1 -1
  20. package/resources/index.d.mts +2 -2
  21. package/resources/index.d.mts.map +1 -1
  22. package/resources/index.d.ts +2 -2
  23. package/resources/index.d.ts.map +1 -1
  24. package/resources/index.js.map +1 -1
  25. package/resources/index.mjs +1 -1
  26. package/resources/index.mjs.map +1 -1
  27. package/resources/messages.d.mts +1 -1
  28. package/resources/messages.d.mts.map +1 -1
  29. package/resources/messages.d.ts +1 -1
  30. package/resources/messages.d.ts.map +1 -1
  31. package/resources/recordings.d.mts +58 -1
  32. package/resources/recordings.d.mts.map +1 -1
  33. package/resources/recordings.d.ts +58 -1
  34. package/resources/recordings.d.ts.map +1 -1
  35. package/resources/recordings.js +14 -0
  36. package/resources/recordings.js.map +1 -1
  37. package/resources/recordings.mjs +14 -0
  38. package/resources/recordings.mjs.map +1 -1
  39. package/resources/webhooks.d.mts +24 -0
  40. package/resources/webhooks.d.mts.map +1 -1
  41. package/resources/webhooks.d.ts +24 -0
  42. package/resources/webhooks.d.ts.map +1 -1
  43. package/src/client.ts +24 -4
  44. package/src/resources/campaigns.ts +35 -1
  45. package/src/resources/index.ts +8 -2
  46. package/src/resources/messages.ts +1 -1
  47. package/src/resources/recordings.ts +81 -1
  48. package/src/resources/webhooks.ts +20 -0
  49. package/src/version.ts +1 -1
  50. package/version.d.mts +1 -1
  51. package/version.d.ts +1 -1
  52. package/version.js +1 -1
  53. package/version.mjs +1 -1
package/src/client.ts CHANGED
@@ -29,7 +29,13 @@ import {
29
29
  Organization,
30
30
  } from './resources/accounts';
31
31
  import { Blast, BlastCreateParams, Blasts } from './resources/blasts';
32
- import { Campaign, CampaignCreateParams, Campaigns } from './resources/campaigns';
32
+ import {
33
+ Campaign,
34
+ CampaignCreateParams,
35
+ CampaignListParams,
36
+ Campaigns,
37
+ CampaignsCursor,
38
+ } from './resources/campaigns';
33
39
  import {
34
40
  Contact,
35
41
  ContactCreateParams,
@@ -52,7 +58,7 @@ import {
52
58
  PhoneNumbers,
53
59
  PhoneNumbersCursor,
54
60
  } from './resources/phone-numbers';
55
- import { RecordingGetFileResponse, Recordings } from './resources/recordings';
61
+ import { RecordingDeleteResponse, RecordingGetFileResponse, Recordings } from './resources/recordings';
56
62
  import {
57
63
  User,
58
64
  UserCreateParams,
@@ -510,7 +516,7 @@ export class Surge {
510
516
  loggerFor(this).info(`${responseInfo} - ${retryMessage}`);
511
517
 
512
518
  const errText = await response.text().catch((err: any) => castToError(err).message);
513
- const errJSON = safeJSON(errText);
519
+ const errJSON = safeJSON(errText) as any;
514
520
  const errMessage = errJSON ? undefined : errText;
515
521
 
516
522
  loggerFor(this).debug(
@@ -783,6 +789,14 @@ export class Surge {
783
789
  (Symbol.iterator in body && 'next' in body && typeof body.next === 'function'))
784
790
  ) {
785
791
  return { bodyHeaders: undefined, body: Shims.ReadableStreamFrom(body as AsyncIterable<Uint8Array>) };
792
+ } else if (
793
+ typeof body === 'object' &&
794
+ headers.values.get('content-type') === 'application/x-www-form-urlencoded'
795
+ ) {
796
+ return {
797
+ bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
798
+ body: this.stringifyQuery(body as Record<string, unknown>),
799
+ };
786
800
  } else {
787
801
  return this.#encoder({ body, headers });
788
802
  }
@@ -851,7 +865,9 @@ export declare namespace Surge {
851
865
  export {
852
866
  Campaigns as Campaigns,
853
867
  type Campaign as Campaign,
868
+ type CampaignsCursor as CampaignsCursor,
854
869
  type CampaignCreateParams as CampaignCreateParams,
870
+ type CampaignListParams as CampaignListParams,
855
871
  };
856
872
 
857
873
  export {
@@ -879,7 +895,11 @@ export declare namespace Surge {
879
895
  type PhoneNumberPurchaseParams as PhoneNumberPurchaseParams,
880
896
  };
881
897
 
882
- export { Recordings as Recordings, type RecordingGetFileResponse as RecordingGetFileResponse };
898
+ export {
899
+ Recordings as Recordings,
900
+ type RecordingDeleteResponse as RecordingDeleteResponse,
901
+ type RecordingGetFileResponse as RecordingGetFileResponse,
902
+ };
883
903
 
884
904
  export {
885
905
  Users as Users,
@@ -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
 
@@ -51,8 +52,34 @@ export class Campaigns extends APIResource {
51
52
  retrieve(id: string, options?: RequestOptions): APIPromise<Campaign> {
52
53
  return this._client.get(path`/campaigns/${id}`, options);
53
54
  }
55
+
56
+ /**
57
+ * List all campaigns for an account with cursor-based pagination.
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * // Automatically fetches more pages as needed.
62
+ * for await (const campaign of client.campaigns.list(
63
+ * 'acct_01j9a43avnfqzbjfch6pygv1td',
64
+ * )) {
65
+ * // ...
66
+ * }
67
+ * ```
68
+ */
69
+ list(
70
+ accountID: string,
71
+ query: CampaignListParams | null | undefined = {},
72
+ options?: RequestOptions,
73
+ ): PagePromise<CampaignsCursor, Campaign> {
74
+ return this._client.getAPIList(path`/accounts/${accountID}/campaigns`, Cursor<Campaign>, {
75
+ query,
76
+ ...options,
77
+ });
78
+ }
54
79
  }
55
80
 
81
+ export type CampaignsCursor = Cursor<Campaign>;
82
+
56
83
  /**
57
84
  * A campaign represents the context in which one or more of your phone numbers
58
85
  * communicates with your contacts. Consent and opt-outs are tied to the campaign.
@@ -318,6 +345,13 @@ export declare namespace CampaignCreateParams {
318
345
  }
319
346
  }
320
347
 
348
+ export interface CampaignListParams extends CursorParams {}
349
+
321
350
  export declare namespace Campaigns {
322
- export { type Campaign as Campaign, type CampaignCreateParams as CampaignCreateParams };
351
+ export {
352
+ type Campaign as Campaign,
353
+ type CampaignsCursor as CampaignsCursor,
354
+ type CampaignCreateParams as CampaignCreateParams,
355
+ type CampaignListParams as CampaignListParams,
356
+ };
323
357
  }
@@ -11,7 +11,13 @@ export {
11
11
  type AccountRetrieveStatusParams,
12
12
  } from './accounts';
13
13
  export { Blasts, type Blast, type BlastCreateParams } from './blasts';
14
- export { Campaigns, type Campaign, type CampaignCreateParams } from './campaigns';
14
+ export {
15
+ Campaigns,
16
+ type Campaign,
17
+ type CampaignCreateParams,
18
+ type CampaignListParams,
19
+ type CampaignsCursor,
20
+ } from './campaigns';
15
21
  export {
16
22
  Contacts,
17
23
  type Contact,
@@ -34,7 +40,7 @@ export {
34
40
  type PhoneNumberPurchaseParams,
35
41
  type PhoneNumbersCursor,
36
42
  } from './phone-numbers';
37
- export { Recordings, type RecordingGetFileResponse } from './recordings';
43
+ export { Recordings, type RecordingDeleteResponse, type RecordingGetFileResponse } from './recordings';
38
44
  export {
39
45
  Users,
40
46
  type User,
@@ -138,7 +138,7 @@ export namespace Message {
138
138
  /**
139
139
  * The type of attachment.
140
140
  */
141
- type?: string;
141
+ type?: 'file' | 'image' | 'link' | 'video';
142
142
 
143
143
  /**
144
144
  * The URL of the attachment.
@@ -1,12 +1,28 @@
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';
4
5
  import * as Shared from './shared';
5
6
  import { APIPromise } from '../core/api-promise';
6
7
  import { RequestOptions } from '../internal/request-options';
7
8
  import { path } from '../internal/utils/path';
8
9
 
9
10
  export class Recordings extends APIResource {
11
+ /**
12
+ * Deletes a recording. The recording file will be removed from storage
13
+ * asynchronously.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const recording = await client.recordings.delete(
18
+ * 'rec_01kfyc9dgdec1avkgs7tng8htg',
19
+ * );
20
+ * ```
21
+ */
22
+ delete(id: string, options?: RequestOptions): APIPromise<RecordingDeleteResponse> {
23
+ return this._client.delete(path`/recordings/${id}`, options);
24
+ }
25
+
10
26
  /**
11
27
  * Redirects to a signed URL where the recording audio file can be downloaded. URL
12
28
  * is short-lived, so redirect should be followed immediately.
@@ -23,6 +39,67 @@ export class Recordings extends APIResource {
23
39
  }
24
40
  }
25
41
 
42
+ /**
43
+ * A call recording
44
+ */
45
+ export interface RecordingDeleteResponse {
46
+ /**
47
+ * The unique identifier for the recording
48
+ */
49
+ id: string;
50
+
51
+ /**
52
+ * The call that produced this recording
53
+ */
54
+ call: RecordingDeleteResponse.Call;
55
+
56
+ /**
57
+ * The duration of the recording in seconds
58
+ */
59
+ duration: number;
60
+ }
61
+
62
+ export namespace RecordingDeleteResponse {
63
+ /**
64
+ * The call that produced this recording
65
+ */
66
+ export interface Call {
67
+ /**
68
+ * The unique identifier for the call
69
+ */
70
+ id: string;
71
+
72
+ /**
73
+ * A contact who has consented to receive messages
74
+ */
75
+ contact: ContactsAPI.Contact;
76
+
77
+ /**
78
+ * The duration of the call in seconds
79
+ */
80
+ duration: number;
81
+
82
+ /**
83
+ * When the call was initiated
84
+ */
85
+ initiated_at: string;
86
+
87
+ /**
88
+ * The status of the call
89
+ */
90
+ status:
91
+ | 'busy'
92
+ | 'canceled'
93
+ | 'completed'
94
+ | 'failed'
95
+ | 'in_progress'
96
+ | 'missed'
97
+ | 'no_answer'
98
+ | 'queued'
99
+ | 'ringing';
100
+ }
101
+ }
102
+
26
103
  /**
27
104
  * An error response
28
105
  */
@@ -34,5 +111,8 @@ export interface RecordingGetFileResponse {
34
111
  }
35
112
 
36
113
  export declare namespace Recordings {
37
- export { type RecordingGetFileResponse as RecordingGetFileResponse };
114
+ export {
115
+ type RecordingDeleteResponse as RecordingDeleteResponse,
116
+ type RecordingGetFileResponse as RecordingGetFileResponse,
117
+ };
38
118
  }
@@ -325,6 +325,11 @@ export namespace MessageDeliveredWebhookEvent {
325
325
  */
326
326
  delivered_at: string;
327
327
 
328
+ /**
329
+ * Set of key-value pairs that will be stored with the object.
330
+ */
331
+ metadata: { [key: string]: string };
332
+
328
333
  /**
329
334
  * Attachments included with the message
330
335
  */
@@ -429,6 +434,11 @@ export namespace MessageFailedWebhookEvent {
429
434
  */
430
435
  failure_reason: string;
431
436
 
437
+ /**
438
+ * Set of key-value pairs that will be stored with the object.
439
+ */
440
+ metadata: { [key: string]: string };
441
+
432
442
  /**
433
443
  * Attachments included with the message
434
444
  */
@@ -523,6 +533,11 @@ export namespace MessageReceivedWebhookEvent {
523
533
  */
524
534
  conversation: Data.Conversation;
525
535
 
536
+ /**
537
+ * Set of key-value pairs that will be stored with the object.
538
+ */
539
+ metadata: { [key: string]: string };
540
+
526
541
  /**
527
542
  * When the message was received
528
543
  */
@@ -622,6 +637,11 @@ export namespace MessageSentWebhookEvent {
622
637
  */
623
638
  conversation: Data.Conversation;
624
639
 
640
+ /**
641
+ * Set of key-value pairs that will be stored with the object.
642
+ */
643
+ metadata: { [key: string]: string };
644
+
625
645
  /**
626
646
  * When the message was sent
627
647
  */
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.36.0'; // x-release-please-version
1
+ export const VERSION = '0.37.0'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.36.0";
1
+ export declare const VERSION = "0.37.0";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.36.0";
1
+ export declare const VERSION = "0.37.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.36.0'; // x-release-please-version
4
+ exports.VERSION = '0.37.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.36.0'; // x-release-please-version
1
+ export const VERSION = '0.37.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map