@surgeapi/node 0.40.0 → 0.42.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 (74) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/client.d.mts +7 -4
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +7 -4
  5. package/client.d.ts.map +1 -1
  6. package/client.js +3 -0
  7. package/client.js.map +1 -1
  8. package/client.mjs +4 -1
  9. package/client.mjs.map +1 -1
  10. package/internal/utils/env.js +2 -2
  11. package/internal/utils/env.js.map +1 -1
  12. package/internal/utils/env.mjs +2 -2
  13. package/internal/utils/env.mjs.map +1 -1
  14. package/package.json +1 -1
  15. package/resources/attachments.d.mts +31 -0
  16. package/resources/attachments.d.mts.map +1 -0
  17. package/resources/attachments.d.ts +31 -0
  18. package/resources/attachments.d.ts.map +1 -0
  19. package/resources/attachments.js +24 -0
  20. package/resources/attachments.js.map +1 -0
  21. package/resources/attachments.mjs +20 -0
  22. package/resources/attachments.mjs.map +1 -0
  23. package/resources/audiences.d.mts +32 -1
  24. package/resources/audiences.d.mts.map +1 -1
  25. package/resources/audiences.d.ts +32 -1
  26. package/resources/audiences.d.ts.map +1 -1
  27. package/resources/audiences.js +14 -0
  28. package/resources/audiences.js.map +1 -1
  29. package/resources/audiences.mjs +14 -0
  30. package/resources/audiences.mjs.map +1 -1
  31. package/resources/campaigns.d.mts +146 -2
  32. package/resources/campaigns.d.mts.map +1 -1
  33. package/resources/campaigns.d.ts +146 -2
  34. package/resources/campaigns.d.ts.map +1 -1
  35. package/resources/campaigns.js +38 -0
  36. package/resources/campaigns.js.map +1 -1
  37. package/resources/campaigns.mjs +38 -0
  38. package/resources/campaigns.mjs.map +1 -1
  39. package/resources/index.d.mts +3 -2
  40. package/resources/index.d.mts.map +1 -1
  41. package/resources/index.d.ts +3 -2
  42. package/resources/index.d.ts.map +1 -1
  43. package/resources/index.js +3 -1
  44. package/resources/index.js.map +1 -1
  45. package/resources/index.mjs +2 -1
  46. package/resources/index.mjs.map +1 -1
  47. package/resources/messages.d.mts +4 -0
  48. package/resources/messages.d.mts.map +1 -1
  49. package/resources/messages.d.ts +4 -0
  50. package/resources/messages.d.ts.map +1 -1
  51. package/resources/phone-numbers.d.mts +9 -0
  52. package/resources/phone-numbers.d.mts.map +1 -1
  53. package/resources/phone-numbers.d.ts +9 -0
  54. package/resources/phone-numbers.d.ts.map +1 -1
  55. package/resources/webhooks.d.mts +11 -2
  56. package/resources/webhooks.d.mts.map +1 -1
  57. package/resources/webhooks.d.ts +11 -2
  58. package/resources/webhooks.d.ts.map +1 -1
  59. package/resources/webhooks.js.map +1 -1
  60. package/resources/webhooks.mjs.map +1 -1
  61. package/src/client.ts +16 -1
  62. package/src/internal/utils/env.ts +2 -2
  63. package/src/resources/attachments.ts +38 -0
  64. package/src/resources/audiences.ts +43 -0
  65. package/src/resources/campaigns.ts +173 -1
  66. package/src/resources/index.ts +9 -1
  67. package/src/resources/messages.ts +5 -0
  68. package/src/resources/phone-numbers.ts +11 -0
  69. package/src/resources/webhooks.ts +13 -2
  70. package/src/version.ts +1 -1
  71. package/version.d.mts +1 -1
  72. package/version.d.ts +1 -1
  73. package/version.js +1 -1
  74. package/version.mjs +1 -1
@@ -25,6 +25,8 @@ export class Campaigns extends APIResource {
25
25
  * 'Your car is ready to go. See your invoice here: https://l.fastauto.shop/s034ij',
26
26
  * ],
27
27
  * privacy_policy_url: 'https://fastauto.shop/sms-privacy',
28
+ * terms_and_conditions_url:
29
+ * 'https://fastauto.shop/terms-and-conditions',
28
30
  * use_cases: [
29
31
  * 'account_notification',
30
32
  * 'customer_care',
@@ -53,6 +55,43 @@ export class Campaigns extends APIResource {
53
55
  return this._client.get(path`/campaigns/${id}`, options);
54
56
  }
55
57
 
58
+ /**
59
+ * Updates a campaign that has not yet been approved. This can be used to fix
60
+ * issues flagged during review and resubmit the campaign. Returns an error if the
61
+ * campaign is currently in review, has already been approved, or has been
62
+ * deactivated.
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * const campaign = await client.campaigns.update(
67
+ * 'cpn_01k0qczvhbet4azgn5xm2ccfst',
68
+ * {
69
+ * consent_flow:
70
+ * 'When customers bring in their car for service, they will fill out this web form for intake: https://fastauto.shop/bp108c In it they can choose to opt in to text message notifications. If they choose to opt in, we will send them notifications to let them know if our mechanics find issues and once the car is ready to go, as well as links to invoices and to leave us feedback.',
71
+ * description:
72
+ * 'This phone number will send auto maintenance notifications to end users that have opted in. It will also be used for responding to customer inquiries and sending some marketing offers.',
73
+ * message_samples: [
74
+ * 'You are now opted in to receive repair notifications from DT Precision Auto. Frequency varies. Msg&data rates apply. Reply STOP to opt out.',
75
+ * "You're lucky that hundred shot of NOS didn't blow the welds on the intake!",
76
+ * 'Your car is ready to go. See your invoice here: https://l.fastauto.shop/s034ij',
77
+ * ],
78
+ * privacy_policy_url: 'https://fastauto.shop/sms-privacy',
79
+ * terms_and_conditions_url:
80
+ * 'https://fastauto.shop/terms-and-conditions',
81
+ * use_cases: [
82
+ * 'account_notification',
83
+ * 'customer_care',
84
+ * 'marketing',
85
+ * ],
86
+ * volume: 'high',
87
+ * },
88
+ * );
89
+ * ```
90
+ */
91
+ update(id: string, body: CampaignUpdateParams, options?: RequestOptions): APIPromise<Campaign> {
92
+ return this._client.patch(path`/campaigns/${id}`, { body, ...options });
93
+ }
94
+
56
95
  /**
57
96
  * List all campaigns for an account with cursor-based pagination.
58
97
  *
@@ -251,6 +290,14 @@ export declare namespace CampaignCreateParams {
251
290
  */
252
291
  privacy_policy_url: string;
253
292
 
293
+ /**
294
+ * The URL of the terms and conditions presented to end users when they opt in to
295
+ * messaging. These terms and conditions may be shared among all of a platform's
296
+ * customers if they're the terms that are presented to end users when they opt in
297
+ * to messaging.
298
+ */
299
+ terms_and_conditions_url: string;
300
+
254
301
  /**
255
302
  * A list containing 1-5 types of messages that will be sent with this campaign.
256
303
  *
@@ -327,6 +374,53 @@ export declare namespace CampaignCreateParams {
327
374
  * to disable automatic link shortening.
328
375
  */
329
376
  link_sample?: string;
377
+ }
378
+
379
+ export interface ExternalCampaignParams {
380
+ /**
381
+ * The Campaign Registry (TCR) ID for the externally registered campaign
382
+ */
383
+ tcr_id: string;
384
+ }
385
+ }
386
+
387
+ export type CampaignUpdateParams =
388
+ | CampaignUpdateParams.StandardCampaignParams
389
+ | CampaignUpdateParams.ExternalCampaignParams;
390
+
391
+ export declare namespace CampaignUpdateParams {
392
+ export interface StandardCampaignParams {
393
+ /**
394
+ * A string explaining the method through which end users will opt in to receive
395
+ * messages from the brand. Typically this should include URLs for opt-in forms or
396
+ * screenshots that might be helpful in explaining the flow to someone unfamiliar
397
+ * with the organization's purpose.
398
+ */
399
+ consent_flow: string;
400
+
401
+ /**
402
+ * An explanation of the organization's purpose and how it will be using text
403
+ * messaging to accomplish that purpose.
404
+ */
405
+ description: string;
406
+
407
+ /**
408
+ * An array of 2-5 strings with examples of the messages that will be sent from
409
+ * this campaign. Typically the first sample should be a compliance message like
410
+ * `You are now opted in to messages from {brand name}. Frequency varies. Msg&data rates apply. Reply STOP to opt out.`
411
+ * These samples don't necessarily need to be the only templates that will be used
412
+ * for the campaign, but they should reflect the purpose of the messages that will
413
+ * be sent. Any variable content can be reflected by wrapping it in square brackets
414
+ * like `[customer name]`.
415
+ */
416
+ message_samples: Array<string>;
417
+
418
+ /**
419
+ * The URL of the privacy policy for the brand in question. This may be a shared
420
+ * privacy policy if it's the policy that is displayed to end users when they opt
421
+ * in to messaging.
422
+ */
423
+ privacy_policy_url: string;
330
424
 
331
425
  /**
332
426
  * The URL of the terms and conditions presented to end users when they opt in to
@@ -334,7 +428,84 @@ export declare namespace CampaignCreateParams {
334
428
  * customers if they're the terms that are presented to end users when they opt in
335
429
  * to messaging.
336
430
  */
337
- terms_and_conditions_url?: string;
431
+ terms_and_conditions_url: string;
432
+
433
+ /**
434
+ * A list containing 1-5 types of messages that will be sent with this campaign.
435
+ *
436
+ * The following use cases are typically available to all brands:
437
+ *
438
+ * - `account_notification` - For sending reminders, alerts, and general
439
+ * account-related notifications like booking confirmations or appointment
440
+ * reminders.
441
+ * - `customer_care` - For account support, troubleshooting, and general customer
442
+ * service communication.
443
+ * - `delivery_notification` - For notifying customers about the status of product
444
+ * or service deliveries.
445
+ * - `fraud_alert` - For warning customers about suspicious or potentially
446
+ * fraudulent activity.
447
+ * - `higher_education` - For messaging related to colleges, universities, and
448
+ * school districts outside of K–12.
449
+ * - `marketing` - For promotional or advertising messages intended to market
450
+ * products or services.
451
+ * - `polling_voting` - For conducting surveys, polls, or voting-related messaging.
452
+ * - `public_service_announcement` - For raising awareness about social issues or
453
+ * important public information.
454
+ * - `security_alert` - For alerts related to potential security breaches or
455
+ * compromised systems requiring user action.
456
+ * - `two_factor_authentication` - For sending one-time passwords or verification
457
+ * codes for login or password reset.
458
+ *
459
+ * For access to special use cases not shown here, reach out to support@surge.app.
460
+ */
461
+ use_cases: Array<
462
+ | 'account_notification'
463
+ | 'customer_care'
464
+ | 'delivery_notification'
465
+ | 'fraud_alert'
466
+ | 'higher_education'
467
+ | 'marketing'
468
+ | 'polling_voting'
469
+ | 'public_service_announcement'
470
+ | 'security_alert'
471
+ | 'two_factor_authentication'
472
+ >;
473
+
474
+ /**
475
+ * This will be one of the following:
476
+ *
477
+ * - `low` - The campaign will be allowed to send up to 2000 SMS segments to
478
+ * T-Mobile customers each day. In this case your platform will be charged for
479
+ * the setup fee for a low volume number upon receipt of the API request.
480
+ * - `high` - The campaign will be allowed to send up to 200k SMS segments to
481
+ * T-Mobile customers each day, depending on the trust score assigned by The
482
+ * Campaign Registry. Your platform will be charged for the setup fee for a high
483
+ * volume number upon receipt of the API request, and phone numbers will be
484
+ * charged as high volume numbers going forward.
485
+ */
486
+ volume: 'high' | 'low';
487
+
488
+ /**
489
+ * A list of properties that this campaign should include. These properties can be
490
+ * any of the following values:
491
+ *
492
+ * - `links` - whether the campaign might send links in messages
493
+ * - `phone_numbers` - whether the campaign might send phone numbers in messages
494
+ * - `age_gated` - whether the campaign contains age gated content (controlled
495
+ * substances or adult content)
496
+ * - `direct_lending` - whether the campaign contains content related to direct
497
+ * lending or other loan arrangements
498
+ */
499
+ includes?: Array<'links' | 'phone_numbers' | 'age_gated' | 'direct_lending'>;
500
+
501
+ /**
502
+ * A sample link that might be sent by this campaign. If links from other domains
503
+ * are sent through this campaign, they are much more likely to be filtered by the
504
+ * carriers. If link shortening is enabled for the account, the link shortener URL
505
+ * will be used instead of what is provided. Reach out to support if you would like
506
+ * to disable automatic link shortening.
507
+ */
508
+ link_sample?: string;
338
509
  }
339
510
 
340
511
  export interface ExternalCampaignParams {
@@ -352,6 +523,7 @@ export declare namespace Campaigns {
352
523
  type Campaign as Campaign,
353
524
  type CampaignsCursor as CampaignsCursor,
354
525
  type CampaignCreateParams as CampaignCreateParams,
526
+ type CampaignUpdateParams as CampaignUpdateParams,
355
527
  type CampaignListParams as CampaignListParams,
356
528
  };
357
529
  }
@@ -10,12 +10,20 @@ export {
10
10
  type AccountUpdateParams,
11
11
  type AccountRetrieveStatusParams,
12
12
  } from './accounts';
13
- export { Audiences, type AudienceAddContactParams, type AudienceListContactsParams } from './audiences';
13
+ export { Attachments, type AttachmentGetFileResponse } from './attachments';
14
+ export {
15
+ Audiences,
16
+ type AudienceCreateResponse,
17
+ type AudienceCreateParams,
18
+ type AudienceAddContactParams,
19
+ type AudienceListContactsParams,
20
+ } from './audiences';
14
21
  export { Blasts, type Blast, type BlastCreateParams } from './blasts';
15
22
  export {
16
23
  Campaigns,
17
24
  type Campaign,
18
25
  type CampaignCreateParams,
26
+ type CampaignUpdateParams,
19
27
  type CampaignListParams,
20
28
  type CampaignsCursor,
21
29
  } from './campaigns';
@@ -176,6 +176,11 @@ export namespace Message {
176
176
  */
177
177
  id: string;
178
178
 
179
+ /**
180
+ * A human-readable name for the phone number
181
+ */
182
+ name: string | null;
183
+
179
184
  /**
180
185
  * The canonical format of the phone number.
181
186
  */
@@ -67,6 +67,11 @@ export interface PhoneNumber {
67
67
  */
68
68
  campaign_id: string | null;
69
69
 
70
+ /**
71
+ * A human-readable name for the phone number
72
+ */
73
+ name: string | null;
74
+
70
75
  /**
71
76
  * The phone number in E.164 format
72
77
  */
@@ -99,6 +104,12 @@ export interface PhoneNumberPurchaseParams {
99
104
  */
100
105
  longitude?: number;
101
106
 
107
+ /**
108
+ * A human-readable name for the phone number. If not provided, defaults to the
109
+ * formatted phone number.
110
+ */
111
+ name?: string;
112
+
102
113
  /**
103
114
  * Whether the phone number is local or toll-free. Can be omitted if area_code or
104
115
  * latitude/longitude are provided.
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { APIResource } from '../core/resource';
4
4
  import * as ContactsAPI from './contacts';
5
+ import * as MessagesAPI from './messages';
5
6
  import * as PhoneNumbersAPI from './phone-numbers';
6
7
  import { Webhook } from 'standardwebhooks';
7
8
 
@@ -267,9 +268,14 @@ export namespace LinkFollowedWebhookEvent {
267
268
  id: string;
268
269
 
269
270
  /**
270
- * The unique identifier for the message that contained the link
271
+ * A Message is a communication sent to a Contact.
271
272
  */
272
- message_id: string;
273
+ message: MessagesAPI.Message | null;
274
+
275
+ /**
276
+ * @deprecated Use `message.id` instead.
277
+ */
278
+ message_id: string | null;
273
279
 
274
280
  /**
275
281
  * The original URL that was shortened
@@ -737,6 +743,11 @@ export namespace PhoneNumberAttachedToCampaignWebhookEvent {
737
743
  */
738
744
  campaign_id: string;
739
745
 
746
+ /**
747
+ * A human-readable name for the phone number
748
+ */
749
+ name: string | null;
750
+
740
751
  /**
741
752
  * The phone number in E.164 format
742
753
  */
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.40.0'; // x-release-please-version
1
+ export const VERSION = '0.42.0'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.40.0";
1
+ export declare const VERSION = "0.42.0";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.40.0";
1
+ export declare const VERSION = "0.42.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.40.0'; // x-release-please-version
4
+ exports.VERSION = '0.42.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.40.0'; // x-release-please-version
1
+ export const VERSION = '0.42.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map