@outseta/react 0.2.0 → 0.2.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/package.json +2 -2
- package/src/generated/activity/activity.ts +395 -0
- package/src/generated/billing/billing.ts +1333 -0
- package/src/generated/crm/crm.ts +1528 -63
- package/src/generated/email/email.ts +992 -0
- package/src/generated/outsetaAPI.schemas.ts +334 -27
- package/src/generated/support/support.ts +478 -1
- package/src/mutator.ts +32 -11
|
@@ -0,0 +1,992 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* Generated by orval v7.21.0 🍺
|
|
4
|
+
* Do not edit manually.
|
|
5
|
+
* Outseta API
|
|
6
|
+
* # Outseta REST API
|
|
7
|
+
|
|
8
|
+
The Outseta REST API enables you to perform a variety of powerful tasks such as creating and updating people, accounts, subscriptions, and invoices. Outseta uses standard HTTP protocols within a compliant architecture that is simple to integrate. You can use the API both on the client or the server side; see the authentication section below for each scenario.
|
|
9
|
+
|
|
10
|
+
**Base URL:** `https://{your-domain}.outseta.com/api/v1/`
|
|
11
|
+
|
|
12
|
+
## API Guidelines
|
|
13
|
+
|
|
14
|
+
1. The API will only respond to secured communication done over **HTTPS**. HTTP requests will be sent a `301` redirect to the corresponding HTTPS resource.
|
|
15
|
+
2. Responses are sent in **JSON** format. In case the API request results in an error, it is represented by an `"error": {}` key in the JSON response.
|
|
16
|
+
3. The request method (verb) determines the nature of the action: **GET** fetches data, **POST** creates new records, **PUT** updates existing records.
|
|
17
|
+
4. The API responds with appropriate **HTTP status codes** for all requests.
|
|
18
|
+
5. Use `donotlog=1` as a query parameter on any API call where you don't want the action to be logged in the activity log.
|
|
19
|
+
|
|
20
|
+
## Authentication
|
|
21
|
+
|
|
22
|
+
All API requests require authentication via one of two methods:
|
|
23
|
+
|
|
24
|
+
### Server-Side (API Keys)
|
|
25
|
+
|
|
26
|
+
Use API keys for server-to-server integrations. Create keys at **Settings > Integrations > API Keys**. Make sure to record the secret key when you create it.
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
Authorization: Outseta {api_key}:{api_secret}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Example:**
|
|
33
|
+
```
|
|
34
|
+
Authorization: Outseta ce08fd5a-e1ee-4472-9c5f-b7575d8369b2:74fc1d2242a4eb7336d34b0e40cfbc5f
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
> **Warning:** Never expose API keys in client-side code. The API key and secret combined give full access to all data in your account.
|
|
38
|
+
|
|
39
|
+
### Client-Side (Bearer Token)
|
|
40
|
+
|
|
41
|
+
Do **not** use API keys on the client side — they can be easily copied. Instead, obtain a JWT access token by calling the `POST /tokens` endpoint from the server side with your credentials, then use it on the client:
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
Authorization: bearer {access_token}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Tokens are JWTs containing claims such as `PersonUid`, `AccountUid`, and subscription details. Tokens expire after approximately one year.
|
|
48
|
+
|
|
49
|
+
Verify tokens server-side using Outseta's [JWKS endpoint](https://{your-domain}.outseta.com/.well-known/jwks.json).
|
|
50
|
+
|
|
51
|
+
## Field Selection
|
|
52
|
+
|
|
53
|
+
When you make an API request, you'll automatically get all the basic information from the main object and its immediate child objects. Referenced objects beyond the first level are returned as `null`.
|
|
54
|
+
|
|
55
|
+
Change this behavior using the `fields` query parameter:
|
|
56
|
+
|
|
57
|
+
- **Go deeper** — Request fields lower down in the object tree: `?fields=CurrentSubscription.Plan.*`
|
|
58
|
+
- **Go lighter** — Request only the essentials for faster performance: `?fields=Uid,Name`
|
|
59
|
+
- **Combination** — `?fields=Uid,Name,CurrentSubscription.Plan.Uid`
|
|
60
|
+
- **Wildcard** — Use `*` to get all fields in an object: `?fields=*` or `?fields=CurrentSubscription.Plan.*`
|
|
61
|
+
|
|
62
|
+
> **Tip:** When expanding nested paths, include `*` and intermediate path segments (e.g., `PersonAccount.*`) to preserve root-level and intermediate fields.
|
|
63
|
+
|
|
64
|
+
**Examples:**
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
# Get the current subscription plan UID for an account
|
|
68
|
+
GET /crm/accounts/{uid}?fields=CurrentSubscription.Plan.Uid
|
|
69
|
+
|
|
70
|
+
# Get the account UID and plan UID for a list of accounts
|
|
71
|
+
GET /crm/accounts?fields=Uid,CurrentSubscription.Plan.Uid
|
|
72
|
+
|
|
73
|
+
# Get the full plan object for an account's current subscription
|
|
74
|
+
GET /crm/accounts/{uid}?fields=CurrentSubscription.Plan.*
|
|
75
|
+
|
|
76
|
+
# Get a person with their account and subscription info
|
|
77
|
+
GET /crm/people/{uid}?fields=Uid,PersonAccount.Account.CurrentSubscription.Plan.Uid
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
If your request includes fields from a child object you will be limited to retrieving **25 items** per page. The maximum for requests not expanding child object fields is **100 items**.
|
|
81
|
+
|
|
82
|
+
## Pagination
|
|
83
|
+
|
|
84
|
+
List endpoints return paginated results with a `metadata` object and an `items` array:
|
|
85
|
+
|
|
86
|
+
```json
|
|
87
|
+
{
|
|
88
|
+
"metadata": {
|
|
89
|
+
"limit": 25,
|
|
90
|
+
"offset": 0,
|
|
91
|
+
"total": 142
|
|
92
|
+
},
|
|
93
|
+
"items": [ ... ]
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
| Parameter | Type | Default | Description |
|
|
98
|
+
|-----------|------|---------|-------------|
|
|
99
|
+
| `offset` | integer | `0` | Page number (zero-based) |
|
|
100
|
+
| `limit` | integer | `25` | Maximum number of records per page |
|
|
101
|
+
|
|
102
|
+
**Examples:**
|
|
103
|
+
```
|
|
104
|
+
?offset=0&limit=20 # returns results 1-20
|
|
105
|
+
?offset=1&limit=20 # returns results 21-40
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Sorting
|
|
109
|
+
|
|
110
|
+
Sort results using the `orderBy` parameter with a property name and direction:
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
?orderBy=PropertyName+DESC
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Filtering
|
|
117
|
+
|
|
118
|
+
Filter results by passing entity properties as query parameters.
|
|
119
|
+
|
|
120
|
+
### Basic Filtering
|
|
121
|
+
|
|
122
|
+
Filter on any field using the field name as a query parameter:
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
GET /crm/people?Email=john@example.com
|
|
126
|
+
GET /crm/accounts?AccountStage=2
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Wildcard Matching
|
|
130
|
+
|
|
131
|
+
| Pattern | Match Type | Example |
|
|
132
|
+
|---------|-----------|---------|
|
|
133
|
+
| `*value` | Ends with | `?Email=*@example.com` |
|
|
134
|
+
| `value*` | Starts with | `?Name=Acme*` |
|
|
135
|
+
| `*value*` | Contains | `?Name=*corp*` |
|
|
136
|
+
|
|
137
|
+
### Comparison Operators
|
|
138
|
+
|
|
139
|
+
For advanced filtering, append comparison operators to field names:
|
|
140
|
+
|
|
141
|
+
| Operator | Description | Example |
|
|
142
|
+
|----------|-------------|---------|
|
|
143
|
+
| `__gt` | Greater than | `Created__gt=2024-01-01` |
|
|
144
|
+
| `__gte` | Greater than or equal | `Amount__gte=100` |
|
|
145
|
+
| `__lt` | Less than | `Created__lt=2024-12-31` |
|
|
146
|
+
| `__lte` | Less than or equal | `Amount__lte=500` |
|
|
147
|
+
| `__ne` | Not equal | `Status__ne=Active` |
|
|
148
|
+
| `__isnull` | Is null (true/false) | `ProfileImageS3Url__isnull=true` |
|
|
149
|
+
|
|
150
|
+
**Examples:**
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
# Date filtering
|
|
154
|
+
GET /crm/accounts?Created__gt=2024-01-01
|
|
155
|
+
GET /billing/subscriptions?EndDate__lt=2024-08-01
|
|
156
|
+
|
|
157
|
+
# Numeric filtering
|
|
158
|
+
GET /billing/invoices?Amount__gte=1000
|
|
159
|
+
|
|
160
|
+
# Null value filtering
|
|
161
|
+
GET /crm/people?ProfileImageS3Url__isnull=true
|
|
162
|
+
|
|
163
|
+
# Multiple filters combined with field selection
|
|
164
|
+
GET /billing/subscriptions?StartDate__gte=2024-01-01&Rate__lt=100&DiscountCode__isnull=false&fields=Uid,Amount,StartDate,DiscountCode,Plan.Name
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Account Billing Stages
|
|
168
|
+
|
|
169
|
+
Account stages reflect the financial standing of each account and are not directly editable — they change automatically based on subscription activity.
|
|
170
|
+
|
|
171
|
+
| Value | Stage | Description |
|
|
172
|
+
|-------|-------|-------------|
|
|
173
|
+
| `2` | Trialing | Currently on a free trial or free plan |
|
|
174
|
+
| `3` | Subscribing | Active paid subscription (contributes to MRR) |
|
|
175
|
+
| `4` | Canceling | Customer has indicated intent to cancel |
|
|
176
|
+
| `5` | Expired | Subscription has ended after cancellation |
|
|
177
|
+
| `6` | Trial Expired | Free trial ended without conversion to paid |
|
|
178
|
+
|
|
179
|
+
Filter by stage: `GET /crm/accounts?AccountStage=3` returns all actively subscribing accounts.
|
|
180
|
+
|
|
181
|
+
## Webhooks
|
|
182
|
+
|
|
183
|
+
Use **Activity Notifications** to receive real-time callbacks when events occur in Outseta. Configure webhooks at **Settings > Notifications**.
|
|
184
|
+
|
|
185
|
+
Common events include:
|
|
186
|
+
- `Person Created` / `Person Updated`
|
|
187
|
+
- `Account Created` / `Account Updated`
|
|
188
|
+
- `Subscription Created` / `Subscription Updated`
|
|
189
|
+
|
|
190
|
+
Always verify webhook signatures using the SHA256 secret provided in the Outseta dashboard.
|
|
191
|
+
|
|
192
|
+
## Error Responses
|
|
193
|
+
|
|
194
|
+
| Status Code | Description |
|
|
195
|
+
|-------------|-------------|
|
|
196
|
+
| `200` | Success |
|
|
197
|
+
| `301` | Redirect — HTTP requests are redirected to HTTPS |
|
|
198
|
+
| `400` | Bad request — invalid parameters or Uid format |
|
|
199
|
+
| `401` | Unauthorized — missing or invalid authentication |
|
|
200
|
+
| `404` | Entity not found |
|
|
201
|
+
| `4XX` / `5XX` | Client or server error |
|
|
202
|
+
|
|
203
|
+
Validation errors return a JSON body with `ErrorMessage` and `PropertyName` fields:
|
|
204
|
+
|
|
205
|
+
```json
|
|
206
|
+
{
|
|
207
|
+
"ErrorMessage": "Invalid company email",
|
|
208
|
+
"PropertyName": "Email"
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Rate Limits
|
|
213
|
+
|
|
214
|
+
Requests authorized by an API Key should not exceed **4 requests/second**.
|
|
215
|
+
|
|
216
|
+
## Support
|
|
217
|
+
|
|
218
|
+
For help regarding the Outseta API please email [support@outseta.com](mailto:support@outseta.com).
|
|
219
|
+
|
|
220
|
+
* OpenAPI spec version: v1
|
|
221
|
+
*/
|
|
222
|
+
import {
|
|
223
|
+
useMutation,
|
|
224
|
+
useQuery
|
|
225
|
+
} from '@tanstack/react-query';
|
|
226
|
+
import type {
|
|
227
|
+
MutationFunction,
|
|
228
|
+
QueryFunction,
|
|
229
|
+
QueryKey,
|
|
230
|
+
UseMutationOptions,
|
|
231
|
+
UseMutationResult,
|
|
232
|
+
UseQueryOptions,
|
|
233
|
+
UseQueryResult
|
|
234
|
+
} from '@tanstack/react-query';
|
|
235
|
+
|
|
236
|
+
import type {
|
|
237
|
+
BroadcastCampaign,
|
|
238
|
+
CampaignAddBroadcastEmailBody,
|
|
239
|
+
CampaignSendTestCampaignEmailBody,
|
|
240
|
+
CampaignUpdateBroadcastEmailBody,
|
|
241
|
+
EmailListAddSubscriptionBody,
|
|
242
|
+
EmailListGetAllSubscriptionsParams,
|
|
243
|
+
EmailListPerson
|
|
244
|
+
} from '../outsetaAPI.schemas';
|
|
245
|
+
|
|
246
|
+
import { customFetch } from '../../mutator';
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* @summary Retrieves all non-archived broadcast campaigns.
|
|
255
|
+
*/
|
|
256
|
+
export const campaignGetAllBroadcastEmails = (
|
|
257
|
+
|
|
258
|
+
options?: SecondParameter<typeof customFetch>,signal?: AbortSignal
|
|
259
|
+
) => {
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
return customFetch<BroadcastCampaign[]>(
|
|
263
|
+
{url: `/api/v1/email/campaigns/broadcasts`, method: 'GET', signal
|
|
264
|
+
},
|
|
265
|
+
options);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
export const getCampaignGetAllBroadcastEmailsQueryKey = () => {
|
|
272
|
+
return [
|
|
273
|
+
`/api/v1/email/campaigns/broadcasts`
|
|
274
|
+
] as const;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
export const getCampaignGetAllBroadcastEmailsQueryOptions = <TData = Awaited<ReturnType<typeof campaignGetAllBroadcastEmails>>, TError = void>( options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof campaignGetAllBroadcastEmails>>, TError, TData>, request?: SecondParameter<typeof customFetch>}
|
|
279
|
+
) => {
|
|
280
|
+
|
|
281
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
282
|
+
|
|
283
|
+
const queryKey = queryOptions?.queryKey ?? getCampaignGetAllBroadcastEmailsQueryKey();
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof campaignGetAllBroadcastEmails>>> = ({ signal }) => campaignGetAllBroadcastEmails(requestOptions, signal);
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof campaignGetAllBroadcastEmails>>, TError, TData> & { queryKey: QueryKey }
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export type CampaignGetAllBroadcastEmailsQueryResult = NonNullable<Awaited<ReturnType<typeof campaignGetAllBroadcastEmails>>>
|
|
297
|
+
export type CampaignGetAllBroadcastEmailsQueryError = void
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* @summary Retrieves all non-archived broadcast campaigns.
|
|
302
|
+
*/
|
|
303
|
+
|
|
304
|
+
export function useCampaignGetAllBroadcastEmails<TData = Awaited<ReturnType<typeof campaignGetAllBroadcastEmails>>, TError = void>(
|
|
305
|
+
options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof campaignGetAllBroadcastEmails>>, TError, TData>, request?: SecondParameter<typeof customFetch>}
|
|
306
|
+
|
|
307
|
+
): UseQueryResult<TData, TError> & { queryKey: QueryKey } {
|
|
308
|
+
|
|
309
|
+
const queryOptions = getCampaignGetAllBroadcastEmailsQueryOptions(options)
|
|
310
|
+
|
|
311
|
+
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
312
|
+
|
|
313
|
+
query.queryKey = queryOptions.queryKey ;
|
|
314
|
+
|
|
315
|
+
return query;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* @summary Creates a new broadcast campaign. To copy an existing broadcast, retrieve it and pass its
|
|
323
|
+
data as the request body — the Uid, SendDateTime, and message counts are automatically reset.
|
|
324
|
+
Recipients can be specified using EmailListUids and SegmentUids instead of populating
|
|
325
|
+
RecipientData directly. If both are provided, they are merged.
|
|
326
|
+
*/
|
|
327
|
+
export const campaignAddBroadcastEmail = (
|
|
328
|
+
campaignAddBroadcastEmailBody: CampaignAddBroadcastEmailBody,
|
|
329
|
+
options?: SecondParameter<typeof customFetch>,signal?: AbortSignal
|
|
330
|
+
) => {
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
return customFetch<BroadcastCampaign>(
|
|
334
|
+
{url: `/api/v1/email/campaigns/broadcasts`, method: 'POST',
|
|
335
|
+
headers: {'Content-Type': 'application/json', },
|
|
336
|
+
data: campaignAddBroadcastEmailBody, signal
|
|
337
|
+
},
|
|
338
|
+
options);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
export const getCampaignAddBroadcastEmailMutationOptions = <TError = void,
|
|
344
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof campaignAddBroadcastEmail>>, TError,{data: CampaignAddBroadcastEmailBody}, TContext>, request?: SecondParameter<typeof customFetch>}
|
|
345
|
+
): UseMutationOptions<Awaited<ReturnType<typeof campaignAddBroadcastEmail>>, TError,{data: CampaignAddBroadcastEmailBody}, TContext> => {
|
|
346
|
+
|
|
347
|
+
const mutationKey = ['campaignAddBroadcastEmail'];
|
|
348
|
+
const {mutation: mutationOptions, request: requestOptions} = options ?
|
|
349
|
+
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
|
|
350
|
+
options
|
|
351
|
+
: {...options, mutation: {...options.mutation, mutationKey}}
|
|
352
|
+
: {mutation: { mutationKey, }, request: undefined};
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
const mutationFn: MutationFunction<Awaited<ReturnType<typeof campaignAddBroadcastEmail>>, {data: CampaignAddBroadcastEmailBody}> = (props) => {
|
|
358
|
+
const {data} = props ?? {};
|
|
359
|
+
|
|
360
|
+
return campaignAddBroadcastEmail(data,requestOptions)
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
return { mutationFn, ...mutationOptions }}
|
|
367
|
+
|
|
368
|
+
export type CampaignAddBroadcastEmailMutationResult = NonNullable<Awaited<ReturnType<typeof campaignAddBroadcastEmail>>>
|
|
369
|
+
export type CampaignAddBroadcastEmailMutationBody = CampaignAddBroadcastEmailBody
|
|
370
|
+
export type CampaignAddBroadcastEmailMutationError = void
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* @summary Creates a new broadcast campaign. To copy an existing broadcast, retrieve it and pass its
|
|
374
|
+
data as the request body — the Uid, SendDateTime, and message counts are automatically reset.
|
|
375
|
+
Recipients can be specified using EmailListUids and SegmentUids instead of populating
|
|
376
|
+
RecipientData directly. If both are provided, they are merged.
|
|
377
|
+
*/
|
|
378
|
+
export const useCampaignAddBroadcastEmail = <TError = void,
|
|
379
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof campaignAddBroadcastEmail>>, TError,{data: CampaignAddBroadcastEmailBody}, TContext>, request?: SecondParameter<typeof customFetch>}
|
|
380
|
+
): UseMutationResult<
|
|
381
|
+
Awaited<ReturnType<typeof campaignAddBroadcastEmail>>,
|
|
382
|
+
TError,
|
|
383
|
+
{data: CampaignAddBroadcastEmailBody},
|
|
384
|
+
TContext
|
|
385
|
+
> => {
|
|
386
|
+
|
|
387
|
+
const mutationOptions = getCampaignAddBroadcastEmailMutationOptions(options);
|
|
388
|
+
|
|
389
|
+
return useMutation(mutationOptions);
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* @summary Retrieves a single broadcast campaign by its Uid.
|
|
393
|
+
*/
|
|
394
|
+
export const campaignGetBroadcastEmail = (
|
|
395
|
+
broadcastCampaignUid: string | null,
|
|
396
|
+
options?: SecondParameter<typeof customFetch>,signal?: AbortSignal
|
|
397
|
+
) => {
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
return customFetch<BroadcastCampaign>(
|
|
401
|
+
{url: `/api/v1/email/campaigns/broadcasts/${broadcastCampaignUid}`, method: 'GET', signal
|
|
402
|
+
},
|
|
403
|
+
options);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
export const getCampaignGetBroadcastEmailQueryKey = (broadcastCampaignUid?: string | null,) => {
|
|
410
|
+
return [
|
|
411
|
+
`/api/v1/email/campaigns/broadcasts/${broadcastCampaignUid}`
|
|
412
|
+
] as const;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
export const getCampaignGetBroadcastEmailQueryOptions = <TData = Awaited<ReturnType<typeof campaignGetBroadcastEmail>>, TError = void>(broadcastCampaignUid: string | null, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof campaignGetBroadcastEmail>>, TError, TData>, request?: SecondParameter<typeof customFetch>}
|
|
417
|
+
) => {
|
|
418
|
+
|
|
419
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
420
|
+
|
|
421
|
+
const queryKey = queryOptions?.queryKey ?? getCampaignGetBroadcastEmailQueryKey(broadcastCampaignUid);
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof campaignGetBroadcastEmail>>> = ({ signal }) => campaignGetBroadcastEmail(broadcastCampaignUid, requestOptions, signal);
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
return { queryKey, queryFn, enabled: !!(broadcastCampaignUid), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof campaignGetBroadcastEmail>>, TError, TData> & { queryKey: QueryKey }
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
export type CampaignGetBroadcastEmailQueryResult = NonNullable<Awaited<ReturnType<typeof campaignGetBroadcastEmail>>>
|
|
435
|
+
export type CampaignGetBroadcastEmailQueryError = void
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* @summary Retrieves a single broadcast campaign by its Uid.
|
|
440
|
+
*/
|
|
441
|
+
|
|
442
|
+
export function useCampaignGetBroadcastEmail<TData = Awaited<ReturnType<typeof campaignGetBroadcastEmail>>, TError = void>(
|
|
443
|
+
broadcastCampaignUid: string | null, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof campaignGetBroadcastEmail>>, TError, TData>, request?: SecondParameter<typeof customFetch>}
|
|
444
|
+
|
|
445
|
+
): UseQueryResult<TData, TError> & { queryKey: QueryKey } {
|
|
446
|
+
|
|
447
|
+
const queryOptions = getCampaignGetBroadcastEmailQueryOptions(broadcastCampaignUid,options)
|
|
448
|
+
|
|
449
|
+
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
450
|
+
|
|
451
|
+
query.queryKey = queryOptions.queryKey ;
|
|
452
|
+
|
|
453
|
+
return query;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* @summary Updates a broadcast campaign. Setting SendDateTime to a future date schedules the broadcast
|
|
461
|
+
for sending and its status changes to Pending. Clearing SendDateTime unschedules the broadcast.
|
|
462
|
+
Recipients can be specified using EmailListUids and SegmentUids instead of populating
|
|
463
|
+
RecipientData directly. If both are provided, they are merged.
|
|
464
|
+
*/
|
|
465
|
+
export const campaignUpdateBroadcastEmail = (
|
|
466
|
+
broadcastCampaignUid: string | null,
|
|
467
|
+
campaignUpdateBroadcastEmailBody: CampaignUpdateBroadcastEmailBody,
|
|
468
|
+
options?: SecondParameter<typeof customFetch>,) => {
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
return customFetch<BroadcastCampaign>(
|
|
472
|
+
{url: `/api/v1/email/campaigns/broadcasts/${broadcastCampaignUid}`, method: 'PUT',
|
|
473
|
+
headers: {'Content-Type': 'application/json', },
|
|
474
|
+
data: campaignUpdateBroadcastEmailBody
|
|
475
|
+
},
|
|
476
|
+
options);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
export const getCampaignUpdateBroadcastEmailMutationOptions = <TError = void,
|
|
482
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof campaignUpdateBroadcastEmail>>, TError,{broadcastCampaignUid: string | null;data: CampaignUpdateBroadcastEmailBody}, TContext>, request?: SecondParameter<typeof customFetch>}
|
|
483
|
+
): UseMutationOptions<Awaited<ReturnType<typeof campaignUpdateBroadcastEmail>>, TError,{broadcastCampaignUid: string | null;data: CampaignUpdateBroadcastEmailBody}, TContext> => {
|
|
484
|
+
|
|
485
|
+
const mutationKey = ['campaignUpdateBroadcastEmail'];
|
|
486
|
+
const {mutation: mutationOptions, request: requestOptions} = options ?
|
|
487
|
+
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
|
|
488
|
+
options
|
|
489
|
+
: {...options, mutation: {...options.mutation, mutationKey}}
|
|
490
|
+
: {mutation: { mutationKey, }, request: undefined};
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
const mutationFn: MutationFunction<Awaited<ReturnType<typeof campaignUpdateBroadcastEmail>>, {broadcastCampaignUid: string | null;data: CampaignUpdateBroadcastEmailBody}> = (props) => {
|
|
496
|
+
const {broadcastCampaignUid,data} = props ?? {};
|
|
497
|
+
|
|
498
|
+
return campaignUpdateBroadcastEmail(broadcastCampaignUid,data,requestOptions)
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
return { mutationFn, ...mutationOptions }}
|
|
505
|
+
|
|
506
|
+
export type CampaignUpdateBroadcastEmailMutationResult = NonNullable<Awaited<ReturnType<typeof campaignUpdateBroadcastEmail>>>
|
|
507
|
+
export type CampaignUpdateBroadcastEmailMutationBody = CampaignUpdateBroadcastEmailBody
|
|
508
|
+
export type CampaignUpdateBroadcastEmailMutationError = void
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* @summary Updates a broadcast campaign. Setting SendDateTime to a future date schedules the broadcast
|
|
512
|
+
for sending and its status changes to Pending. Clearing SendDateTime unschedules the broadcast.
|
|
513
|
+
Recipients can be specified using EmailListUids and SegmentUids instead of populating
|
|
514
|
+
RecipientData directly. If both are provided, they are merged.
|
|
515
|
+
*/
|
|
516
|
+
export const useCampaignUpdateBroadcastEmail = <TError = void,
|
|
517
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof campaignUpdateBroadcastEmail>>, TError,{broadcastCampaignUid: string | null;data: CampaignUpdateBroadcastEmailBody}, TContext>, request?: SecondParameter<typeof customFetch>}
|
|
518
|
+
): UseMutationResult<
|
|
519
|
+
Awaited<ReturnType<typeof campaignUpdateBroadcastEmail>>,
|
|
520
|
+
TError,
|
|
521
|
+
{broadcastCampaignUid: string | null;data: CampaignUpdateBroadcastEmailBody},
|
|
522
|
+
TContext
|
|
523
|
+
> => {
|
|
524
|
+
|
|
525
|
+
const mutationOptions = getCampaignUpdateBroadcastEmailMutationOptions(options);
|
|
526
|
+
|
|
527
|
+
return useMutation(mutationOptions);
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* @summary Deletes a broadcast campaign. Only campaigns in Draft or Pending status can be deleted.
|
|
531
|
+
Campaigns that have been processed should be archived instead.
|
|
532
|
+
*/
|
|
533
|
+
export const campaignDeleteBroadcastCampaign = (
|
|
534
|
+
broadcastCampaignUid: string | null,
|
|
535
|
+
options?: SecondParameter<typeof customFetch>,) => {
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
return customFetch<Blob>(
|
|
539
|
+
{url: `/api/v1/email/campaigns/broadcasts/${broadcastCampaignUid}`, method: 'DELETE',
|
|
540
|
+
responseType: 'blob'
|
|
541
|
+
},
|
|
542
|
+
options);
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
export const getCampaignDeleteBroadcastCampaignMutationOptions = <TError = void,
|
|
548
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof campaignDeleteBroadcastCampaign>>, TError,{broadcastCampaignUid: string | null}, TContext>, request?: SecondParameter<typeof customFetch>}
|
|
549
|
+
): UseMutationOptions<Awaited<ReturnType<typeof campaignDeleteBroadcastCampaign>>, TError,{broadcastCampaignUid: string | null}, TContext> => {
|
|
550
|
+
|
|
551
|
+
const mutationKey = ['campaignDeleteBroadcastCampaign'];
|
|
552
|
+
const {mutation: mutationOptions, request: requestOptions} = options ?
|
|
553
|
+
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
|
|
554
|
+
options
|
|
555
|
+
: {...options, mutation: {...options.mutation, mutationKey}}
|
|
556
|
+
: {mutation: { mutationKey, }, request: undefined};
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
const mutationFn: MutationFunction<Awaited<ReturnType<typeof campaignDeleteBroadcastCampaign>>, {broadcastCampaignUid: string | null}> = (props) => {
|
|
562
|
+
const {broadcastCampaignUid} = props ?? {};
|
|
563
|
+
|
|
564
|
+
return campaignDeleteBroadcastCampaign(broadcastCampaignUid,requestOptions)
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
return { mutationFn, ...mutationOptions }}
|
|
571
|
+
|
|
572
|
+
export type CampaignDeleteBroadcastCampaignMutationResult = NonNullable<Awaited<ReturnType<typeof campaignDeleteBroadcastCampaign>>>
|
|
573
|
+
|
|
574
|
+
export type CampaignDeleteBroadcastCampaignMutationError = void
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* @summary Deletes a broadcast campaign. Only campaigns in Draft or Pending status can be deleted.
|
|
578
|
+
Campaigns that have been processed should be archived instead.
|
|
579
|
+
*/
|
|
580
|
+
export const useCampaignDeleteBroadcastCampaign = <TError = void,
|
|
581
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof campaignDeleteBroadcastCampaign>>, TError,{broadcastCampaignUid: string | null}, TContext>, request?: SecondParameter<typeof customFetch>}
|
|
582
|
+
): UseMutationResult<
|
|
583
|
+
Awaited<ReturnType<typeof campaignDeleteBroadcastCampaign>>,
|
|
584
|
+
TError,
|
|
585
|
+
{broadcastCampaignUid: string | null},
|
|
586
|
+
TContext
|
|
587
|
+
> => {
|
|
588
|
+
|
|
589
|
+
const mutationOptions = getCampaignDeleteBroadcastCampaignMutationOptions(options);
|
|
590
|
+
|
|
591
|
+
return useMutation(mutationOptions);
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* @summary Unschedules a pending broadcast campaign, reverting its status to Draft.
|
|
595
|
+
*/
|
|
596
|
+
export const campaignUnscheduleBroadcastEmail = (
|
|
597
|
+
broadcastCampaignUid: string | null,
|
|
598
|
+
options?: SecondParameter<typeof customFetch>,signal?: AbortSignal
|
|
599
|
+
) => {
|
|
600
|
+
|
|
601
|
+
|
|
602
|
+
return customFetch<BroadcastCampaign>(
|
|
603
|
+
{url: `/api/v1/email/campaigns/broadcasts/${broadcastCampaignUid}/unschedule`, method: 'POST', signal
|
|
604
|
+
},
|
|
605
|
+
options);
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
|
|
609
|
+
|
|
610
|
+
export const getCampaignUnscheduleBroadcastEmailMutationOptions = <TError = void,
|
|
611
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof campaignUnscheduleBroadcastEmail>>, TError,{broadcastCampaignUid: string | null}, TContext>, request?: SecondParameter<typeof customFetch>}
|
|
612
|
+
): UseMutationOptions<Awaited<ReturnType<typeof campaignUnscheduleBroadcastEmail>>, TError,{broadcastCampaignUid: string | null}, TContext> => {
|
|
613
|
+
|
|
614
|
+
const mutationKey = ['campaignUnscheduleBroadcastEmail'];
|
|
615
|
+
const {mutation: mutationOptions, request: requestOptions} = options ?
|
|
616
|
+
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
|
|
617
|
+
options
|
|
618
|
+
: {...options, mutation: {...options.mutation, mutationKey}}
|
|
619
|
+
: {mutation: { mutationKey, }, request: undefined};
|
|
620
|
+
|
|
621
|
+
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
const mutationFn: MutationFunction<Awaited<ReturnType<typeof campaignUnscheduleBroadcastEmail>>, {broadcastCampaignUid: string | null}> = (props) => {
|
|
625
|
+
const {broadcastCampaignUid} = props ?? {};
|
|
626
|
+
|
|
627
|
+
return campaignUnscheduleBroadcastEmail(broadcastCampaignUid,requestOptions)
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
|
|
633
|
+
return { mutationFn, ...mutationOptions }}
|
|
634
|
+
|
|
635
|
+
export type CampaignUnscheduleBroadcastEmailMutationResult = NonNullable<Awaited<ReturnType<typeof campaignUnscheduleBroadcastEmail>>>
|
|
636
|
+
|
|
637
|
+
export type CampaignUnscheduleBroadcastEmailMutationError = void
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* @summary Unschedules a pending broadcast campaign, reverting its status to Draft.
|
|
641
|
+
*/
|
|
642
|
+
export const useCampaignUnscheduleBroadcastEmail = <TError = void,
|
|
643
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof campaignUnscheduleBroadcastEmail>>, TError,{broadcastCampaignUid: string | null}, TContext>, request?: SecondParameter<typeof customFetch>}
|
|
644
|
+
): UseMutationResult<
|
|
645
|
+
Awaited<ReturnType<typeof campaignUnscheduleBroadcastEmail>>,
|
|
646
|
+
TError,
|
|
647
|
+
{broadcastCampaignUid: string | null},
|
|
648
|
+
TContext
|
|
649
|
+
> => {
|
|
650
|
+
|
|
651
|
+
const mutationOptions = getCampaignUnscheduleBroadcastEmailMutationOptions(options);
|
|
652
|
+
|
|
653
|
+
return useMutation(mutationOptions);
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* @summary Archives a broadcast campaign. Archived campaigns are excluded from the default list results.
|
|
657
|
+
*/
|
|
658
|
+
export const campaignArchiveBroadcastCampaign = (
|
|
659
|
+
broadcastCampaignUid: string | null,
|
|
660
|
+
options?: SecondParameter<typeof customFetch>,signal?: AbortSignal
|
|
661
|
+
) => {
|
|
662
|
+
|
|
663
|
+
|
|
664
|
+
return customFetch<Blob>(
|
|
665
|
+
{url: `/api/v1/email/campaigns/broadcasts/${broadcastCampaignUid}/archive`, method: 'POST',
|
|
666
|
+
responseType: 'blob', signal
|
|
667
|
+
},
|
|
668
|
+
options);
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
|
|
672
|
+
|
|
673
|
+
export const getCampaignArchiveBroadcastCampaignMutationOptions = <TError = void,
|
|
674
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof campaignArchiveBroadcastCampaign>>, TError,{broadcastCampaignUid: string | null}, TContext>, request?: SecondParameter<typeof customFetch>}
|
|
675
|
+
): UseMutationOptions<Awaited<ReturnType<typeof campaignArchiveBroadcastCampaign>>, TError,{broadcastCampaignUid: string | null}, TContext> => {
|
|
676
|
+
|
|
677
|
+
const mutationKey = ['campaignArchiveBroadcastCampaign'];
|
|
678
|
+
const {mutation: mutationOptions, request: requestOptions} = options ?
|
|
679
|
+
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
|
|
680
|
+
options
|
|
681
|
+
: {...options, mutation: {...options.mutation, mutationKey}}
|
|
682
|
+
: {mutation: { mutationKey, }, request: undefined};
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
|
|
687
|
+
const mutationFn: MutationFunction<Awaited<ReturnType<typeof campaignArchiveBroadcastCampaign>>, {broadcastCampaignUid: string | null}> = (props) => {
|
|
688
|
+
const {broadcastCampaignUid} = props ?? {};
|
|
689
|
+
|
|
690
|
+
return campaignArchiveBroadcastCampaign(broadcastCampaignUid,requestOptions)
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
|
|
694
|
+
|
|
695
|
+
|
|
696
|
+
return { mutationFn, ...mutationOptions }}
|
|
697
|
+
|
|
698
|
+
export type CampaignArchiveBroadcastCampaignMutationResult = NonNullable<Awaited<ReturnType<typeof campaignArchiveBroadcastCampaign>>>
|
|
699
|
+
|
|
700
|
+
export type CampaignArchiveBroadcastCampaignMutationError = void
|
|
701
|
+
|
|
702
|
+
/**
|
|
703
|
+
* @summary Archives a broadcast campaign. Archived campaigns are excluded from the default list results.
|
|
704
|
+
*/
|
|
705
|
+
export const useCampaignArchiveBroadcastCampaign = <TError = void,
|
|
706
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof campaignArchiveBroadcastCampaign>>, TError,{broadcastCampaignUid: string | null}, TContext>, request?: SecondParameter<typeof customFetch>}
|
|
707
|
+
): UseMutationResult<
|
|
708
|
+
Awaited<ReturnType<typeof campaignArchiveBroadcastCampaign>>,
|
|
709
|
+
TError,
|
|
710
|
+
{broadcastCampaignUid: string | null},
|
|
711
|
+
TContext
|
|
712
|
+
> => {
|
|
713
|
+
|
|
714
|
+
const mutationOptions = getCampaignArchiveBroadcastCampaignMutationOptions(options);
|
|
715
|
+
|
|
716
|
+
return useMutation(mutationOptions);
|
|
717
|
+
}
|
|
718
|
+
/**
|
|
719
|
+
* @summary Sends a test email for a broadcast campaign to the logged-in user and optionally to additional
|
|
720
|
+
recipients. Additional recipients are specified as a list of person Uids and must belong to the
|
|
721
|
+
same account as the logged-in user.
|
|
722
|
+
*/
|
|
723
|
+
export const campaignSendTestCampaignEmail = (
|
|
724
|
+
campaignSendTestCampaignEmailBody: CampaignSendTestCampaignEmailBody,
|
|
725
|
+
options?: SecondParameter<typeof customFetch>,signal?: AbortSignal
|
|
726
|
+
) => {
|
|
727
|
+
|
|
728
|
+
|
|
729
|
+
return customFetch<Blob>(
|
|
730
|
+
{url: `/api/v1/email/campaigns/broadcasts/sendtestemail`, method: 'POST',
|
|
731
|
+
headers: {'Content-Type': 'application/json', },
|
|
732
|
+
data: campaignSendTestCampaignEmailBody,
|
|
733
|
+
responseType: 'blob', signal
|
|
734
|
+
},
|
|
735
|
+
options);
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
|
|
739
|
+
|
|
740
|
+
export const getCampaignSendTestCampaignEmailMutationOptions = <TError = void,
|
|
741
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof campaignSendTestCampaignEmail>>, TError,{data: CampaignSendTestCampaignEmailBody}, TContext>, request?: SecondParameter<typeof customFetch>}
|
|
742
|
+
): UseMutationOptions<Awaited<ReturnType<typeof campaignSendTestCampaignEmail>>, TError,{data: CampaignSendTestCampaignEmailBody}, TContext> => {
|
|
743
|
+
|
|
744
|
+
const mutationKey = ['campaignSendTestCampaignEmail'];
|
|
745
|
+
const {mutation: mutationOptions, request: requestOptions} = options ?
|
|
746
|
+
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
|
|
747
|
+
options
|
|
748
|
+
: {...options, mutation: {...options.mutation, mutationKey}}
|
|
749
|
+
: {mutation: { mutationKey, }, request: undefined};
|
|
750
|
+
|
|
751
|
+
|
|
752
|
+
|
|
753
|
+
|
|
754
|
+
const mutationFn: MutationFunction<Awaited<ReturnType<typeof campaignSendTestCampaignEmail>>, {data: CampaignSendTestCampaignEmailBody}> = (props) => {
|
|
755
|
+
const {data} = props ?? {};
|
|
756
|
+
|
|
757
|
+
return campaignSendTestCampaignEmail(data,requestOptions)
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
|
|
761
|
+
|
|
762
|
+
|
|
763
|
+
return { mutationFn, ...mutationOptions }}
|
|
764
|
+
|
|
765
|
+
export type CampaignSendTestCampaignEmailMutationResult = NonNullable<Awaited<ReturnType<typeof campaignSendTestCampaignEmail>>>
|
|
766
|
+
export type CampaignSendTestCampaignEmailMutationBody = CampaignSendTestCampaignEmailBody
|
|
767
|
+
export type CampaignSendTestCampaignEmailMutationError = void
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
* @summary Sends a test email for a broadcast campaign to the logged-in user and optionally to additional
|
|
771
|
+
recipients. Additional recipients are specified as a list of person Uids and must belong to the
|
|
772
|
+
same account as the logged-in user.
|
|
773
|
+
*/
|
|
774
|
+
export const useCampaignSendTestCampaignEmail = <TError = void,
|
|
775
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof campaignSendTestCampaignEmail>>, TError,{data: CampaignSendTestCampaignEmailBody}, TContext>, request?: SecondParameter<typeof customFetch>}
|
|
776
|
+
): UseMutationResult<
|
|
777
|
+
Awaited<ReturnType<typeof campaignSendTestCampaignEmail>>,
|
|
778
|
+
TError,
|
|
779
|
+
{data: CampaignSendTestCampaignEmailBody},
|
|
780
|
+
TContext
|
|
781
|
+
> => {
|
|
782
|
+
|
|
783
|
+
const mutationOptions = getCampaignSendTestCampaignEmailMutationOptions(options);
|
|
784
|
+
|
|
785
|
+
return useMutation(mutationOptions);
|
|
786
|
+
}
|
|
787
|
+
/**
|
|
788
|
+
* @summary Retrieves all the people subscribing to an email list.
|
|
789
|
+
*/
|
|
790
|
+
export const emailListGetAllSubscriptions = (
|
|
791
|
+
emailListUid: string | null,
|
|
792
|
+
params?: EmailListGetAllSubscriptionsParams,
|
|
793
|
+
options?: SecondParameter<typeof customFetch>,signal?: AbortSignal
|
|
794
|
+
) => {
|
|
795
|
+
|
|
796
|
+
|
|
797
|
+
return customFetch<EmailListPerson[]>(
|
|
798
|
+
{url: `/api/v1/email/lists/${emailListUid}/subscriptions`, method: 'GET',
|
|
799
|
+
params, signal
|
|
800
|
+
},
|
|
801
|
+
options);
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
|
|
805
|
+
|
|
806
|
+
|
|
807
|
+
export const getEmailListGetAllSubscriptionsQueryKey = (emailListUid?: string | null,
|
|
808
|
+
params?: EmailListGetAllSubscriptionsParams,) => {
|
|
809
|
+
return [
|
|
810
|
+
`/api/v1/email/lists/${emailListUid}/subscriptions`, ...(params ? [params]: [])
|
|
811
|
+
] as const;
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
|
|
815
|
+
export const getEmailListGetAllSubscriptionsQueryOptions = <TData = Awaited<ReturnType<typeof emailListGetAllSubscriptions>>, TError = void>(emailListUid: string | null,
|
|
816
|
+
params?: EmailListGetAllSubscriptionsParams, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof emailListGetAllSubscriptions>>, TError, TData>, request?: SecondParameter<typeof customFetch>}
|
|
817
|
+
) => {
|
|
818
|
+
|
|
819
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
820
|
+
|
|
821
|
+
const queryKey = queryOptions?.queryKey ?? getEmailListGetAllSubscriptionsQueryKey(emailListUid,params);
|
|
822
|
+
|
|
823
|
+
|
|
824
|
+
|
|
825
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof emailListGetAllSubscriptions>>> = ({ signal }) => emailListGetAllSubscriptions(emailListUid,params, requestOptions, signal);
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
|
|
829
|
+
|
|
830
|
+
|
|
831
|
+
return { queryKey, queryFn, enabled: !!(emailListUid), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof emailListGetAllSubscriptions>>, TError, TData> & { queryKey: QueryKey }
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
export type EmailListGetAllSubscriptionsQueryResult = NonNullable<Awaited<ReturnType<typeof emailListGetAllSubscriptions>>>
|
|
835
|
+
export type EmailListGetAllSubscriptionsQueryError = void
|
|
836
|
+
|
|
837
|
+
|
|
838
|
+
/**
|
|
839
|
+
* @summary Retrieves all the people subscribing to an email list.
|
|
840
|
+
*/
|
|
841
|
+
|
|
842
|
+
export function useEmailListGetAllSubscriptions<TData = Awaited<ReturnType<typeof emailListGetAllSubscriptions>>, TError = void>(
|
|
843
|
+
emailListUid: string | null,
|
|
844
|
+
params?: EmailListGetAllSubscriptionsParams, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof emailListGetAllSubscriptions>>, TError, TData>, request?: SecondParameter<typeof customFetch>}
|
|
845
|
+
|
|
846
|
+
): UseQueryResult<TData, TError> & { queryKey: QueryKey } {
|
|
847
|
+
|
|
848
|
+
const queryOptions = getEmailListGetAllSubscriptionsQueryOptions(emailListUid,params,options)
|
|
849
|
+
|
|
850
|
+
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
851
|
+
|
|
852
|
+
query.queryKey = queryOptions.queryKey ;
|
|
853
|
+
|
|
854
|
+
return query;
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
|
|
858
|
+
|
|
859
|
+
|
|
860
|
+
/**
|
|
861
|
+
* @summary Subscribe a person to an email list. To subscribe a new person, pass a Person object with an
|
|
862
|
+
Email address. To subscribe an existing person, pass a Person object with a Uid. The
|
|
863
|
+
SendWelcomeEmail property determines if the person is sent a welcome email and defaults to false.
|
|
864
|
+
*/
|
|
865
|
+
export const emailListAddSubscription = (
|
|
866
|
+
emailListUid: string | null,
|
|
867
|
+
emailListAddSubscriptionBody: EmailListAddSubscriptionBody,
|
|
868
|
+
options?: SecondParameter<typeof customFetch>,signal?: AbortSignal
|
|
869
|
+
) => {
|
|
870
|
+
|
|
871
|
+
|
|
872
|
+
return customFetch<EmailListPerson>(
|
|
873
|
+
{url: `/api/v1/email/lists/${emailListUid}/subscriptions`, method: 'POST',
|
|
874
|
+
headers: {'Content-Type': 'application/json', },
|
|
875
|
+
data: emailListAddSubscriptionBody, signal
|
|
876
|
+
},
|
|
877
|
+
options);
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
|
|
881
|
+
|
|
882
|
+
export const getEmailListAddSubscriptionMutationOptions = <TError = void,
|
|
883
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof emailListAddSubscription>>, TError,{emailListUid: string | null;data: EmailListAddSubscriptionBody}, TContext>, request?: SecondParameter<typeof customFetch>}
|
|
884
|
+
): UseMutationOptions<Awaited<ReturnType<typeof emailListAddSubscription>>, TError,{emailListUid: string | null;data: EmailListAddSubscriptionBody}, TContext> => {
|
|
885
|
+
|
|
886
|
+
const mutationKey = ['emailListAddSubscription'];
|
|
887
|
+
const {mutation: mutationOptions, request: requestOptions} = options ?
|
|
888
|
+
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
|
|
889
|
+
options
|
|
890
|
+
: {...options, mutation: {...options.mutation, mutationKey}}
|
|
891
|
+
: {mutation: { mutationKey, }, request: undefined};
|
|
892
|
+
|
|
893
|
+
|
|
894
|
+
|
|
895
|
+
|
|
896
|
+
const mutationFn: MutationFunction<Awaited<ReturnType<typeof emailListAddSubscription>>, {emailListUid: string | null;data: EmailListAddSubscriptionBody}> = (props) => {
|
|
897
|
+
const {emailListUid,data} = props ?? {};
|
|
898
|
+
|
|
899
|
+
return emailListAddSubscription(emailListUid,data,requestOptions)
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
|
|
903
|
+
|
|
904
|
+
|
|
905
|
+
return { mutationFn, ...mutationOptions }}
|
|
906
|
+
|
|
907
|
+
export type EmailListAddSubscriptionMutationResult = NonNullable<Awaited<ReturnType<typeof emailListAddSubscription>>>
|
|
908
|
+
export type EmailListAddSubscriptionMutationBody = EmailListAddSubscriptionBody
|
|
909
|
+
export type EmailListAddSubscriptionMutationError = void
|
|
910
|
+
|
|
911
|
+
/**
|
|
912
|
+
* @summary Subscribe a person to an email list. To subscribe a new person, pass a Person object with an
|
|
913
|
+
Email address. To subscribe an existing person, pass a Person object with a Uid. The
|
|
914
|
+
SendWelcomeEmail property determines if the person is sent a welcome email and defaults to false.
|
|
915
|
+
*/
|
|
916
|
+
export const useEmailListAddSubscription = <TError = void,
|
|
917
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof emailListAddSubscription>>, TError,{emailListUid: string | null;data: EmailListAddSubscriptionBody}, TContext>, request?: SecondParameter<typeof customFetch>}
|
|
918
|
+
): UseMutationResult<
|
|
919
|
+
Awaited<ReturnType<typeof emailListAddSubscription>>,
|
|
920
|
+
TError,
|
|
921
|
+
{emailListUid: string | null;data: EmailListAddSubscriptionBody},
|
|
922
|
+
TContext
|
|
923
|
+
> => {
|
|
924
|
+
|
|
925
|
+
const mutationOptions = getEmailListAddSubscriptionMutationOptions(options);
|
|
926
|
+
|
|
927
|
+
return useMutation(mutationOptions);
|
|
928
|
+
}
|
|
929
|
+
/**
|
|
930
|
+
* @summary Remove a subscriber from an email list.
|
|
931
|
+
*/
|
|
932
|
+
export const emailListDeleteSubscription = (
|
|
933
|
+
emailListUid: string | null,
|
|
934
|
+
subscriptionUid: string | null,
|
|
935
|
+
options?: SecondParameter<typeof customFetch>,) => {
|
|
936
|
+
|
|
937
|
+
|
|
938
|
+
return customFetch<Blob>(
|
|
939
|
+
{url: `/api/v1/email/lists/${emailListUid}/subscriptions/${subscriptionUid}`, method: 'DELETE',
|
|
940
|
+
responseType: 'blob'
|
|
941
|
+
},
|
|
942
|
+
options);
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
|
|
946
|
+
|
|
947
|
+
export const getEmailListDeleteSubscriptionMutationOptions = <TError = void,
|
|
948
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof emailListDeleteSubscription>>, TError,{emailListUid: string | null;subscriptionUid: string | null}, TContext>, request?: SecondParameter<typeof customFetch>}
|
|
949
|
+
): UseMutationOptions<Awaited<ReturnType<typeof emailListDeleteSubscription>>, TError,{emailListUid: string | null;subscriptionUid: string | null}, TContext> => {
|
|
950
|
+
|
|
951
|
+
const mutationKey = ['emailListDeleteSubscription'];
|
|
952
|
+
const {mutation: mutationOptions, request: requestOptions} = options ?
|
|
953
|
+
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
|
|
954
|
+
options
|
|
955
|
+
: {...options, mutation: {...options.mutation, mutationKey}}
|
|
956
|
+
: {mutation: { mutationKey, }, request: undefined};
|
|
957
|
+
|
|
958
|
+
|
|
959
|
+
|
|
960
|
+
|
|
961
|
+
const mutationFn: MutationFunction<Awaited<ReturnType<typeof emailListDeleteSubscription>>, {emailListUid: string | null;subscriptionUid: string | null}> = (props) => {
|
|
962
|
+
const {emailListUid,subscriptionUid} = props ?? {};
|
|
963
|
+
|
|
964
|
+
return emailListDeleteSubscription(emailListUid,subscriptionUid,requestOptions)
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
|
|
968
|
+
|
|
969
|
+
|
|
970
|
+
return { mutationFn, ...mutationOptions }}
|
|
971
|
+
|
|
972
|
+
export type EmailListDeleteSubscriptionMutationResult = NonNullable<Awaited<ReturnType<typeof emailListDeleteSubscription>>>
|
|
973
|
+
|
|
974
|
+
export type EmailListDeleteSubscriptionMutationError = void
|
|
975
|
+
|
|
976
|
+
/**
|
|
977
|
+
* @summary Remove a subscriber from an email list.
|
|
978
|
+
*/
|
|
979
|
+
export const useEmailListDeleteSubscription = <TError = void,
|
|
980
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof emailListDeleteSubscription>>, TError,{emailListUid: string | null;subscriptionUid: string | null}, TContext>, request?: SecondParameter<typeof customFetch>}
|
|
981
|
+
): UseMutationResult<
|
|
982
|
+
Awaited<ReturnType<typeof emailListDeleteSubscription>>,
|
|
983
|
+
TError,
|
|
984
|
+
{emailListUid: string | null;subscriptionUid: string | null},
|
|
985
|
+
TContext
|
|
986
|
+
> => {
|
|
987
|
+
|
|
988
|
+
const mutationOptions = getEmailListDeleteSubscriptionMutationOptions(options);
|
|
989
|
+
|
|
990
|
+
return useMutation(mutationOptions);
|
|
991
|
+
}
|
|
992
|
+
|