@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.
- package/CHANGELOG.md +114 -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/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/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
|
@@ -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
|
+
}
|