@trycourier/courier 7.11.0 → 7.19.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 (179) hide show
  1. package/CHANGELOG.md +114 -0
  2. package/README.md +1 -0
  3. package/client.d.mts +10 -4
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +10 -4
  6. package/client.d.ts.map +1 -1
  7. package/client.js +15 -1
  8. package/client.js.map +1 -1
  9. package/client.mjs +15 -1
  10. package/client.mjs.map +1 -1
  11. package/package.json +1 -1
  12. package/resources/audiences.d.mts +5 -2
  13. package/resources/audiences.d.mts.map +1 -1
  14. package/resources/audiences.d.ts +5 -2
  15. package/resources/audiences.d.ts.map +1 -1
  16. package/resources/brands.d.mts +35 -2
  17. package/resources/brands.d.mts.map +1 -1
  18. package/resources/brands.d.ts +35 -2
  19. package/resources/brands.d.ts.map +1 -1
  20. package/resources/brands.js +34 -1
  21. package/resources/brands.js.map +1 -1
  22. package/resources/brands.mjs +34 -1
  23. package/resources/brands.mjs.map +1 -1
  24. package/resources/digests/digests.d.mts +94 -0
  25. package/resources/digests/digests.d.mts.map +1 -0
  26. package/resources/digests/digests.d.ts +94 -0
  27. package/resources/digests/digests.d.ts.map +1 -0
  28. package/resources/digests/digests.js +17 -0
  29. package/resources/digests/digests.js.map +1 -0
  30. package/resources/digests/digests.mjs +12 -0
  31. package/resources/digests/digests.mjs.map +1 -0
  32. package/resources/digests/index.d.mts +3 -0
  33. package/resources/digests/index.d.mts.map +1 -0
  34. package/resources/digests/index.d.ts +3 -0
  35. package/resources/digests/index.d.ts.map +1 -0
  36. package/resources/digests/index.js +9 -0
  37. package/resources/digests/index.js.map +1 -0
  38. package/resources/digests/index.mjs +4 -0
  39. package/resources/digests/index.mjs.map +1 -0
  40. package/resources/digests/schedules.d.mts +32 -0
  41. package/resources/digests/schedules.d.mts.map +1 -0
  42. package/resources/digests/schedules.d.ts +32 -0
  43. package/resources/digests/schedules.d.ts.map +1 -0
  44. package/resources/digests/schedules.js +29 -0
  45. package/resources/digests/schedules.js.map +1 -0
  46. package/resources/digests/schedules.mjs +25 -0
  47. package/resources/digests/schedules.mjs.map +1 -0
  48. package/resources/digests.d.mts +2 -0
  49. package/resources/digests.d.mts.map +1 -0
  50. package/resources/digests.d.ts +2 -0
  51. package/resources/digests.d.ts.map +1 -0
  52. package/resources/digests.js +6 -0
  53. package/resources/digests.js.map +1 -0
  54. package/resources/digests.mjs +3 -0
  55. package/resources/digests.mjs.map +1 -0
  56. package/resources/index.d.mts +4 -2
  57. package/resources/index.d.mts.map +1 -1
  58. package/resources/index.d.ts +4 -2
  59. package/resources/index.d.ts.map +1 -1
  60. package/resources/index.js +5 -1
  61. package/resources/index.js.map +1 -1
  62. package/resources/index.mjs +2 -0
  63. package/resources/index.mjs.map +1 -1
  64. package/resources/journeys/index.d.mts +2 -2
  65. package/resources/journeys/index.d.mts.map +1 -1
  66. package/resources/journeys/index.d.ts +2 -2
  67. package/resources/journeys/index.d.ts.map +1 -1
  68. package/resources/journeys/index.js.map +1 -1
  69. package/resources/journeys/index.mjs.map +1 -1
  70. package/resources/journeys/journeys.d.mts +198 -7
  71. package/resources/journeys/journeys.d.mts.map +1 -1
  72. package/resources/journeys/journeys.d.ts +198 -7
  73. package/resources/journeys/journeys.d.ts.map +1 -1
  74. package/resources/journeys/journeys.js +18 -0
  75. package/resources/journeys/journeys.js.map +1 -1
  76. package/resources/journeys/journeys.mjs +18 -0
  77. package/resources/journeys/journeys.mjs.map +1 -1
  78. package/resources/journeys/templates.d.mts +120 -1
  79. package/resources/journeys/templates.d.mts.map +1 -1
  80. package/resources/journeys/templates.d.ts +120 -1
  81. package/resources/journeys/templates.d.ts.map +1 -1
  82. package/resources/journeys/templates.js +71 -0
  83. package/resources/journeys/templates.js.map +1 -1
  84. package/resources/journeys/templates.mjs +71 -0
  85. package/resources/journeys/templates.mjs.map +1 -1
  86. package/resources/messages.d.mts +16 -1
  87. package/resources/messages.d.mts.map +1 -1
  88. package/resources/messages.d.ts +16 -1
  89. package/resources/messages.d.ts.map +1 -1
  90. package/resources/messages.js +10 -0
  91. package/resources/messages.js.map +1 -1
  92. package/resources/messages.mjs +10 -0
  93. package/resources/messages.mjs.map +1 -1
  94. package/resources/notifications/checks.d.mts +3 -3
  95. package/resources/notifications/checks.d.ts +3 -3
  96. package/resources/notifications/checks.js +3 -3
  97. package/resources/notifications/checks.mjs +3 -3
  98. package/resources/shared.d.mts +6 -0
  99. package/resources/shared.d.mts.map +1 -1
  100. package/resources/shared.d.ts +6 -0
  101. package/resources/shared.d.ts.map +1 -1
  102. package/resources/users/index.d.mts +1 -1
  103. package/resources/users/index.d.mts.map +1 -1
  104. package/resources/users/index.d.ts +1 -1
  105. package/resources/users/index.d.ts.map +1 -1
  106. package/resources/users/index.js.map +1 -1
  107. package/resources/users/index.mjs.map +1 -1
  108. package/resources/users/preferences.d.mts +211 -1
  109. package/resources/users/preferences.d.mts.map +1 -1
  110. package/resources/users/preferences.d.ts +211 -1
  111. package/resources/users/preferences.d.ts.map +1 -1
  112. package/resources/users/preferences.js +105 -0
  113. package/resources/users/preferences.js.map +1 -1
  114. package/resources/users/preferences.mjs +105 -0
  115. package/resources/users/preferences.mjs.map +1 -1
  116. package/resources/users/users.d.mts +2 -2
  117. package/resources/users/users.d.mts.map +1 -1
  118. package/resources/users/users.d.ts +2 -2
  119. package/resources/users/users.d.ts.map +1 -1
  120. package/resources/users/users.js.map +1 -1
  121. package/resources/users/users.mjs.map +1 -1
  122. package/resources/workspace-preferences/index.d.mts +3 -0
  123. package/resources/workspace-preferences/index.d.mts.map +1 -0
  124. package/resources/workspace-preferences/index.d.ts +3 -0
  125. package/resources/workspace-preferences/index.d.ts.map +1 -0
  126. package/resources/workspace-preferences/index.js +9 -0
  127. package/resources/workspace-preferences/index.js.map +1 -0
  128. package/resources/workspace-preferences/index.mjs +4 -0
  129. package/resources/workspace-preferences/index.mjs.map +1 -0
  130. package/resources/workspace-preferences/topics.d.mts +168 -0
  131. package/resources/workspace-preferences/topics.d.mts.map +1 -0
  132. package/resources/workspace-preferences/topics.d.ts +168 -0
  133. package/resources/workspace-preferences/topics.d.ts.map +1 -0
  134. package/resources/workspace-preferences/topics.js +103 -0
  135. package/resources/workspace-preferences/topics.js.map +1 -0
  136. package/resources/workspace-preferences/topics.mjs +99 -0
  137. package/resources/workspace-preferences/topics.mjs.map +1 -0
  138. package/resources/workspace-preferences/workspace-preferences.d.mts +410 -0
  139. package/resources/workspace-preferences/workspace-preferences.d.mts.map +1 -0
  140. package/resources/workspace-preferences/workspace-preferences.d.ts +410 -0
  141. package/resources/workspace-preferences/workspace-preferences.d.ts.map +1 -0
  142. package/resources/workspace-preferences/workspace-preferences.js +104 -0
  143. package/resources/workspace-preferences/workspace-preferences.js.map +1 -0
  144. package/resources/workspace-preferences/workspace-preferences.mjs +99 -0
  145. package/resources/workspace-preferences/workspace-preferences.mjs.map +1 -0
  146. package/resources/workspace-preferences.d.mts +2 -0
  147. package/resources/workspace-preferences.d.mts.map +1 -0
  148. package/resources/workspace-preferences.d.ts +2 -0
  149. package/resources/workspace-preferences.d.ts.map +1 -0
  150. package/resources/workspace-preferences.js +6 -0
  151. package/resources/workspace-preferences.js.map +1 -0
  152. package/resources/workspace-preferences.mjs +3 -0
  153. package/resources/workspace-preferences.mjs.map +1 -0
  154. package/src/client.ts +71 -1
  155. package/src/resources/audiences.ts +5 -2
  156. package/src/resources/brands.ts +36 -3
  157. package/src/resources/digests/digests.ts +120 -0
  158. package/src/resources/digests/index.ts +9 -0
  159. package/src/resources/digests/schedules.ts +51 -0
  160. package/src/resources/digests.ts +3 -0
  161. package/src/resources/index.ts +28 -0
  162. package/src/resources/journeys/index.ts +8 -0
  163. package/src/resources/journeys/journeys.ts +246 -4
  164. package/src/resources/journeys/templates.ts +168 -0
  165. package/src/resources/messages.ts +20 -0
  166. package/src/resources/notifications/checks.ts +3 -3
  167. package/src/resources/shared.ts +7 -0
  168. package/src/resources/users/index.ts +6 -0
  169. package/src/resources/users/preferences.ts +269 -0
  170. package/src/resources/users/users.ts +12 -0
  171. package/src/resources/workspace-preferences/index.ts +25 -0
  172. package/src/resources/workspace-preferences/topics.ts +229 -0
  173. package/src/resources/workspace-preferences/workspace-preferences.ts +534 -0
  174. package/src/resources/workspace-preferences.ts +3 -0
  175. package/src/version.ts +1 -1
  176. package/version.d.mts +1 -1
  177. package/version.d.ts +1 -1
  178. package/version.js +1 -1
  179. package/version.mjs +1 -1
@@ -3,6 +3,7 @@
3
3
  import { APIResource } from '../../core/resource';
4
4
  import * as Shared from '../shared';
5
5
  import { APIPromise } from '../../core/api-promise';
6
+ import { buildHeaders } from '../../internal/headers';
6
7
  import { RequestOptions } from '../../internal/request-options';
7
8
  import { path } from '../../internal/utils/path';
8
9
 
@@ -25,6 +26,125 @@ export class Preferences extends APIResource {
25
26
  return this._client.get(path`/users/${userID}/preferences`, { query, ...options });
26
27
  }
27
28
 
29
+ /**
30
+ * Replace a user's complete set of preference overrides in a single request. The
31
+ * topics in the request body become the recipient's entire set of overrides:
32
+ * listed topics are created or updated, and every existing override that is not
33
+ * included in the body is reset to its topic default. Submitting an empty `topics`
34
+ * array is a valid clear-all that resets every existing override.
35
+ *
36
+ * This operation is validation-atomic (all-or-nothing): structural validation
37
+ * fails fast with a single `400`, and if any topic is semantically invalid (an
38
+ * unknown topic, a `REQUIRED` topic that cannot be opted out, or a custom routing
39
+ * request that is not available on the workspace's plan) the request returns a
40
+ * single `400` aggregating every failure in `errors` and writes nothing. On
41
+ * success it returns `200` with `items` (the complete resulting override set) and
42
+ * `deleted` (the ids of the overrides that were reset to default).
43
+ *
44
+ * Every `topic_id` in the response — in `items`, `deleted`, and any `errors` — is
45
+ * returned in Courier's canonical topic id form, regardless of the form supplied
46
+ * in the request.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * const response = await client.users.preferences.bulkReplace(
51
+ * 'user_id',
52
+ * {
53
+ * topics: [
54
+ * {
55
+ * topic_id: '74Q4QGFBEX481DP6JRPMV751H4XT',
56
+ * status: 'OPTED_IN',
57
+ * has_custom_routing: true,
58
+ * custom_routing: ['inbox', 'email'],
59
+ * },
60
+ * ],
61
+ * },
62
+ * );
63
+ * ```
64
+ */
65
+ bulkReplace(
66
+ userID: string,
67
+ params: PreferenceBulkReplaceParams,
68
+ options?: RequestOptions,
69
+ ): APIPromise<PreferenceBulkReplaceResponse> {
70
+ const { tenant_id, ...body } = params;
71
+ return this._client.put(path`/users/${userID}/preferences`, { query: { tenant_id }, body, ...options });
72
+ }
73
+
74
+ /**
75
+ * Additively create or update a user's preferences for one or more subscription
76
+ * topics in a single request. Only the topics included in the request body are
77
+ * created or updated; any existing overrides for topics not listed are left
78
+ * untouched.
79
+ *
80
+ * Structural validation of the request body fails fast with a single `400`. Beyond
81
+ * that, each topic is processed independently (partial-success, not
82
+ * all-or-nothing): valid topics are written and returned in `items`, while topics
83
+ * that cannot be applied are collected in `errors` with a per-topic `reason` (for
84
+ * example an unknown topic, a `REQUIRED` topic that cannot be opted out, a custom
85
+ * routing request that is not available on the workspace's plan, or a write
86
+ * failure). The request therefore returns `200` with both lists whenever the body
87
+ * is structurally valid.
88
+ *
89
+ * Every `topic_id` in the response — in both `items` and `errors` — is returned in
90
+ * Courier's canonical topic id form, regardless of the form supplied in the
91
+ * request.
92
+ *
93
+ * @example
94
+ * ```ts
95
+ * const response = await client.users.preferences.bulkUpdate(
96
+ * 'user_id',
97
+ * {
98
+ * topics: [
99
+ * {
100
+ * topic_id: '74Q4QGFBEX481DP6JRPMV751H4XT',
101
+ * status: 'OPTED_IN',
102
+ * has_custom_routing: true,
103
+ * custom_routing: ['inbox', 'email'],
104
+ * },
105
+ * {
106
+ * topic_id: '5Q4QGFBEX481DP6JRPMV751H4YU',
107
+ * status: 'OPTED_OUT',
108
+ * },
109
+ * ],
110
+ * },
111
+ * );
112
+ * ```
113
+ */
114
+ bulkUpdate(
115
+ userID: string,
116
+ params: PreferenceBulkUpdateParams,
117
+ options?: RequestOptions,
118
+ ): APIPromise<PreferenceBulkUpdateResponse> {
119
+ const { tenant_id, ...body } = params;
120
+ return this._client.post(path`/users/${userID}/preferences`, { query: { tenant_id }, body, ...options });
121
+ }
122
+
123
+ /**
124
+ * Remove a user's preferences for a specific subscription topic, resetting the
125
+ * topic to its effective default. This operation is idempotent: deleting a
126
+ * preference that does not exist succeeds with no error.
127
+ *
128
+ * @example
129
+ * ```ts
130
+ * await client.users.preferences.deleteTopic('topic_id', {
131
+ * user_id: 'user_id',
132
+ * });
133
+ * ```
134
+ */
135
+ deleteTopic(
136
+ topicID: string,
137
+ params: PreferenceDeleteTopicParams,
138
+ options?: RequestOptions,
139
+ ): APIPromise<void> {
140
+ const { user_id, tenant_id } = params;
141
+ return this._client.delete(path`/users/${user_id}/preferences/${topicID}`, {
142
+ query: { tenant_id },
143
+ ...options,
144
+ headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
145
+ });
146
+ }
147
+
28
148
  /**
29
149
  * Fetch user preferences for a specific subscription topic.
30
150
  *
@@ -78,6 +198,23 @@ export class Preferences extends APIResource {
78
198
  }
79
199
  }
80
200
 
201
+ /**
202
+ * A single topic override echoed in a bulk preference response.
203
+ */
204
+ export interface BulkPreferenceTopic {
205
+ custom_routing: Array<Shared.ChannelClassification>;
206
+
207
+ has_custom_routing: boolean;
208
+
209
+ /**
210
+ * The applied subscription status. Echoes the requested value, so it is always
211
+ * OPTED_IN or OPTED_OUT.
212
+ */
213
+ status: 'OPTED_IN' | 'OPTED_OUT';
214
+
215
+ topic_id: string;
216
+ }
217
+
81
218
  export interface TopicPreference {
82
219
  default_status: Shared.PreferenceStatus;
83
220
 
@@ -107,6 +244,44 @@ export interface PreferenceRetrieveResponse {
107
244
  paging: Shared.Paging;
108
245
  }
109
246
 
247
+ export interface PreferenceBulkReplaceResponse {
248
+ /**
249
+ * The ids of the overrides that were reset to their topic default.
250
+ */
251
+ deleted: Array<string>;
252
+
253
+ /**
254
+ * The complete resulting set of topic overrides for the user.
255
+ */
256
+ items: Array<BulkPreferenceTopic>;
257
+ }
258
+
259
+ export interface PreferenceBulkUpdateResponse {
260
+ /**
261
+ * The topics that could not be applied, each with a reason.
262
+ */
263
+ errors: Array<PreferenceBulkUpdateResponse.Error>;
264
+
265
+ /**
266
+ * The topics that were successfully created or updated.
267
+ */
268
+ items: Array<BulkPreferenceTopic>;
269
+ }
270
+
271
+ export namespace PreferenceBulkUpdateResponse {
272
+ /**
273
+ * A single topic that could not be applied in a bulk preference request.
274
+ */
275
+ export interface Error {
276
+ /**
277
+ * A human-readable explanation of why the topic could not be applied.
278
+ */
279
+ reason: string;
280
+
281
+ topic_id: string;
282
+ }
283
+ }
284
+
110
285
  export interface PreferenceRetrieveTopicResponse {
111
286
  topic: TopicPreference;
112
287
  }
@@ -122,6 +297,94 @@ export interface PreferenceRetrieveParams {
122
297
  tenant_id?: string | null;
123
298
  }
124
299
 
300
+ export interface PreferenceBulkReplaceParams {
301
+ /**
302
+ * Body param: The complete set of topic overrides for the user. Up to 50 topics
303
+ * may be provided. Any existing override not listed here is reset to its topic
304
+ * default; an empty array resets every existing override.
305
+ */
306
+ topics: Array<PreferenceBulkReplaceParams.Topic>;
307
+
308
+ /**
309
+ * Query param: Replace the preferences of a user for this specific tenant context.
310
+ */
311
+ tenant_id?: string | null;
312
+ }
313
+
314
+ export namespace PreferenceBulkReplaceParams {
315
+ export interface Topic {
316
+ /**
317
+ * The subscription status to apply for this topic.
318
+ */
319
+ status: 'OPTED_IN' | 'OPTED_OUT';
320
+
321
+ /**
322
+ * A unique identifier associated with a subscription topic.
323
+ */
324
+ topic_id: string;
325
+
326
+ /**
327
+ * The channels a user has chosen to receive notifications through for this topic.
328
+ */
329
+ custom_routing?: Array<Shared.ChannelClassification>;
330
+
331
+ /**
332
+ * Whether the recipient has chosen specific delivery channels for this topic.
333
+ */
334
+ has_custom_routing?: boolean;
335
+ }
336
+ }
337
+
338
+ export interface PreferenceBulkUpdateParams {
339
+ /**
340
+ * Body param: The topics to create or update. Between 1 and 50 topics may be
341
+ * provided in a single request.
342
+ */
343
+ topics: Array<PreferenceBulkUpdateParams.Topic>;
344
+
345
+ /**
346
+ * Query param: Update the preferences of a user for this specific tenant context.
347
+ */
348
+ tenant_id?: string | null;
349
+ }
350
+
351
+ export namespace PreferenceBulkUpdateParams {
352
+ export interface Topic {
353
+ /**
354
+ * The subscription status to apply for this topic.
355
+ */
356
+ status: 'OPTED_IN' | 'OPTED_OUT';
357
+
358
+ /**
359
+ * A unique identifier associated with a subscription topic.
360
+ */
361
+ topic_id: string;
362
+
363
+ /**
364
+ * The channels a user has chosen to receive notifications through for this topic.
365
+ */
366
+ custom_routing?: Array<Shared.ChannelClassification>;
367
+
368
+ /**
369
+ * Whether the recipient has chosen specific delivery channels for this topic.
370
+ */
371
+ has_custom_routing?: boolean;
372
+ }
373
+ }
374
+
375
+ export interface PreferenceDeleteTopicParams {
376
+ /**
377
+ * Path param: A unique identifier associated with the user whose preferences you
378
+ * wish to delete.
379
+ */
380
+ user_id: string;
381
+
382
+ /**
383
+ * Query param: Delete the preferences of a user for this specific tenant context.
384
+ */
385
+ tenant_id?: string | null;
386
+ }
387
+
125
388
  export interface PreferenceRetrieveTopicParams {
126
389
  /**
127
390
  * Path param: A unique identifier associated with the user whose preferences you
@@ -168,11 +431,17 @@ export namespace PreferenceUpdateOrCreateTopicParams {
168
431
 
169
432
  export declare namespace Preferences {
170
433
  export {
434
+ type BulkPreferenceTopic as BulkPreferenceTopic,
171
435
  type TopicPreference as TopicPreference,
172
436
  type PreferenceRetrieveResponse as PreferenceRetrieveResponse,
437
+ type PreferenceBulkReplaceResponse as PreferenceBulkReplaceResponse,
438
+ type PreferenceBulkUpdateResponse as PreferenceBulkUpdateResponse,
173
439
  type PreferenceRetrieveTopicResponse as PreferenceRetrieveTopicResponse,
174
440
  type PreferenceUpdateOrCreateTopicResponse as PreferenceUpdateOrCreateTopicResponse,
175
441
  type PreferenceRetrieveParams as PreferenceRetrieveParams,
442
+ type PreferenceBulkReplaceParams as PreferenceBulkReplaceParams,
443
+ type PreferenceBulkUpdateParams as PreferenceBulkUpdateParams,
444
+ type PreferenceDeleteTopicParams as PreferenceDeleteTopicParams,
176
445
  type PreferenceRetrieveTopicParams as PreferenceRetrieveTopicParams,
177
446
  type PreferenceUpdateOrCreateTopicParams as PreferenceUpdateOrCreateTopicParams,
178
447
  };
@@ -3,6 +3,12 @@
3
3
  import { APIResource } from '../../core/resource';
4
4
  import * as PreferencesAPI from './preferences';
5
5
  import {
6
+ BulkPreferenceTopic,
7
+ PreferenceBulkReplaceParams,
8
+ PreferenceBulkReplaceResponse,
9
+ PreferenceBulkUpdateParams,
10
+ PreferenceBulkUpdateResponse,
11
+ PreferenceDeleteTopicParams,
6
12
  PreferenceRetrieveParams,
7
13
  PreferenceRetrieveResponse,
8
14
  PreferenceRetrieveTopicParams,
@@ -46,11 +52,17 @@ Users.Tokens = Tokens;
46
52
  export declare namespace Users {
47
53
  export {
48
54
  Preferences as Preferences,
55
+ type BulkPreferenceTopic as BulkPreferenceTopic,
49
56
  type TopicPreference as TopicPreference,
50
57
  type PreferenceRetrieveResponse as PreferenceRetrieveResponse,
58
+ type PreferenceBulkReplaceResponse as PreferenceBulkReplaceResponse,
59
+ type PreferenceBulkUpdateResponse as PreferenceBulkUpdateResponse,
51
60
  type PreferenceRetrieveTopicResponse as PreferenceRetrieveTopicResponse,
52
61
  type PreferenceUpdateOrCreateTopicResponse as PreferenceUpdateOrCreateTopicResponse,
53
62
  type PreferenceRetrieveParams as PreferenceRetrieveParams,
63
+ type PreferenceBulkReplaceParams as PreferenceBulkReplaceParams,
64
+ type PreferenceBulkUpdateParams as PreferenceBulkUpdateParams,
65
+ type PreferenceDeleteTopicParams as PreferenceDeleteTopicParams,
54
66
  type PreferenceRetrieveTopicParams as PreferenceRetrieveTopicParams,
55
67
  type PreferenceUpdateOrCreateTopicParams as PreferenceUpdateOrCreateTopicParams,
56
68
  };
@@ -0,0 +1,25 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ export {
4
+ Topics,
5
+ type TopicCreateParams,
6
+ type TopicRetrieveParams,
7
+ type TopicArchiveParams,
8
+ type TopicReplaceParams,
9
+ } from './topics';
10
+ export {
11
+ WorkspacePreferences,
12
+ type PublishPreferencesRequest,
13
+ type PublishPreferencesResponse,
14
+ type WorkspacePreferenceCreateRequest,
15
+ type WorkspacePreferenceGetResponse,
16
+ type WorkspacePreferenceListResponse,
17
+ type WorkspacePreferenceReplaceRequest,
18
+ type WorkspacePreferenceTopicCreateRequest,
19
+ type WorkspacePreferenceTopicGetResponse,
20
+ type WorkspacePreferenceTopicListResponse,
21
+ type WorkspacePreferenceTopicReplaceRequest,
22
+ type WorkspacePreferenceCreateParams,
23
+ type WorkspacePreferencePublishParams,
24
+ type WorkspacePreferenceReplaceParams,
25
+ } from './workspace-preferences';
@@ -0,0 +1,229 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../core/resource';
4
+ import * as Shared from '../shared';
5
+ import * as WorkspacePreferencesAPI from './workspace-preferences';
6
+ import { APIPromise } from '../../core/api-promise';
7
+ import { buildHeaders } from '../../internal/headers';
8
+ import { RequestOptions } from '../../internal/request-options';
9
+ import { path } from '../../internal/utils/path';
10
+
11
+ export class Topics extends APIResource {
12
+ /**
13
+ * Create a subscription preference topic inside a workspace preference. Fails with
14
+ * 404 if the workspace preference does not exist. The topic id is generated and
15
+ * returned.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * const workspacePreferenceTopicGetResponse =
20
+ * await client.workspacePreferences.topics.create(
21
+ * 'section_id',
22
+ * { default_status: 'OPTED_OUT', name: 'Marketing' },
23
+ * );
24
+ * ```
25
+ */
26
+ create(
27
+ sectionID: string,
28
+ body: TopicCreateParams,
29
+ options?: RequestOptions,
30
+ ): APIPromise<WorkspacePreferencesAPI.WorkspacePreferenceTopicGetResponse> {
31
+ return this._client.post(path`/preferences/sections/${sectionID}/topics`, { body, ...options });
32
+ }
33
+
34
+ /**
35
+ * Retrieve a topic within a workspace preference. Returns 404 if the workspace
36
+ * preference does not exist, the topic does not exist, or the topic belongs to a
37
+ * different workspace preference.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * const workspacePreferenceTopicGetResponse =
42
+ * await client.workspacePreferences.topics.retrieve(
43
+ * 'topic_id',
44
+ * { section_id: 'section_id' },
45
+ * );
46
+ * ```
47
+ */
48
+ retrieve(
49
+ topicID: string,
50
+ params: TopicRetrieveParams,
51
+ options?: RequestOptions,
52
+ ): APIPromise<WorkspacePreferencesAPI.WorkspacePreferenceTopicGetResponse> {
53
+ const { section_id } = params;
54
+ return this._client.get(path`/preferences/sections/${section_id}/topics/${topicID}`, options);
55
+ }
56
+
57
+ /**
58
+ * List the topics in a workspace preference.
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * const workspacePreferenceTopicListResponse =
63
+ * await client.workspacePreferences.topics.list(
64
+ * 'section_id',
65
+ * );
66
+ * ```
67
+ */
68
+ list(
69
+ sectionID: string,
70
+ options?: RequestOptions,
71
+ ): APIPromise<WorkspacePreferencesAPI.WorkspacePreferenceTopicListResponse> {
72
+ return this._client.get(path`/preferences/sections/${sectionID}/topics`, options);
73
+ }
74
+
75
+ /**
76
+ * Archive a topic and remove it from its workspace preference. Same 404 rules as
77
+ * GET.
78
+ *
79
+ * @example
80
+ * ```ts
81
+ * await client.workspacePreferences.topics.archive(
82
+ * 'topic_id',
83
+ * { section_id: 'section_id' },
84
+ * );
85
+ * ```
86
+ */
87
+ archive(topicID: string, params: TopicArchiveParams, options?: RequestOptions): APIPromise<void> {
88
+ const { section_id } = params;
89
+ return this._client.delete(path`/preferences/sections/${section_id}/topics/${topicID}`, {
90
+ ...options,
91
+ headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
92
+ });
93
+ }
94
+
95
+ /**
96
+ * Replace a topic within a workspace preference. Full document replacement;
97
+ * missing optional fields are cleared. Same 404 rules as GET.
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * const workspacePreferenceTopicGetResponse =
102
+ * await client.workspacePreferences.topics.replace(
103
+ * 'topic_id',
104
+ * {
105
+ * section_id: 'section_id',
106
+ * default_status: 'OPTED_OUT',
107
+ * name: 'name',
108
+ * },
109
+ * );
110
+ * ```
111
+ */
112
+ replace(
113
+ topicID: string,
114
+ params: TopicReplaceParams,
115
+ options?: RequestOptions,
116
+ ): APIPromise<WorkspacePreferencesAPI.WorkspacePreferenceTopicGetResponse> {
117
+ const { section_id, ...body } = params;
118
+ return this._client.put(path`/preferences/sections/${section_id}/topics/${topicID}`, {
119
+ body,
120
+ ...options,
121
+ });
122
+ }
123
+ }
124
+
125
+ export interface TopicCreateParams {
126
+ /**
127
+ * The default subscription status applied when a recipient has not set their own.
128
+ */
129
+ default_status: 'OPTED_OUT' | 'OPTED_IN' | 'REQUIRED';
130
+
131
+ /**
132
+ * Human-readable name for the preference topic.
133
+ */
134
+ name: string;
135
+
136
+ /**
137
+ * Preference controls a recipient may customize for this topic. Defaults to empty
138
+ * if omitted.
139
+ */
140
+ allowed_preferences?: Array<'snooze' | 'channel_preferences'> | null;
141
+
142
+ /**
143
+ * Optional description shown under the topic on the hosted preferences page.
144
+ */
145
+ description?: string | null;
146
+
147
+ /**
148
+ * Whether to include a list-unsubscribe header on emails for this topic.
149
+ */
150
+ include_unsubscribe_header?: boolean | null;
151
+
152
+ /**
153
+ * Default channels delivered for this topic. Defaults to empty if omitted.
154
+ */
155
+ routing_options?: Array<Shared.ChannelClassification> | null;
156
+
157
+ /**
158
+ * Arbitrary metadata associated with the topic.
159
+ */
160
+ topic_data?: { [key: string]: unknown } | null;
161
+ }
162
+
163
+ export interface TopicRetrieveParams {
164
+ /**
165
+ * Id of the workspace preference.
166
+ */
167
+ section_id: string;
168
+ }
169
+
170
+ export interface TopicArchiveParams {
171
+ /**
172
+ * Id of the workspace preference.
173
+ */
174
+ section_id: string;
175
+ }
176
+
177
+ export interface TopicReplaceParams {
178
+ /**
179
+ * Path param: Id of the workspace preference.
180
+ */
181
+ section_id: string;
182
+
183
+ /**
184
+ * Body param: The default subscription status applied when a recipient has not set
185
+ * their own.
186
+ */
187
+ default_status: 'OPTED_OUT' | 'OPTED_IN' | 'REQUIRED';
188
+
189
+ /**
190
+ * Body param: Human-readable name for the preference topic.
191
+ */
192
+ name: string;
193
+
194
+ /**
195
+ * Body param: Preference controls a recipient may customize. Omit to clear.
196
+ */
197
+ allowed_preferences?: Array<'snooze' | 'channel_preferences'> | null;
198
+
199
+ /**
200
+ * Body param: Optional description shown under the topic on the hosted preferences
201
+ * page. Omit to clear.
202
+ */
203
+ description?: string | null;
204
+
205
+ /**
206
+ * Body param: Whether to include a list-unsubscribe header on emails for this
207
+ * topic.
208
+ */
209
+ include_unsubscribe_header?: boolean | null;
210
+
211
+ /**
212
+ * Body param: Default channels delivered for this topic. Omit to clear.
213
+ */
214
+ routing_options?: Array<Shared.ChannelClassification> | null;
215
+
216
+ /**
217
+ * Body param: Arbitrary metadata associated with the topic. Omit to clear.
218
+ */
219
+ topic_data?: { [key: string]: unknown } | null;
220
+ }
221
+
222
+ export declare namespace Topics {
223
+ export {
224
+ type TopicCreateParams as TopicCreateParams,
225
+ type TopicRetrieveParams as TopicRetrieveParams,
226
+ type TopicArchiveParams as TopicArchiveParams,
227
+ type TopicReplaceParams as TopicReplaceParams,
228
+ };
229
+ }