@trycourier/courier 7.11.0 → 7.19.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.
- package/CHANGELOG.md +123 -0
- package/README.md +1 -0
- package/client.d.mts +10 -4
- package/client.d.mts.map +1 -1
- package/client.d.ts +10 -4
- package/client.d.ts.map +1 -1
- package/client.js +15 -1
- package/client.js.map +1 -1
- package/client.mjs +15 -1
- package/client.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/audiences.d.mts +5 -2
- package/resources/audiences.d.mts.map +1 -1
- package/resources/audiences.d.ts +5 -2
- package/resources/audiences.d.ts.map +1 -1
- package/resources/brands.d.mts +35 -2
- package/resources/brands.d.mts.map +1 -1
- package/resources/brands.d.ts +35 -2
- package/resources/brands.d.ts.map +1 -1
- package/resources/brands.js +34 -1
- package/resources/brands.js.map +1 -1
- package/resources/brands.mjs +34 -1
- package/resources/brands.mjs.map +1 -1
- package/resources/digests/digests.d.mts +94 -0
- package/resources/digests/digests.d.mts.map +1 -0
- package/resources/digests/digests.d.ts +94 -0
- package/resources/digests/digests.d.ts.map +1 -0
- package/resources/digests/digests.js +17 -0
- package/resources/digests/digests.js.map +1 -0
- package/resources/digests/digests.mjs +12 -0
- package/resources/digests/digests.mjs.map +1 -0
- package/resources/digests/index.d.mts +3 -0
- package/resources/digests/index.d.mts.map +1 -0
- package/resources/digests/index.d.ts +3 -0
- package/resources/digests/index.d.ts.map +1 -0
- package/resources/digests/index.js +9 -0
- package/resources/digests/index.js.map +1 -0
- package/resources/digests/index.mjs +4 -0
- package/resources/digests/index.mjs.map +1 -0
- package/resources/digests/schedules.d.mts +32 -0
- package/resources/digests/schedules.d.mts.map +1 -0
- package/resources/digests/schedules.d.ts +32 -0
- package/resources/digests/schedules.d.ts.map +1 -0
- package/resources/digests/schedules.js +29 -0
- package/resources/digests/schedules.js.map +1 -0
- package/resources/digests/schedules.mjs +25 -0
- package/resources/digests/schedules.mjs.map +1 -0
- package/resources/digests.d.mts +2 -0
- package/resources/digests.d.mts.map +1 -0
- package/resources/digests.d.ts +2 -0
- package/resources/digests.d.ts.map +1 -0
- package/resources/digests.js +6 -0
- package/resources/digests.js.map +1 -0
- package/resources/digests.mjs +3 -0
- package/resources/digests.mjs.map +1 -0
- package/resources/index.d.mts +4 -2
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +4 -2
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +5 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +2 -0
- package/resources/index.mjs.map +1 -1
- package/resources/journeys/index.d.mts +2 -2
- package/resources/journeys/index.d.mts.map +1 -1
- package/resources/journeys/index.d.ts +2 -2
- package/resources/journeys/index.d.ts.map +1 -1
- package/resources/journeys/index.js.map +1 -1
- package/resources/journeys/index.mjs.map +1 -1
- package/resources/journeys/journeys.d.mts +198 -7
- package/resources/journeys/journeys.d.mts.map +1 -1
- package/resources/journeys/journeys.d.ts +198 -7
- package/resources/journeys/journeys.d.ts.map +1 -1
- package/resources/journeys/journeys.js +18 -0
- package/resources/journeys/journeys.js.map +1 -1
- package/resources/journeys/journeys.mjs +18 -0
- package/resources/journeys/journeys.mjs.map +1 -1
- package/resources/journeys/templates.d.mts +120 -1
- package/resources/journeys/templates.d.mts.map +1 -1
- package/resources/journeys/templates.d.ts +120 -1
- package/resources/journeys/templates.d.ts.map +1 -1
- package/resources/journeys/templates.js +71 -0
- package/resources/journeys/templates.js.map +1 -1
- package/resources/journeys/templates.mjs +71 -0
- package/resources/journeys/templates.mjs.map +1 -1
- package/resources/messages.d.mts +16 -1
- package/resources/messages.d.mts.map +1 -1
- package/resources/messages.d.ts +16 -1
- package/resources/messages.d.ts.map +1 -1
- package/resources/messages.js +10 -0
- package/resources/messages.js.map +1 -1
- package/resources/messages.mjs +10 -0
- package/resources/messages.mjs.map +1 -1
- package/resources/notifications/checks.d.mts +3 -3
- package/resources/notifications/checks.d.ts +3 -3
- package/resources/notifications/checks.js +3 -3
- package/resources/notifications/checks.mjs +3 -3
- package/resources/notifications/notifications.d.mts +7 -3
- package/resources/notifications/notifications.d.mts.map +1 -1
- package/resources/notifications/notifications.d.ts +7 -3
- package/resources/notifications/notifications.d.ts.map +1 -1
- package/resources/notifications/notifications.js +7 -3
- package/resources/notifications/notifications.js.map +1 -1
- package/resources/notifications/notifications.mjs +7 -3
- package/resources/notifications/notifications.mjs.map +1 -1
- package/resources/shared.d.mts +6 -0
- package/resources/shared.d.mts.map +1 -1
- package/resources/shared.d.ts +6 -0
- package/resources/shared.d.ts.map +1 -1
- package/resources/users/index.d.mts +1 -1
- package/resources/users/index.d.mts.map +1 -1
- package/resources/users/index.d.ts +1 -1
- package/resources/users/index.d.ts.map +1 -1
- package/resources/users/index.js.map +1 -1
- package/resources/users/index.mjs.map +1 -1
- package/resources/users/preferences.d.mts +211 -1
- package/resources/users/preferences.d.mts.map +1 -1
- package/resources/users/preferences.d.ts +211 -1
- package/resources/users/preferences.d.ts.map +1 -1
- package/resources/users/preferences.js +105 -0
- package/resources/users/preferences.js.map +1 -1
- package/resources/users/preferences.mjs +105 -0
- package/resources/users/preferences.mjs.map +1 -1
- package/resources/users/users.d.mts +2 -2
- package/resources/users/users.d.mts.map +1 -1
- package/resources/users/users.d.ts +2 -2
- package/resources/users/users.d.ts.map +1 -1
- package/resources/users/users.js.map +1 -1
- package/resources/users/users.mjs.map +1 -1
- package/resources/workspace-preferences/index.d.mts +3 -0
- package/resources/workspace-preferences/index.d.mts.map +1 -0
- package/resources/workspace-preferences/index.d.ts +3 -0
- package/resources/workspace-preferences/index.d.ts.map +1 -0
- package/resources/workspace-preferences/index.js +9 -0
- package/resources/workspace-preferences/index.js.map +1 -0
- package/resources/workspace-preferences/index.mjs +4 -0
- package/resources/workspace-preferences/index.mjs.map +1 -0
- package/resources/workspace-preferences/topics.d.mts +168 -0
- package/resources/workspace-preferences/topics.d.mts.map +1 -0
- package/resources/workspace-preferences/topics.d.ts +168 -0
- package/resources/workspace-preferences/topics.d.ts.map +1 -0
- package/resources/workspace-preferences/topics.js +103 -0
- package/resources/workspace-preferences/topics.js.map +1 -0
- package/resources/workspace-preferences/topics.mjs +99 -0
- package/resources/workspace-preferences/topics.mjs.map +1 -0
- package/resources/workspace-preferences/workspace-preferences.d.mts +410 -0
- package/resources/workspace-preferences/workspace-preferences.d.mts.map +1 -0
- package/resources/workspace-preferences/workspace-preferences.d.ts +410 -0
- package/resources/workspace-preferences/workspace-preferences.d.ts.map +1 -0
- package/resources/workspace-preferences/workspace-preferences.js +104 -0
- package/resources/workspace-preferences/workspace-preferences.js.map +1 -0
- package/resources/workspace-preferences/workspace-preferences.mjs +99 -0
- package/resources/workspace-preferences/workspace-preferences.mjs.map +1 -0
- package/resources/workspace-preferences.d.mts +2 -0
- package/resources/workspace-preferences.d.mts.map +1 -0
- package/resources/workspace-preferences.d.ts +2 -0
- package/resources/workspace-preferences.d.ts.map +1 -0
- package/resources/workspace-preferences.js +6 -0
- package/resources/workspace-preferences.js.map +1 -0
- package/resources/workspace-preferences.mjs +3 -0
- package/resources/workspace-preferences.mjs.map +1 -0
- package/src/client.ts +71 -1
- package/src/resources/audiences.ts +5 -2
- package/src/resources/brands.ts +36 -3
- package/src/resources/digests/digests.ts +120 -0
- package/src/resources/digests/index.ts +9 -0
- package/src/resources/digests/schedules.ts +51 -0
- package/src/resources/digests.ts +3 -0
- package/src/resources/index.ts +28 -0
- package/src/resources/journeys/index.ts +8 -0
- package/src/resources/journeys/journeys.ts +246 -4
- package/src/resources/journeys/templates.ts +168 -0
- package/src/resources/messages.ts +20 -0
- package/src/resources/notifications/checks.ts +3 -3
- package/src/resources/notifications/notifications.ts +7 -3
- package/src/resources/shared.ts +7 -0
- package/src/resources/users/index.ts +6 -0
- package/src/resources/users/preferences.ts +269 -0
- package/src/resources/users/users.ts +12 -0
- package/src/resources/workspace-preferences/index.ts +25 -0
- package/src/resources/workspace-preferences/topics.ts +229 -0
- package/src/resources/workspace-preferences/workspace-preferences.ts +534 -0
- package/src/resources/workspace-preferences.ts +3 -0
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -14,6 +14,97 @@ export declare class Preferences extends APIResource {
|
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
16
|
retrieve(userID: string, query?: PreferenceRetrieveParams | null | undefined, options?: RequestOptions): APIPromise<PreferenceRetrieveResponse>;
|
|
17
|
+
/**
|
|
18
|
+
* Replace a user's complete set of preference overrides in a single request. The
|
|
19
|
+
* topics in the request body become the recipient's entire set of overrides:
|
|
20
|
+
* listed topics are created or updated, and every existing override that is not
|
|
21
|
+
* included in the body is reset to its topic default. Submitting an empty `topics`
|
|
22
|
+
* array is a valid clear-all that resets every existing override.
|
|
23
|
+
*
|
|
24
|
+
* This operation is validation-atomic (all-or-nothing): structural validation
|
|
25
|
+
* fails fast with a single `400`, and if any topic is semantically invalid (an
|
|
26
|
+
* unknown topic, a `REQUIRED` topic that cannot be opted out, or a custom routing
|
|
27
|
+
* request that is not available on the workspace's plan) the request returns a
|
|
28
|
+
* single `400` aggregating every failure in `errors` and writes nothing. On
|
|
29
|
+
* success it returns `200` with `items` (the complete resulting override set) and
|
|
30
|
+
* `deleted` (the ids of the overrides that were reset to default).
|
|
31
|
+
*
|
|
32
|
+
* Every `topic_id` in the response — in `items`, `deleted`, and any `errors` — is
|
|
33
|
+
* returned in Courier's canonical topic id form, regardless of the form supplied
|
|
34
|
+
* in the request.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* const response = await client.users.preferences.bulkReplace(
|
|
39
|
+
* 'user_id',
|
|
40
|
+
* {
|
|
41
|
+
* topics: [
|
|
42
|
+
* {
|
|
43
|
+
* topic_id: 'pt_01kx4h2jdafq8bk996nn92357r',
|
|
44
|
+
* status: 'OPTED_IN',
|
|
45
|
+
* has_custom_routing: true,
|
|
46
|
+
* custom_routing: ['inbox', 'email'],
|
|
47
|
+
* },
|
|
48
|
+
* ],
|
|
49
|
+
* },
|
|
50
|
+
* );
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
bulkReplace(userID: string, params: PreferenceBulkReplaceParams, options?: RequestOptions): APIPromise<PreferenceBulkReplaceResponse>;
|
|
54
|
+
/**
|
|
55
|
+
* Additively create or update a user's preferences for one or more subscription
|
|
56
|
+
* topics in a single request. Only the topics included in the request body are
|
|
57
|
+
* created or updated; any existing overrides for topics not listed are left
|
|
58
|
+
* untouched.
|
|
59
|
+
*
|
|
60
|
+
* Structural validation of the request body fails fast with a single `400`. Beyond
|
|
61
|
+
* that, each topic is processed independently (partial-success, not
|
|
62
|
+
* all-or-nothing): valid topics are written and returned in `items`, while topics
|
|
63
|
+
* that cannot be applied are collected in `errors` with a per-topic `reason` (for
|
|
64
|
+
* example an unknown topic, a `REQUIRED` topic that cannot be opted out, a custom
|
|
65
|
+
* routing request that is not available on the workspace's plan, or a write
|
|
66
|
+
* failure). The request therefore returns `200` with both lists whenever the body
|
|
67
|
+
* is structurally valid.
|
|
68
|
+
*
|
|
69
|
+
* Every `topic_id` in the response — in both `items` and `errors` — is returned in
|
|
70
|
+
* Courier's canonical topic id form, regardless of the form supplied in the
|
|
71
|
+
* request.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* const response = await client.users.preferences.bulkUpdate(
|
|
76
|
+
* 'user_id',
|
|
77
|
+
* {
|
|
78
|
+
* topics: [
|
|
79
|
+
* {
|
|
80
|
+
* topic_id: 'pt_01kx4h2jdafq8bk996nn92357r',
|
|
81
|
+
* status: 'OPTED_IN',
|
|
82
|
+
* has_custom_routing: true,
|
|
83
|
+
* custom_routing: ['inbox', 'email'],
|
|
84
|
+
* },
|
|
85
|
+
* {
|
|
86
|
+
* topic_id: 'pt_01kx4h2jdafq8bk99eyt3dx43x',
|
|
87
|
+
* status: 'OPTED_OUT',
|
|
88
|
+
* },
|
|
89
|
+
* ],
|
|
90
|
+
* },
|
|
91
|
+
* );
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
bulkUpdate(userID: string, params: PreferenceBulkUpdateParams, options?: RequestOptions): APIPromise<PreferenceBulkUpdateResponse>;
|
|
95
|
+
/**
|
|
96
|
+
* Remove a user's preferences for a specific subscription topic, resetting the
|
|
97
|
+
* topic to its effective default. This operation is idempotent: deleting a
|
|
98
|
+
* preference that does not exist succeeds with no error.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```ts
|
|
102
|
+
* await client.users.preferences.deleteTopic('topic_id', {
|
|
103
|
+
* user_id: 'user_id',
|
|
104
|
+
* });
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
deleteTopic(topicID: string, params: PreferenceDeleteTopicParams, options?: RequestOptions): APIPromise<void>;
|
|
17
108
|
/**
|
|
18
109
|
* Fetch user preferences for a specific subscription topic.
|
|
19
110
|
*
|
|
@@ -47,6 +138,19 @@ export declare class Preferences extends APIResource {
|
|
|
47
138
|
*/
|
|
48
139
|
updateOrCreateTopic(topicID: string, params: PreferenceUpdateOrCreateTopicParams, options?: RequestOptions): APIPromise<PreferenceUpdateOrCreateTopicResponse>;
|
|
49
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* A single topic override echoed in a bulk preference response.
|
|
143
|
+
*/
|
|
144
|
+
export interface BulkPreferenceTopic {
|
|
145
|
+
custom_routing: Array<Shared.ChannelClassification>;
|
|
146
|
+
has_custom_routing: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* The applied subscription status. Echoes the requested value, so it is always
|
|
149
|
+
* OPTED_IN or OPTED_OUT.
|
|
150
|
+
*/
|
|
151
|
+
status: 'OPTED_IN' | 'OPTED_OUT';
|
|
152
|
+
topic_id: string;
|
|
153
|
+
}
|
|
50
154
|
export interface TopicPreference {
|
|
51
155
|
default_status: Shared.PreferenceStatus;
|
|
52
156
|
status: Shared.PreferenceStatus;
|
|
@@ -68,6 +172,38 @@ export interface PreferenceRetrieveResponse {
|
|
|
68
172
|
*/
|
|
69
173
|
paging: Shared.Paging;
|
|
70
174
|
}
|
|
175
|
+
export interface PreferenceBulkReplaceResponse {
|
|
176
|
+
/**
|
|
177
|
+
* The ids of the overrides that were reset to their topic default.
|
|
178
|
+
*/
|
|
179
|
+
deleted: Array<string>;
|
|
180
|
+
/**
|
|
181
|
+
* The complete resulting set of topic overrides for the user.
|
|
182
|
+
*/
|
|
183
|
+
items: Array<BulkPreferenceTopic>;
|
|
184
|
+
}
|
|
185
|
+
export interface PreferenceBulkUpdateResponse {
|
|
186
|
+
/**
|
|
187
|
+
* The topics that could not be applied, each with a reason.
|
|
188
|
+
*/
|
|
189
|
+
errors: Array<PreferenceBulkUpdateResponse.Error>;
|
|
190
|
+
/**
|
|
191
|
+
* The topics that were successfully created or updated.
|
|
192
|
+
*/
|
|
193
|
+
items: Array<BulkPreferenceTopic>;
|
|
194
|
+
}
|
|
195
|
+
export declare namespace PreferenceBulkUpdateResponse {
|
|
196
|
+
/**
|
|
197
|
+
* A single topic that could not be applied in a bulk preference request.
|
|
198
|
+
*/
|
|
199
|
+
interface Error {
|
|
200
|
+
/**
|
|
201
|
+
* A human-readable explanation of why the topic could not be applied.
|
|
202
|
+
*/
|
|
203
|
+
reason: string;
|
|
204
|
+
topic_id: string;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
71
207
|
export interface PreferenceRetrieveTopicResponse {
|
|
72
208
|
topic: TopicPreference;
|
|
73
209
|
}
|
|
@@ -80,6 +216,80 @@ export interface PreferenceRetrieveParams {
|
|
|
80
216
|
*/
|
|
81
217
|
tenant_id?: string | null;
|
|
82
218
|
}
|
|
219
|
+
export interface PreferenceBulkReplaceParams {
|
|
220
|
+
/**
|
|
221
|
+
* Body param: The complete set of topic overrides for the user. Up to 50 topics
|
|
222
|
+
* may be provided. Any existing override not listed here is reset to its topic
|
|
223
|
+
* default; an empty array resets every existing override.
|
|
224
|
+
*/
|
|
225
|
+
topics: Array<PreferenceBulkReplaceParams.Topic>;
|
|
226
|
+
/**
|
|
227
|
+
* Query param: Replace the preferences of a user for this specific tenant context.
|
|
228
|
+
*/
|
|
229
|
+
tenant_id?: string | null;
|
|
230
|
+
}
|
|
231
|
+
export declare namespace PreferenceBulkReplaceParams {
|
|
232
|
+
interface Topic {
|
|
233
|
+
/**
|
|
234
|
+
* The subscription status to apply for this topic.
|
|
235
|
+
*/
|
|
236
|
+
status: 'OPTED_IN' | 'OPTED_OUT';
|
|
237
|
+
/**
|
|
238
|
+
* A unique identifier associated with a subscription topic.
|
|
239
|
+
*/
|
|
240
|
+
topic_id: string;
|
|
241
|
+
/**
|
|
242
|
+
* The channels a user has chosen to receive notifications through for this topic.
|
|
243
|
+
*/
|
|
244
|
+
custom_routing?: Array<Shared.ChannelClassification>;
|
|
245
|
+
/**
|
|
246
|
+
* Whether the recipient has chosen specific delivery channels for this topic.
|
|
247
|
+
*/
|
|
248
|
+
has_custom_routing?: boolean;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
export interface PreferenceBulkUpdateParams {
|
|
252
|
+
/**
|
|
253
|
+
* Body param: The topics to create or update. Between 1 and 50 topics may be
|
|
254
|
+
* provided in a single request.
|
|
255
|
+
*/
|
|
256
|
+
topics: Array<PreferenceBulkUpdateParams.Topic>;
|
|
257
|
+
/**
|
|
258
|
+
* Query param: Update the preferences of a user for this specific tenant context.
|
|
259
|
+
*/
|
|
260
|
+
tenant_id?: string | null;
|
|
261
|
+
}
|
|
262
|
+
export declare namespace PreferenceBulkUpdateParams {
|
|
263
|
+
interface Topic {
|
|
264
|
+
/**
|
|
265
|
+
* The subscription status to apply for this topic.
|
|
266
|
+
*/
|
|
267
|
+
status: 'OPTED_IN' | 'OPTED_OUT';
|
|
268
|
+
/**
|
|
269
|
+
* A unique identifier associated with a subscription topic.
|
|
270
|
+
*/
|
|
271
|
+
topic_id: string;
|
|
272
|
+
/**
|
|
273
|
+
* The channels a user has chosen to receive notifications through for this topic.
|
|
274
|
+
*/
|
|
275
|
+
custom_routing?: Array<Shared.ChannelClassification>;
|
|
276
|
+
/**
|
|
277
|
+
* Whether the recipient has chosen specific delivery channels for this topic.
|
|
278
|
+
*/
|
|
279
|
+
has_custom_routing?: boolean;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
export interface PreferenceDeleteTopicParams {
|
|
283
|
+
/**
|
|
284
|
+
* Path param: A unique identifier associated with the user whose preferences you
|
|
285
|
+
* wish to delete.
|
|
286
|
+
*/
|
|
287
|
+
user_id: string;
|
|
288
|
+
/**
|
|
289
|
+
* Query param: Delete the preferences of a user for this specific tenant context.
|
|
290
|
+
*/
|
|
291
|
+
tenant_id?: string | null;
|
|
292
|
+
}
|
|
83
293
|
export interface PreferenceRetrieveTopicParams {
|
|
84
294
|
/**
|
|
85
295
|
* Path param: A unique identifier associated with the user whose preferences you
|
|
@@ -117,6 +327,6 @@ export declare namespace PreferenceUpdateOrCreateTopicParams {
|
|
|
117
327
|
}
|
|
118
328
|
}
|
|
119
329
|
export declare namespace Preferences {
|
|
120
|
-
export { type TopicPreference as TopicPreference, type PreferenceRetrieveResponse as PreferenceRetrieveResponse, type PreferenceRetrieveTopicResponse as PreferenceRetrieveTopicResponse, type PreferenceUpdateOrCreateTopicResponse as PreferenceUpdateOrCreateTopicResponse, type PreferenceRetrieveParams as PreferenceRetrieveParams, type PreferenceRetrieveTopicParams as PreferenceRetrieveTopicParams, type PreferenceUpdateOrCreateTopicParams as PreferenceUpdateOrCreateTopicParams, };
|
|
330
|
+
export { type BulkPreferenceTopic as BulkPreferenceTopic, type TopicPreference as TopicPreference, type PreferenceRetrieveResponse as PreferenceRetrieveResponse, type PreferenceBulkReplaceResponse as PreferenceBulkReplaceResponse, type PreferenceBulkUpdateResponse as PreferenceBulkUpdateResponse, type PreferenceRetrieveTopicResponse as PreferenceRetrieveTopicResponse, type PreferenceUpdateOrCreateTopicResponse as PreferenceUpdateOrCreateTopicResponse, type PreferenceRetrieveParams as PreferenceRetrieveParams, type PreferenceBulkReplaceParams as PreferenceBulkReplaceParams, type PreferenceBulkUpdateParams as PreferenceBulkUpdateParams, type PreferenceDeleteTopicParams as PreferenceDeleteTopicParams, type PreferenceRetrieveTopicParams as PreferenceRetrieveTopicParams, type PreferenceUpdateOrCreateTopicParams as PreferenceUpdateOrCreateTopicParams, };
|
|
121
331
|
}
|
|
122
332
|
//# sourceMappingURL=preferences.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preferences.d.mts","sourceRoot":"","sources":["../../src/resources/users/preferences.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,gCAA4B;AAClD,OAAO,KAAK,MAAM,sBAAkB;AACpC,OAAO,EAAE,UAAU,EAAE,mCAA+B;
|
|
1
|
+
{"version":3,"file":"preferences.d.mts","sourceRoot":"","sources":["../../src/resources/users/preferences.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,gCAA4B;AAClD,OAAO,KAAK,MAAM,sBAAkB;AACpC,OAAO,EAAE,UAAU,EAAE,mCAA+B;AAEpD,OAAO,EAAE,cAAc,EAAE,2CAAuC;AAGhE,qBAAa,WAAY,SAAQ,WAAW;IAC1C;;;;;;;;;OASG;IACH,QAAQ,CACN,MAAM,EAAE,MAAM,EACd,KAAK,GAAE,wBAAwB,GAAG,IAAI,GAAG,SAAc,EACvD,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,0BAA0B,CAAC;IAIzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACH,WAAW,CACT,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,2BAA2B,EACnC,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,6BAA6B,CAAC;IAK5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuCG;IACH,UAAU,CACR,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,0BAA0B,EAClC,OAAO,CAAC,EAAE,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6BAA6B,IAAI,6BAA6B,EACnE,KAAK,4BAA4B,IAAI,4BAA4B,EACjE,KAAK,+BAA+B,IAAI,+BAA+B,EACvE,KAAK,qCAAqC,IAAI,qCAAqC,EACnF,KAAK,wBAAwB,IAAI,wBAAwB,EACzD,KAAK,2BAA2B,IAAI,2BAA2B,EAC/D,KAAK,0BAA0B,IAAI,0BAA0B,EAC7D,KAAK,2BAA2B,IAAI,2BAA2B,EAC/D,KAAK,6BAA6B,IAAI,6BAA6B,EACnE,KAAK,mCAAmC,IAAI,mCAAmC,GAChF,CAAC;CACH"}
|
|
@@ -14,6 +14,97 @@ export declare class Preferences extends APIResource {
|
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
16
|
retrieve(userID: string, query?: PreferenceRetrieveParams | null | undefined, options?: RequestOptions): APIPromise<PreferenceRetrieveResponse>;
|
|
17
|
+
/**
|
|
18
|
+
* Replace a user's complete set of preference overrides in a single request. The
|
|
19
|
+
* topics in the request body become the recipient's entire set of overrides:
|
|
20
|
+
* listed topics are created or updated, and every existing override that is not
|
|
21
|
+
* included in the body is reset to its topic default. Submitting an empty `topics`
|
|
22
|
+
* array is a valid clear-all that resets every existing override.
|
|
23
|
+
*
|
|
24
|
+
* This operation is validation-atomic (all-or-nothing): structural validation
|
|
25
|
+
* fails fast with a single `400`, and if any topic is semantically invalid (an
|
|
26
|
+
* unknown topic, a `REQUIRED` topic that cannot be opted out, or a custom routing
|
|
27
|
+
* request that is not available on the workspace's plan) the request returns a
|
|
28
|
+
* single `400` aggregating every failure in `errors` and writes nothing. On
|
|
29
|
+
* success it returns `200` with `items` (the complete resulting override set) and
|
|
30
|
+
* `deleted` (the ids of the overrides that were reset to default).
|
|
31
|
+
*
|
|
32
|
+
* Every `topic_id` in the response — in `items`, `deleted`, and any `errors` — is
|
|
33
|
+
* returned in Courier's canonical topic id form, regardless of the form supplied
|
|
34
|
+
* in the request.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* const response = await client.users.preferences.bulkReplace(
|
|
39
|
+
* 'user_id',
|
|
40
|
+
* {
|
|
41
|
+
* topics: [
|
|
42
|
+
* {
|
|
43
|
+
* topic_id: 'pt_01kx4h2jdafq8bk996nn92357r',
|
|
44
|
+
* status: 'OPTED_IN',
|
|
45
|
+
* has_custom_routing: true,
|
|
46
|
+
* custom_routing: ['inbox', 'email'],
|
|
47
|
+
* },
|
|
48
|
+
* ],
|
|
49
|
+
* },
|
|
50
|
+
* );
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
bulkReplace(userID: string, params: PreferenceBulkReplaceParams, options?: RequestOptions): APIPromise<PreferenceBulkReplaceResponse>;
|
|
54
|
+
/**
|
|
55
|
+
* Additively create or update a user's preferences for one or more subscription
|
|
56
|
+
* topics in a single request. Only the topics included in the request body are
|
|
57
|
+
* created or updated; any existing overrides for topics not listed are left
|
|
58
|
+
* untouched.
|
|
59
|
+
*
|
|
60
|
+
* Structural validation of the request body fails fast with a single `400`. Beyond
|
|
61
|
+
* that, each topic is processed independently (partial-success, not
|
|
62
|
+
* all-or-nothing): valid topics are written and returned in `items`, while topics
|
|
63
|
+
* that cannot be applied are collected in `errors` with a per-topic `reason` (for
|
|
64
|
+
* example an unknown topic, a `REQUIRED` topic that cannot be opted out, a custom
|
|
65
|
+
* routing request that is not available on the workspace's plan, or a write
|
|
66
|
+
* failure). The request therefore returns `200` with both lists whenever the body
|
|
67
|
+
* is structurally valid.
|
|
68
|
+
*
|
|
69
|
+
* Every `topic_id` in the response — in both `items` and `errors` — is returned in
|
|
70
|
+
* Courier's canonical topic id form, regardless of the form supplied in the
|
|
71
|
+
* request.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* const response = await client.users.preferences.bulkUpdate(
|
|
76
|
+
* 'user_id',
|
|
77
|
+
* {
|
|
78
|
+
* topics: [
|
|
79
|
+
* {
|
|
80
|
+
* topic_id: 'pt_01kx4h2jdafq8bk996nn92357r',
|
|
81
|
+
* status: 'OPTED_IN',
|
|
82
|
+
* has_custom_routing: true,
|
|
83
|
+
* custom_routing: ['inbox', 'email'],
|
|
84
|
+
* },
|
|
85
|
+
* {
|
|
86
|
+
* topic_id: 'pt_01kx4h2jdafq8bk99eyt3dx43x',
|
|
87
|
+
* status: 'OPTED_OUT',
|
|
88
|
+
* },
|
|
89
|
+
* ],
|
|
90
|
+
* },
|
|
91
|
+
* );
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
bulkUpdate(userID: string, params: PreferenceBulkUpdateParams, options?: RequestOptions): APIPromise<PreferenceBulkUpdateResponse>;
|
|
95
|
+
/**
|
|
96
|
+
* Remove a user's preferences for a specific subscription topic, resetting the
|
|
97
|
+
* topic to its effective default. This operation is idempotent: deleting a
|
|
98
|
+
* preference that does not exist succeeds with no error.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```ts
|
|
102
|
+
* await client.users.preferences.deleteTopic('topic_id', {
|
|
103
|
+
* user_id: 'user_id',
|
|
104
|
+
* });
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
deleteTopic(topicID: string, params: PreferenceDeleteTopicParams, options?: RequestOptions): APIPromise<void>;
|
|
17
108
|
/**
|
|
18
109
|
* Fetch user preferences for a specific subscription topic.
|
|
19
110
|
*
|
|
@@ -47,6 +138,19 @@ export declare class Preferences extends APIResource {
|
|
|
47
138
|
*/
|
|
48
139
|
updateOrCreateTopic(topicID: string, params: PreferenceUpdateOrCreateTopicParams, options?: RequestOptions): APIPromise<PreferenceUpdateOrCreateTopicResponse>;
|
|
49
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* A single topic override echoed in a bulk preference response.
|
|
143
|
+
*/
|
|
144
|
+
export interface BulkPreferenceTopic {
|
|
145
|
+
custom_routing: Array<Shared.ChannelClassification>;
|
|
146
|
+
has_custom_routing: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* The applied subscription status. Echoes the requested value, so it is always
|
|
149
|
+
* OPTED_IN or OPTED_OUT.
|
|
150
|
+
*/
|
|
151
|
+
status: 'OPTED_IN' | 'OPTED_OUT';
|
|
152
|
+
topic_id: string;
|
|
153
|
+
}
|
|
50
154
|
export interface TopicPreference {
|
|
51
155
|
default_status: Shared.PreferenceStatus;
|
|
52
156
|
status: Shared.PreferenceStatus;
|
|
@@ -68,6 +172,38 @@ export interface PreferenceRetrieveResponse {
|
|
|
68
172
|
*/
|
|
69
173
|
paging: Shared.Paging;
|
|
70
174
|
}
|
|
175
|
+
export interface PreferenceBulkReplaceResponse {
|
|
176
|
+
/**
|
|
177
|
+
* The ids of the overrides that were reset to their topic default.
|
|
178
|
+
*/
|
|
179
|
+
deleted: Array<string>;
|
|
180
|
+
/**
|
|
181
|
+
* The complete resulting set of topic overrides for the user.
|
|
182
|
+
*/
|
|
183
|
+
items: Array<BulkPreferenceTopic>;
|
|
184
|
+
}
|
|
185
|
+
export interface PreferenceBulkUpdateResponse {
|
|
186
|
+
/**
|
|
187
|
+
* The topics that could not be applied, each with a reason.
|
|
188
|
+
*/
|
|
189
|
+
errors: Array<PreferenceBulkUpdateResponse.Error>;
|
|
190
|
+
/**
|
|
191
|
+
* The topics that were successfully created or updated.
|
|
192
|
+
*/
|
|
193
|
+
items: Array<BulkPreferenceTopic>;
|
|
194
|
+
}
|
|
195
|
+
export declare namespace PreferenceBulkUpdateResponse {
|
|
196
|
+
/**
|
|
197
|
+
* A single topic that could not be applied in a bulk preference request.
|
|
198
|
+
*/
|
|
199
|
+
interface Error {
|
|
200
|
+
/**
|
|
201
|
+
* A human-readable explanation of why the topic could not be applied.
|
|
202
|
+
*/
|
|
203
|
+
reason: string;
|
|
204
|
+
topic_id: string;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
71
207
|
export interface PreferenceRetrieveTopicResponse {
|
|
72
208
|
topic: TopicPreference;
|
|
73
209
|
}
|
|
@@ -80,6 +216,80 @@ export interface PreferenceRetrieveParams {
|
|
|
80
216
|
*/
|
|
81
217
|
tenant_id?: string | null;
|
|
82
218
|
}
|
|
219
|
+
export interface PreferenceBulkReplaceParams {
|
|
220
|
+
/**
|
|
221
|
+
* Body param: The complete set of topic overrides for the user. Up to 50 topics
|
|
222
|
+
* may be provided. Any existing override not listed here is reset to its topic
|
|
223
|
+
* default; an empty array resets every existing override.
|
|
224
|
+
*/
|
|
225
|
+
topics: Array<PreferenceBulkReplaceParams.Topic>;
|
|
226
|
+
/**
|
|
227
|
+
* Query param: Replace the preferences of a user for this specific tenant context.
|
|
228
|
+
*/
|
|
229
|
+
tenant_id?: string | null;
|
|
230
|
+
}
|
|
231
|
+
export declare namespace PreferenceBulkReplaceParams {
|
|
232
|
+
interface Topic {
|
|
233
|
+
/**
|
|
234
|
+
* The subscription status to apply for this topic.
|
|
235
|
+
*/
|
|
236
|
+
status: 'OPTED_IN' | 'OPTED_OUT';
|
|
237
|
+
/**
|
|
238
|
+
* A unique identifier associated with a subscription topic.
|
|
239
|
+
*/
|
|
240
|
+
topic_id: string;
|
|
241
|
+
/**
|
|
242
|
+
* The channels a user has chosen to receive notifications through for this topic.
|
|
243
|
+
*/
|
|
244
|
+
custom_routing?: Array<Shared.ChannelClassification>;
|
|
245
|
+
/**
|
|
246
|
+
* Whether the recipient has chosen specific delivery channels for this topic.
|
|
247
|
+
*/
|
|
248
|
+
has_custom_routing?: boolean;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
export interface PreferenceBulkUpdateParams {
|
|
252
|
+
/**
|
|
253
|
+
* Body param: The topics to create or update. Between 1 and 50 topics may be
|
|
254
|
+
* provided in a single request.
|
|
255
|
+
*/
|
|
256
|
+
topics: Array<PreferenceBulkUpdateParams.Topic>;
|
|
257
|
+
/**
|
|
258
|
+
* Query param: Update the preferences of a user for this specific tenant context.
|
|
259
|
+
*/
|
|
260
|
+
tenant_id?: string | null;
|
|
261
|
+
}
|
|
262
|
+
export declare namespace PreferenceBulkUpdateParams {
|
|
263
|
+
interface Topic {
|
|
264
|
+
/**
|
|
265
|
+
* The subscription status to apply for this topic.
|
|
266
|
+
*/
|
|
267
|
+
status: 'OPTED_IN' | 'OPTED_OUT';
|
|
268
|
+
/**
|
|
269
|
+
* A unique identifier associated with a subscription topic.
|
|
270
|
+
*/
|
|
271
|
+
topic_id: string;
|
|
272
|
+
/**
|
|
273
|
+
* The channels a user has chosen to receive notifications through for this topic.
|
|
274
|
+
*/
|
|
275
|
+
custom_routing?: Array<Shared.ChannelClassification>;
|
|
276
|
+
/**
|
|
277
|
+
* Whether the recipient has chosen specific delivery channels for this topic.
|
|
278
|
+
*/
|
|
279
|
+
has_custom_routing?: boolean;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
export interface PreferenceDeleteTopicParams {
|
|
283
|
+
/**
|
|
284
|
+
* Path param: A unique identifier associated with the user whose preferences you
|
|
285
|
+
* wish to delete.
|
|
286
|
+
*/
|
|
287
|
+
user_id: string;
|
|
288
|
+
/**
|
|
289
|
+
* Query param: Delete the preferences of a user for this specific tenant context.
|
|
290
|
+
*/
|
|
291
|
+
tenant_id?: string | null;
|
|
292
|
+
}
|
|
83
293
|
export interface PreferenceRetrieveTopicParams {
|
|
84
294
|
/**
|
|
85
295
|
* Path param: A unique identifier associated with the user whose preferences you
|
|
@@ -117,6 +327,6 @@ export declare namespace PreferenceUpdateOrCreateTopicParams {
|
|
|
117
327
|
}
|
|
118
328
|
}
|
|
119
329
|
export declare namespace Preferences {
|
|
120
|
-
export { type TopicPreference as TopicPreference, type PreferenceRetrieveResponse as PreferenceRetrieveResponse, type PreferenceRetrieveTopicResponse as PreferenceRetrieveTopicResponse, type PreferenceUpdateOrCreateTopicResponse as PreferenceUpdateOrCreateTopicResponse, type PreferenceRetrieveParams as PreferenceRetrieveParams, type PreferenceRetrieveTopicParams as PreferenceRetrieveTopicParams, type PreferenceUpdateOrCreateTopicParams as PreferenceUpdateOrCreateTopicParams, };
|
|
330
|
+
export { type BulkPreferenceTopic as BulkPreferenceTopic, type TopicPreference as TopicPreference, type PreferenceRetrieveResponse as PreferenceRetrieveResponse, type PreferenceBulkReplaceResponse as PreferenceBulkReplaceResponse, type PreferenceBulkUpdateResponse as PreferenceBulkUpdateResponse, type PreferenceRetrieveTopicResponse as PreferenceRetrieveTopicResponse, type PreferenceUpdateOrCreateTopicResponse as PreferenceUpdateOrCreateTopicResponse, type PreferenceRetrieveParams as PreferenceRetrieveParams, type PreferenceBulkReplaceParams as PreferenceBulkReplaceParams, type PreferenceBulkUpdateParams as PreferenceBulkUpdateParams, type PreferenceDeleteTopicParams as PreferenceDeleteTopicParams, type PreferenceRetrieveTopicParams as PreferenceRetrieveTopicParams, type PreferenceUpdateOrCreateTopicParams as PreferenceUpdateOrCreateTopicParams, };
|
|
121
331
|
}
|
|
122
332
|
//# sourceMappingURL=preferences.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preferences.d.ts","sourceRoot":"","sources":["../../src/resources/users/preferences.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,+BAA4B;AAClD,OAAO,KAAK,MAAM,qBAAkB;AACpC,OAAO,EAAE,UAAU,EAAE,kCAA+B;
|
|
1
|
+
{"version":3,"file":"preferences.d.ts","sourceRoot":"","sources":["../../src/resources/users/preferences.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,+BAA4B;AAClD,OAAO,KAAK,MAAM,qBAAkB;AACpC,OAAO,EAAE,UAAU,EAAE,kCAA+B;AAEpD,OAAO,EAAE,cAAc,EAAE,0CAAuC;AAGhE,qBAAa,WAAY,SAAQ,WAAW;IAC1C;;;;;;;;;OASG;IACH,QAAQ,CACN,MAAM,EAAE,MAAM,EACd,KAAK,GAAE,wBAAwB,GAAG,IAAI,GAAG,SAAc,EACvD,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,0BAA0B,CAAC;IAIzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACH,WAAW,C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CAAC,GAAG,IAAI,CAAC;QAE5D,kBAAkB,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;KACrC;CACF;AAED,MAAM,CAAC,OAAO,WAAW,WAAW,CAAC;IACnC,OAAO,EACL,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,eAAe,IAAI,eAAe,EACvC,KAAK,0BAA0B,IAAI,0BAA0B,EAC7D,KAAK,6BAA6B,IAAI,6BAA6B,EACnE,KAAK,4BAA4B,IAAI,4BAA4B,EACjE,KAAK,+BAA+B,IAAI,+BAA+B,EACvE,KAAK,qCAAqC,IAAI,qCAAqC,EACnF,KAAK,wBAAwB,IAAI,wBAAwB,EACzD,KAAK,2BAA2B,IAAI,2BAA2B,EAC/D,KAAK,0BAA0B,IAAI,0BAA0B,EAC7D,KAAK,2BAA2B,IAAI,2BAA2B,EAC/D,KAAK,6BAA6B,IAAI,6BAA6B,EACnE,KAAK,mCAAmC,IAAI,mCAAmC,GAChF,CAAC;CACH"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Preferences = void 0;
|
|
5
5
|
const resource_1 = require("../../core/resource.js");
|
|
6
|
+
const headers_1 = require("../../internal/headers.js");
|
|
6
7
|
const path_1 = require("../../internal/utils/path.js");
|
|
7
8
|
class Preferences extends resource_1.APIResource {
|
|
8
9
|
/**
|
|
@@ -18,6 +19,110 @@ class Preferences extends resource_1.APIResource {
|
|
|
18
19
|
retrieve(userID, query = {}, options) {
|
|
19
20
|
return this._client.get((0, path_1.path) `/users/${userID}/preferences`, { query, ...options });
|
|
20
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Replace a user's complete set of preference overrides in a single request. The
|
|
24
|
+
* topics in the request body become the recipient's entire set of overrides:
|
|
25
|
+
* listed topics are created or updated, and every existing override that is not
|
|
26
|
+
* included in the body is reset to its topic default. Submitting an empty `topics`
|
|
27
|
+
* array is a valid clear-all that resets every existing override.
|
|
28
|
+
*
|
|
29
|
+
* This operation is validation-atomic (all-or-nothing): structural validation
|
|
30
|
+
* fails fast with a single `400`, and if any topic is semantically invalid (an
|
|
31
|
+
* unknown topic, a `REQUIRED` topic that cannot be opted out, or a custom routing
|
|
32
|
+
* request that is not available on the workspace's plan) the request returns a
|
|
33
|
+
* single `400` aggregating every failure in `errors` and writes nothing. On
|
|
34
|
+
* success it returns `200` with `items` (the complete resulting override set) and
|
|
35
|
+
* `deleted` (the ids of the overrides that were reset to default).
|
|
36
|
+
*
|
|
37
|
+
* Every `topic_id` in the response — in `items`, `deleted`, and any `errors` — is
|
|
38
|
+
* returned in Courier's canonical topic id form, regardless of the form supplied
|
|
39
|
+
* in the request.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* const response = await client.users.preferences.bulkReplace(
|
|
44
|
+
* 'user_id',
|
|
45
|
+
* {
|
|
46
|
+
* topics: [
|
|
47
|
+
* {
|
|
48
|
+
* topic_id: 'pt_01kx4h2jdafq8bk996nn92357r',
|
|
49
|
+
* status: 'OPTED_IN',
|
|
50
|
+
* has_custom_routing: true,
|
|
51
|
+
* custom_routing: ['inbox', 'email'],
|
|
52
|
+
* },
|
|
53
|
+
* ],
|
|
54
|
+
* },
|
|
55
|
+
* );
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
bulkReplace(userID, params, options) {
|
|
59
|
+
const { tenant_id, ...body } = params;
|
|
60
|
+
return this._client.put((0, path_1.path) `/users/${userID}/preferences`, { query: { tenant_id }, body, ...options });
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Additively create or update a user's preferences for one or more subscription
|
|
64
|
+
* topics in a single request. Only the topics included in the request body are
|
|
65
|
+
* created or updated; any existing overrides for topics not listed are left
|
|
66
|
+
* untouched.
|
|
67
|
+
*
|
|
68
|
+
* Structural validation of the request body fails fast with a single `400`. Beyond
|
|
69
|
+
* that, each topic is processed independently (partial-success, not
|
|
70
|
+
* all-or-nothing): valid topics are written and returned in `items`, while topics
|
|
71
|
+
* that cannot be applied are collected in `errors` with a per-topic `reason` (for
|
|
72
|
+
* example an unknown topic, a `REQUIRED` topic that cannot be opted out, a custom
|
|
73
|
+
* routing request that is not available on the workspace's plan, or a write
|
|
74
|
+
* failure). The request therefore returns `200` with both lists whenever the body
|
|
75
|
+
* is structurally valid.
|
|
76
|
+
*
|
|
77
|
+
* Every `topic_id` in the response — in both `items` and `errors` — is returned in
|
|
78
|
+
* Courier's canonical topic id form, regardless of the form supplied in the
|
|
79
|
+
* request.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* const response = await client.users.preferences.bulkUpdate(
|
|
84
|
+
* 'user_id',
|
|
85
|
+
* {
|
|
86
|
+
* topics: [
|
|
87
|
+
* {
|
|
88
|
+
* topic_id: 'pt_01kx4h2jdafq8bk996nn92357r',
|
|
89
|
+
* status: 'OPTED_IN',
|
|
90
|
+
* has_custom_routing: true,
|
|
91
|
+
* custom_routing: ['inbox', 'email'],
|
|
92
|
+
* },
|
|
93
|
+
* {
|
|
94
|
+
* topic_id: 'pt_01kx4h2jdafq8bk99eyt3dx43x',
|
|
95
|
+
* status: 'OPTED_OUT',
|
|
96
|
+
* },
|
|
97
|
+
* ],
|
|
98
|
+
* },
|
|
99
|
+
* );
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
bulkUpdate(userID, params, options) {
|
|
103
|
+
const { tenant_id, ...body } = params;
|
|
104
|
+
return this._client.post((0, path_1.path) `/users/${userID}/preferences`, { query: { tenant_id }, body, ...options });
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Remove a user's preferences for a specific subscription topic, resetting the
|
|
108
|
+
* topic to its effective default. This operation is idempotent: deleting a
|
|
109
|
+
* preference that does not exist succeeds with no error.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```ts
|
|
113
|
+
* await client.users.preferences.deleteTopic('topic_id', {
|
|
114
|
+
* user_id: 'user_id',
|
|
115
|
+
* });
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
deleteTopic(topicID, params, options) {
|
|
119
|
+
const { user_id, tenant_id } = params;
|
|
120
|
+
return this._client.delete((0, path_1.path) `/users/${user_id}/preferences/${topicID}`, {
|
|
121
|
+
query: { tenant_id },
|
|
122
|
+
...options,
|
|
123
|
+
headers: (0, headers_1.buildHeaders)([{ Accept: '*/*' }, options?.headers]),
|
|
124
|
+
});
|
|
125
|
+
}
|
|
21
126
|
/**
|
|
22
127
|
* Fetch user preferences for a specific subscription topic.
|
|
23
128
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preferences.js","sourceRoot":"","sources":["../../src/resources/users/preferences.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,qDAAkD;
|
|
1
|
+
{"version":3,"file":"preferences.js","sourceRoot":"","sources":["../../src/resources/users/preferences.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,qDAAkD;AAGlD,uDAAsD;AAEtD,uDAAiD;AAEjD,MAAa,WAAY,SAAQ,sBAAW;IAC1C;;;;;;;;;OASG;IACH,QAAQ,CACN,MAAc,EACd,QAAqD,EAAE,EACvD,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAA,WAAI,EAAA,UAAU,MAAM,cAAc,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACrF,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACH,WAAW,CACT,MAAc,EACd,MAAmC,EACnC,OAAwB;QAExB,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QACtC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAA,WAAI,EAAA,UAAU,MAAM,cAAc,EAAE,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,EAAE,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