• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

box / box-typescript-sdk-gen / 17491718999

05 Sep 2025 11:20AM UTC coverage: 41.3%. First build
17491718999

Pull #753

github

web-flow
Merge c56b7a7eb into 3c8f1fd03
Pull Request #753: feat: Add missing webhook events (box/box-openapi#554)

4407 of 18520 branches covered (23.8%)

Branch coverage included in aggregate %.

0 of 18 new or added lines in 2 files covered. (0.0%)

16251 of 31499 relevant lines covered (51.59%)

192.85 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

30.18
/src/managers/webhooks.generated.ts
1
import { serializeDateTime } from '../internal/utils.js';
2
import { deserializeDateTime } from '../internal/utils.js';
3
import { serializeWebhooks } from '../schemas/webhooks.generated.js';
4
import { deserializeWebhooks } from '../schemas/webhooks.generated.js';
231✔
5
import { serializeClientError } from '../schemas/clientError.generated.js';
6
import { deserializeClientError } from '../schemas/clientError.generated.js';
7
import { serializeWebhook } from '../schemas/webhook.generated.js';
8
import { deserializeWebhook } from '../schemas/webhook.generated.js';
231✔
9
import { ResponseFormat } from '../networking/fetchOptions.generated.js';
10
import { DateTime } from '../internal/utils.js';
11
import { Webhooks } from '../schemas/webhooks.generated.js';
12
import { ClientError } from '../schemas/clientError.generated.js';
13
import { Webhook } from '../schemas/webhook.generated.js';
14
import { BoxSdkError } from '../box/errors.js';
231✔
15
import { Authentication } from '../networking/auth.generated.js';
16
import { NetworkSession } from '../networking/network.generated.js';
231✔
17
import { FetchOptions } from '../networking/fetchOptions.generated.js';
231✔
18
import { FetchResponse } from '../networking/fetchResponse.generated.js';
19
import { prepareParams } from '../internal/utils.js';
231✔
20
import { toString } from '../internal/utils.js';
231✔
21
import { ByteStream } from '../internal/utils.js';
22
import { CancellationToken } from '../internal/utils.js';
23
import { sdToJson } from '../serialization/json.js';
24
import { SerializedData } from '../serialization/json.js';
25
import { computeWebhookSignature } from '../internal/utils.js';
231✔
26
import { compareSignatures } from '../internal/utils.js';
231✔
27
import { dateTimeFromString } from '../internal/utils.js';
231✔
28
import { getEpochTimeInSeconds } from '../internal/utils.js';
231✔
29
import { dateTimeToEpochSeconds } from '../internal/utils.js';
231✔
30
import { sdIsEmpty } from '../serialization/json.js';
31
import { sdIsBoolean } from '../serialization/json.js';
32
import { sdIsNumber } from '../serialization/json.js';
33
import { sdIsString } from '../serialization/json.js';
231✔
34
import { sdIsList } from '../serialization/json.js';
231✔
35
import { sdIsMap } from '../serialization/json.js';
231✔
36
export class CreateWebhookOptionals {
231✔
37
  readonly headers: CreateWebhookHeaders = new CreateWebhookHeaders({});
3✔
38
  readonly cancellationToken?: CancellationToken = void 0;
3✔
39
  constructor(
40
    fields: Omit<CreateWebhookOptionals, 'headers' | 'cancellationToken'> &
41
      Partial<Pick<CreateWebhookOptionals, 'headers' | 'cancellationToken'>>,
42
  ) {
43
    if (fields.headers !== undefined) {
3!
44
      this.headers = fields.headers;
×
45
    }
46
    if (fields.cancellationToken !== undefined) {
3!
47
      this.cancellationToken = fields.cancellationToken;
×
48
    }
49
  }
50
}
51
export interface CreateWebhookOptionalsInput {
52
  readonly headers?: CreateWebhookHeaders;
53
  readonly cancellationToken?: undefined | CancellationToken;
54
}
55
export class GetWebhookByIdOptionals {
231✔
56
  readonly headers: GetWebhookByIdHeaders = new GetWebhookByIdHeaders({});
3✔
57
  readonly cancellationToken?: CancellationToken = void 0;
3✔
58
  constructor(
59
    fields: Omit<GetWebhookByIdOptionals, 'headers' | 'cancellationToken'> &
60
      Partial<Pick<GetWebhookByIdOptionals, 'headers' | 'cancellationToken'>>,
61
  ) {
62
    if (fields.headers !== undefined) {
3!
63
      this.headers = fields.headers;
×
64
    }
65
    if (fields.cancellationToken !== undefined) {
3!
66
      this.cancellationToken = fields.cancellationToken;
×
67
    }
68
  }
69
}
70
export interface GetWebhookByIdOptionalsInput {
71
  readonly headers?: GetWebhookByIdHeaders;
72
  readonly cancellationToken?: undefined | CancellationToken;
73
}
74
export class UpdateWebhookByIdOptionals {
231✔
75
  readonly requestBody: UpdateWebhookByIdRequestBody =
3✔
76
    {} satisfies UpdateWebhookByIdRequestBody;
77
  readonly headers: UpdateWebhookByIdHeaders = new UpdateWebhookByIdHeaders({});
3✔
78
  readonly cancellationToken?: CancellationToken = void 0;
3✔
79
  constructor(
80
    fields: Omit<
81
      UpdateWebhookByIdOptionals,
82
      'requestBody' | 'headers' | 'cancellationToken'
83
    > &
84
      Partial<
85
        Pick<
86
          UpdateWebhookByIdOptionals,
87
          'requestBody' | 'headers' | 'cancellationToken'
88
        >
89
      >,
90
  ) {
91
    if (fields.requestBody !== undefined) {
3✔
92
      this.requestBody = fields.requestBody;
3✔
93
    }
94
    if (fields.headers !== undefined) {
3!
95
      this.headers = fields.headers;
×
96
    }
97
    if (fields.cancellationToken !== undefined) {
3!
98
      this.cancellationToken = fields.cancellationToken;
×
99
    }
100
  }
101
}
102
export interface UpdateWebhookByIdOptionalsInput {
103
  readonly requestBody?: UpdateWebhookByIdRequestBody;
104
  readonly headers?: UpdateWebhookByIdHeaders;
105
  readonly cancellationToken?: undefined | CancellationToken;
106
}
107
export class DeleteWebhookByIdOptionals {
231✔
108
  readonly headers: DeleteWebhookByIdHeaders = new DeleteWebhookByIdHeaders({});
6✔
109
  readonly cancellationToken?: CancellationToken = void 0;
6✔
110
  constructor(
111
    fields: Omit<DeleteWebhookByIdOptionals, 'headers' | 'cancellationToken'> &
112
      Partial<
113
        Pick<DeleteWebhookByIdOptionals, 'headers' | 'cancellationToken'>
114
      >,
115
  ) {
116
    if (fields.headers !== undefined) {
6!
117
      this.headers = fields.headers;
×
118
    }
119
    if (fields.cancellationToken !== undefined) {
6!
120
      this.cancellationToken = fields.cancellationToken;
×
121
    }
122
  }
123
}
124
export interface DeleteWebhookByIdOptionalsInput {
125
  readonly headers?: DeleteWebhookByIdHeaders;
126
  readonly cancellationToken?: undefined | CancellationToken;
127
}
128
export class ValidateMessageOptionals {
231✔
129
  readonly secondaryKey?: string = void 0;
36✔
130
  readonly maxAge?: number = 600;
36✔
131
  constructor(
132
    fields: Omit<ValidateMessageOptionals, 'secondaryKey' | 'maxAge'> &
133
      Partial<Pick<ValidateMessageOptionals, 'secondaryKey' | 'maxAge'>>,
134
  ) {
135
    if (fields.secondaryKey !== undefined) {
36✔
136
      this.secondaryKey = fields.secondaryKey;
36✔
137
    }
138
    if (fields.maxAge !== undefined) {
36!
139
      this.maxAge = fields.maxAge;
×
140
    }
141
  }
142
}
143
export interface ValidateMessageOptionalsInput {
144
  readonly secondaryKey?: undefined | string;
145
  readonly maxAge?: undefined | number;
146
}
147
export interface GetWebhooksQueryParams {
148
  /**
149
   * Defines the position marker at which to begin returning results. This is
150
   * used when paginating using marker-based pagination.
151
   *
152
   * This requires `usemarker` to be set to `true`. */
153
  readonly marker?: string;
154
  /**
155
   * The maximum number of items to return per page. */
156
  readonly limit?: number;
157
}
158
export class GetWebhooksHeaders {
231✔
159
  /**
160
   * Extra headers that will be included in the HTTP request. */
161
  readonly extraHeaders?: {
6✔
162
    readonly [key: string]: undefined | string;
163
  } = {};
164
  constructor(
165
    fields: Omit<GetWebhooksHeaders, 'extraHeaders'> &
166
      Partial<Pick<GetWebhooksHeaders, 'extraHeaders'>>,
167
  ) {
168
    if (fields.extraHeaders !== undefined) {
6✔
169
      this.extraHeaders = fields.extraHeaders;
3✔
170
    }
171
  }
172
}
173
export interface GetWebhooksHeadersInput {
174
  /**
175
   * Extra headers that will be included in the HTTP request. */
176
  readonly extraHeaders?:
177
    | undefined
178
    | {
179
        readonly [key: string]: undefined | string;
180
      };
181
}
182
export type CreateWebhookRequestBodyTargetTypeField = 'file' | 'folder';
183
export interface CreateWebhookRequestBodyTargetField {
184
  /**
185
   * The ID of the item to trigger a webhook. */
186
  readonly id?: string;
187
  /**
188
   * The type of item to trigger a webhook. */
189
  readonly type?: CreateWebhookRequestBodyTargetTypeField;
190
  readonly rawData?: SerializedData;
191
}
192
export type CreateWebhookRequestBodyTriggersField =
193
  | 'FILE.UPLOADED'
194
  | 'FILE.PREVIEWED'
195
  | 'FILE.DOWNLOADED'
196
  | 'FILE.TRASHED'
197
  | 'FILE.DELETED'
198
  | 'FILE.RESTORED'
199
  | 'FILE.COPIED'
200
  | 'FILE.MOVED'
201
  | 'FILE.LOCKED'
202
  | 'FILE.UNLOCKED'
203
  | 'FILE.RENAMED'
204
  | 'COMMENT.CREATED'
205
  | 'COMMENT.UPDATED'
206
  | 'COMMENT.DELETED'
207
  | 'TASK_ASSIGNMENT.CREATED'
208
  | 'TASK_ASSIGNMENT.UPDATED'
209
  | 'METADATA_INSTANCE.CREATED'
210
  | 'METADATA_INSTANCE.UPDATED'
211
  | 'METADATA_INSTANCE.DELETED'
212
  | 'FOLDER.CREATED'
213
  | 'FOLDER.RENAMED'
214
  | 'FOLDER.DOWNLOADED'
215
  | 'FOLDER.RESTORED'
216
  | 'FOLDER.DELETED'
217
  | 'FOLDER.COPIED'
218
  | 'FOLDER.MOVED'
219
  | 'FOLDER.TRASHED'
220
  | 'WEBHOOK.DELETED'
221
  | 'COLLABORATION.CREATED'
222
  | 'COLLABORATION.ACCEPTED'
223
  | 'COLLABORATION.REJECTED'
224
  | 'COLLABORATION.REMOVED'
225
  | 'COLLABORATION.UPDATED'
226
  | 'SHARED_LINK.DELETED'
227
  | 'SHARED_LINK.CREATED'
228
  | 'SHARED_LINK.UPDATED'
229
  | 'SIGN_REQUEST.COMPLETED'
230
  | 'SIGN_REQUEST.DECLINED'
231
  | 'SIGN_REQUEST.EXPIRED'
232
  | 'SIGN_REQUEST.SIGNER_EMAIL_BOUNCED'
233
  | 'SIGN_REQUEST.SIGN_SIGNER_SIGNED'
234
  | 'SIGN_REQUEST.SIGN_DOCUMENT_CREATED'
235
  | 'SIGN_REQUEST.SIGN_ERROR_FINALIZING'
236
  | string;
237
export interface CreateWebhookRequestBody {
238
  /**
239
   * The item that will trigger the webhook. */
240
  readonly target: CreateWebhookRequestBodyTargetField;
241
  /**
242
   * The URL that is notified by this webhook. */
243
  readonly address: string;
244
  /**
245
   * An array of event names that this webhook is
246
   * to be triggered for. */
247
  readonly triggers: readonly CreateWebhookRequestBodyTriggersField[];
248
  readonly rawData?: SerializedData;
249
}
250
export class CreateWebhookHeaders {
231✔
251
  /**
252
   * Extra headers that will be included in the HTTP request. */
253
  readonly extraHeaders?: {
3✔
254
    readonly [key: string]: undefined | string;
255
  } = {};
256
  constructor(
257
    fields: Omit<CreateWebhookHeaders, 'extraHeaders'> &
258
      Partial<Pick<CreateWebhookHeaders, 'extraHeaders'>>,
259
  ) {
260
    if (fields.extraHeaders !== undefined) {
3!
261
      this.extraHeaders = fields.extraHeaders;
×
262
    }
263
  }
264
}
265
export interface CreateWebhookHeadersInput {
266
  /**
267
   * Extra headers that will be included in the HTTP request. */
268
  readonly extraHeaders?:
269
    | undefined
270
    | {
271
        readonly [key: string]: undefined | string;
272
      };
273
}
274
export class GetWebhookByIdHeaders {
231✔
275
  /**
276
   * Extra headers that will be included in the HTTP request. */
277
  readonly extraHeaders?: {
3✔
278
    readonly [key: string]: undefined | string;
279
  } = {};
280
  constructor(
281
    fields: Omit<GetWebhookByIdHeaders, 'extraHeaders'> &
282
      Partial<Pick<GetWebhookByIdHeaders, 'extraHeaders'>>,
283
  ) {
284
    if (fields.extraHeaders !== undefined) {
3!
285
      this.extraHeaders = fields.extraHeaders;
×
286
    }
287
  }
288
}
289
export interface GetWebhookByIdHeadersInput {
290
  /**
291
   * Extra headers that will be included in the HTTP request. */
292
  readonly extraHeaders?:
293
    | undefined
294
    | {
295
        readonly [key: string]: undefined | string;
296
      };
297
}
298
export type UpdateWebhookByIdRequestBodyTargetTypeField = 'file' | 'folder';
299
export interface UpdateWebhookByIdRequestBodyTargetField {
300
  /**
301
   * The ID of the item to trigger a webhook. */
302
  readonly id?: string;
303
  /**
304
   * The type of item to trigger a webhook. */
305
  readonly type?: UpdateWebhookByIdRequestBodyTargetTypeField;
306
  readonly rawData?: SerializedData;
307
}
308
export type UpdateWebhookByIdRequestBodyTriggersField =
309
  | 'FILE.UPLOADED'
310
  | 'FILE.PREVIEWED'
311
  | 'FILE.DOWNLOADED'
312
  | 'FILE.TRASHED'
313
  | 'FILE.DELETED'
314
  | 'FILE.RESTORED'
315
  | 'FILE.COPIED'
316
  | 'FILE.MOVED'
317
  | 'FILE.LOCKED'
318
  | 'FILE.UNLOCKED'
319
  | 'FILE.RENAMED'
320
  | 'COMMENT.CREATED'
321
  | 'COMMENT.UPDATED'
322
  | 'COMMENT.DELETED'
323
  | 'TASK_ASSIGNMENT.CREATED'
324
  | 'TASK_ASSIGNMENT.UPDATED'
325
  | 'METADATA_INSTANCE.CREATED'
326
  | 'METADATA_INSTANCE.UPDATED'
327
  | 'METADATA_INSTANCE.DELETED'
328
  | 'FOLDER.CREATED'
329
  | 'FOLDER.RENAMED'
330
  | 'FOLDER.DOWNLOADED'
331
  | 'FOLDER.RESTORED'
332
  | 'FOLDER.DELETED'
333
  | 'FOLDER.COPIED'
334
  | 'FOLDER.MOVED'
335
  | 'FOLDER.TRASHED'
336
  | 'WEBHOOK.DELETED'
337
  | 'COLLABORATION.CREATED'
338
  | 'COLLABORATION.ACCEPTED'
339
  | 'COLLABORATION.REJECTED'
340
  | 'COLLABORATION.REMOVED'
341
  | 'COLLABORATION.UPDATED'
342
  | 'SHARED_LINK.DELETED'
343
  | 'SHARED_LINK.CREATED'
344
  | 'SHARED_LINK.UPDATED'
345
  | 'SIGN_REQUEST.COMPLETED'
346
  | 'SIGN_REQUEST.DECLINED'
347
  | 'SIGN_REQUEST.EXPIRED'
348
  | 'SIGN_REQUEST.SIGNER_EMAIL_BOUNCED'
349
  | 'SIGN_REQUEST.SIGN_SIGNER_SIGNED'
350
  | 'SIGN_REQUEST.SIGN_DOCUMENT_CREATED'
351
  | 'SIGN_REQUEST.SIGN_ERROR_FINALIZING'
352
  | string;
353
export interface UpdateWebhookByIdRequestBody {
354
  /**
355
   * The item that will trigger the webhook. */
356
  readonly target?: UpdateWebhookByIdRequestBodyTargetField;
357
  /**
358
   * The URL that is notified by this webhook. */
359
  readonly address?: string;
360
  /**
361
   * An array of event names that this webhook is
362
   * to be triggered for. */
363
  readonly triggers?: readonly UpdateWebhookByIdRequestBodyTriggersField[];
364
  readonly rawData?: SerializedData;
365
}
366
export class UpdateWebhookByIdHeaders {
231✔
367
  /**
368
   * Extra headers that will be included in the HTTP request. */
369
  readonly extraHeaders?: {
3✔
370
    readonly [key: string]: undefined | string;
371
  } = {};
372
  constructor(
373
    fields: Omit<UpdateWebhookByIdHeaders, 'extraHeaders'> &
374
      Partial<Pick<UpdateWebhookByIdHeaders, 'extraHeaders'>>,
375
  ) {
376
    if (fields.extraHeaders !== undefined) {
3!
377
      this.extraHeaders = fields.extraHeaders;
×
378
    }
379
  }
380
}
381
export interface UpdateWebhookByIdHeadersInput {
382
  /**
383
   * Extra headers that will be included in the HTTP request. */
384
  readonly extraHeaders?:
385
    | undefined
386
    | {
387
        readonly [key: string]: undefined | string;
388
      };
389
}
390
export class DeleteWebhookByIdHeaders {
231✔
391
  /**
392
   * Extra headers that will be included in the HTTP request. */
393
  readonly extraHeaders?: {
6✔
394
    readonly [key: string]: undefined | string;
395
  } = {};
396
  constructor(
397
    fields: Omit<DeleteWebhookByIdHeaders, 'extraHeaders'> &
398
      Partial<Pick<DeleteWebhookByIdHeaders, 'extraHeaders'>>,
399
  ) {
400
    if (fields.extraHeaders !== undefined) {
6!
401
      this.extraHeaders = fields.extraHeaders;
×
402
    }
403
  }
404
}
405
export interface DeleteWebhookByIdHeadersInput {
406
  /**
407
   * Extra headers that will be included in the HTTP request. */
408
  readonly extraHeaders?:
409
    | undefined
410
    | {
411
        readonly [key: string]: undefined | string;
412
      };
413
}
414
export class WebhooksManager {
231✔
415
  readonly auth?: Authentication;
416
  readonly networkSession: NetworkSession = new NetworkSession({});
517✔
417
  constructor(
418
    fields: Omit<
419
      WebhooksManager,
420
      | 'networkSession'
421
      | 'getWebhooks'
422
      | 'createWebhook'
423
      | 'getWebhookById'
424
      | 'updateWebhookById'
425
      | 'deleteWebhookById'
426
      | 'validateMessage'
427
    > &
428
      Partial<Pick<WebhooksManager, 'networkSession'>>,
429
  ) {
430
    if (fields.auth !== undefined) {
517✔
431
      this.auth = fields.auth;
517✔
432
    }
433
    if (fields.networkSession !== undefined) {
517✔
434
      this.networkSession = fields.networkSession;
517✔
435
    }
436
  }
437
  /**
438
   * Returns all defined webhooks for the requesting application.
439
   *
440
   * This API only returns webhooks that are applied to files or folders that are
441
   * owned by the authenticated user. This means that an admin can not see webhooks
442
   * created by a service account unless the admin has access to those folders, and
443
   * vice versa.
444
   * @param {GetWebhooksQueryParams} queryParams Query parameters of getWebhooks method
445
   * @param {GetWebhooksHeadersInput} headersInput Headers of getWebhooks method
446
   * @param {CancellationToken} cancellationToken Token used for request cancellation.
447
   * @returns {Promise<Webhooks>}
448
   */
449
  async getWebhooks(
450
    queryParams: GetWebhooksQueryParams = {} satisfies GetWebhooksQueryParams,
3✔
451
    headersInput: GetWebhooksHeadersInput = new GetWebhooksHeaders({}),
3✔
452
    cancellationToken?: CancellationToken,
453
  ): Promise<Webhooks> {
454
    const headers: GetWebhooksHeaders = new GetWebhooksHeaders({
3✔
455
      extraHeaders: headersInput.extraHeaders,
456
    });
457
    const queryParamsMap: {
458
      readonly [key: string]: string;
459
    } = prepareParams({
3✔
460
      ['marker']: toString(queryParams.marker) as string,
461
      ['limit']: toString(queryParams.limit) as string,
462
    });
463
    const headersMap: {
464
      readonly [key: string]: string;
465
    } = prepareParams({ ...{}, ...headers.extraHeaders });
3✔
466
    const response: FetchResponse =
467
      await this.networkSession.networkClient.fetch(
3✔
468
        new FetchOptions({
469
          url: ''.concat(
470
            this.networkSession.baseUrls.baseUrl,
471
            '/2.0/webhooks',
472
          ) as string,
473
          method: 'GET',
474
          params: queryParamsMap,
475
          headers: headersMap,
476
          responseFormat: 'json' as ResponseFormat,
477
          auth: this.auth,
478
          networkSession: this.networkSession,
479
          cancellationToken: cancellationToken,
480
        }),
481
      );
482
    return {
3✔
483
      ...deserializeWebhooks(response.data!),
484
      rawData: response.data!,
485
    };
486
  }
487
  /**
488
   * Creates a webhook.
489
   * @param {CreateWebhookRequestBody} requestBody Request body of createWebhook method
490
   * @param {CreateWebhookOptionalsInput} optionalsInput
491
   * @returns {Promise<Webhook>}
492
   */
493
  async createWebhook(
494
    requestBody: CreateWebhookRequestBody,
3✔
495
    optionalsInput: CreateWebhookOptionalsInput = {},
3✔
496
  ): Promise<Webhook> {
497
    const optionals: CreateWebhookOptionals = new CreateWebhookOptionals({
3✔
498
      headers: optionalsInput.headers,
499
      cancellationToken: optionalsInput.cancellationToken,
500
    });
501
    const headers: any = optionals.headers;
3✔
502
    const cancellationToken: any = optionals.cancellationToken;
3✔
503
    const headersMap: {
504
      readonly [key: string]: string;
505
    } = prepareParams({ ...{}, ...headers.extraHeaders });
3✔
506
    const response: FetchResponse =
507
      await this.networkSession.networkClient.fetch(
3✔
508
        new FetchOptions({
509
          url: ''.concat(
510
            this.networkSession.baseUrls.baseUrl,
511
            '/2.0/webhooks',
512
          ) as string,
513
          method: 'POST',
514
          headers: headersMap,
515
          data: serializeCreateWebhookRequestBody(requestBody),
516
          contentType: 'application/json',
517
          responseFormat: 'json' as ResponseFormat,
518
          auth: this.auth,
519
          networkSession: this.networkSession,
520
          cancellationToken: cancellationToken,
521
        }),
522
      );
523
    return {
3✔
524
      ...deserializeWebhook(response.data!),
525
      rawData: response.data!,
526
    };
527
  }
528
  /**
529
     * Retrieves a specific webhook.
530
     * @param {string} webhookId The ID of the webhook.
531
    Example: "3321123"
532
     * @param {GetWebhookByIdOptionalsInput} optionalsInput
533
     * @returns {Promise<Webhook>}
534
     */
535
  async getWebhookById(
536
    webhookId: string,
3✔
537
    optionalsInput: GetWebhookByIdOptionalsInput = {},
3✔
538
  ): Promise<Webhook> {
539
    const optionals: GetWebhookByIdOptionals = new GetWebhookByIdOptionals({
3✔
540
      headers: optionalsInput.headers,
541
      cancellationToken: optionalsInput.cancellationToken,
542
    });
543
    const headers: any = optionals.headers;
3✔
544
    const cancellationToken: any = optionals.cancellationToken;
3✔
545
    const headersMap: {
546
      readonly [key: string]: string;
547
    } = prepareParams({ ...{}, ...headers.extraHeaders });
3✔
548
    const response: FetchResponse =
549
      await this.networkSession.networkClient.fetch(
3✔
550
        new FetchOptions({
551
          url: ''.concat(
552
            this.networkSession.baseUrls.baseUrl,
553
            '/2.0/webhooks/',
554
            toString(webhookId) as string,
555
          ) as string,
556
          method: 'GET',
557
          headers: headersMap,
558
          responseFormat: 'json' as ResponseFormat,
559
          auth: this.auth,
560
          networkSession: this.networkSession,
561
          cancellationToken: cancellationToken,
562
        }),
563
      );
564
    return {
3✔
565
      ...deserializeWebhook(response.data!),
566
      rawData: response.data!,
567
    };
568
  }
569
  /**
570
     * Updates a webhook.
571
     * @param {string} webhookId The ID of the webhook.
572
    Example: "3321123"
573
     * @param {UpdateWebhookByIdOptionalsInput} optionalsInput
574
     * @returns {Promise<Webhook>}
575
     */
576
  async updateWebhookById(
577
    webhookId: string,
3✔
578
    optionalsInput: UpdateWebhookByIdOptionalsInput = {},
×
579
  ): Promise<Webhook> {
580
    const optionals: UpdateWebhookByIdOptionals =
581
      new UpdateWebhookByIdOptionals({
3✔
582
        requestBody: optionalsInput.requestBody,
583
        headers: optionalsInput.headers,
584
        cancellationToken: optionalsInput.cancellationToken,
585
      });
586
    const requestBody: any = optionals.requestBody;
3✔
587
    const headers: any = optionals.headers;
3✔
588
    const cancellationToken: any = optionals.cancellationToken;
3✔
589
    const headersMap: {
590
      readonly [key: string]: string;
591
    } = prepareParams({ ...{}, ...headers.extraHeaders });
3✔
592
    const response: FetchResponse =
593
      await this.networkSession.networkClient.fetch(
3✔
594
        new FetchOptions({
595
          url: ''.concat(
596
            this.networkSession.baseUrls.baseUrl,
597
            '/2.0/webhooks/',
598
            toString(webhookId) as string,
599
          ) as string,
600
          method: 'PUT',
601
          headers: headersMap,
602
          data: serializeUpdateWebhookByIdRequestBody(requestBody),
603
          contentType: 'application/json',
604
          responseFormat: 'json' as ResponseFormat,
605
          auth: this.auth,
606
          networkSession: this.networkSession,
607
          cancellationToken: cancellationToken,
608
        }),
609
      );
610
    return {
3✔
611
      ...deserializeWebhook(response.data!),
612
      rawData: response.data!,
613
    };
614
  }
615
  /**
616
     * Deletes a webhook.
617
     * @param {string} webhookId The ID of the webhook.
618
    Example: "3321123"
619
     * @param {DeleteWebhookByIdOptionalsInput} optionalsInput
620
     * @returns {Promise<undefined>}
621
     */
622
  async deleteWebhookById(
623
    webhookId: string,
6✔
624
    optionalsInput: DeleteWebhookByIdOptionalsInput = {},
6✔
625
  ): Promise<undefined> {
626
    const optionals: DeleteWebhookByIdOptionals =
627
      new DeleteWebhookByIdOptionals({
6✔
628
        headers: optionalsInput.headers,
629
        cancellationToken: optionalsInput.cancellationToken,
630
      });
631
    const headers: any = optionals.headers;
6✔
632
    const cancellationToken: any = optionals.cancellationToken;
6✔
633
    const headersMap: {
634
      readonly [key: string]: string;
635
    } = prepareParams({ ...{}, ...headers.extraHeaders });
6✔
636
    const response: FetchResponse =
637
      await this.networkSession.networkClient.fetch(
6✔
638
        new FetchOptions({
639
          url: ''.concat(
640
            this.networkSession.baseUrls.baseUrl,
641
            '/2.0/webhooks/',
642
            toString(webhookId) as string,
643
          ) as string,
644
          method: 'DELETE',
645
          headers: headersMap,
646
          responseFormat: 'no_content' as ResponseFormat,
647
          auth: this.auth,
648
          networkSession: this.networkSession,
649
          cancellationToken: cancellationToken,
650
        }),
651
      );
652
    return void 0;
3✔
653
  }
654
  /**
655
     * Validate a webhook message by verifying the signature and the delivery timestamp
656
     * @param {string} body The request body of the webhook message
657
     * @param {{
658
        readonly [key: string]: string;
659
    }} headers The headers of the webhook message
660
     * @param {string} primaryKey The primary signature to verify the message with
661
     * @param {ValidateMessageOptionalsInput} optionalsInput
662
     * @returns {Promise<boolean>}
663
     */
664
  static async validateMessage(
665
    body: string,
36✔
666
    headers: {
667
      readonly [key: string]: string;
668
    },
669
    primaryKey: string,
670
    optionalsInput: ValidateMessageOptionalsInput = {},
×
671
  ): Promise<boolean> {
672
    const optionals: ValidateMessageOptionals = new ValidateMessageOptionals({
36✔
673
      secondaryKey: optionalsInput.secondaryKey,
674
      maxAge: optionalsInput.maxAge,
675
    });
676
    const secondaryKey: any = optionals.secondaryKey;
36✔
677
    const maxAge: any = optionals.maxAge;
36✔
678
    const deliveryTimestamp: DateTime = dateTimeFromString(
36✔
679
      headers['box-delivery-timestamp'],
680
    );
681
    const currentEpoch: number = getEpochTimeInSeconds();
36✔
682
    if (
36✔
683
      currentEpoch - maxAge > dateTimeToEpochSeconds(deliveryTimestamp) ||
60✔
684
      dateTimeToEpochSeconds(deliveryTimestamp) > currentEpoch
685
    ) {
686
      return false;
15✔
687
    }
688
    if (
21✔
689
      !(primaryKey == void 0) &&
63✔
690
      !(headers['box-signature-primary'] == void 0) &&
691
      (await compareSignatures(
692
        await computeWebhookSignature(body, headers, primaryKey, false),
693
        headers['box-signature-primary'],
694
      ))
695
    ) {
696
      return true;
6✔
697
    }
698
    if (
15✔
699
      !(primaryKey == void 0) &&
45✔
700
      !(headers['box-signature-primary'] == void 0) &&
701
      (await compareSignatures(
702
        await computeWebhookSignature(body, headers, primaryKey, true),
703
        headers['box-signature-primary'],
704
      ))
705
    ) {
706
      return true;
6✔
707
    }
708
    if (
9✔
709
      !(secondaryKey == void 0) &&
27✔
710
      !(headers['box-signature-secondary'] == void 0) &&
711
      (await compareSignatures(
712
        await computeWebhookSignature(body, headers, secondaryKey, false),
713
        headers['box-signature-secondary'],
714
      ))
715
    ) {
716
      return true;
3✔
717
    }
718
    if (
6✔
719
      !(secondaryKey == void 0) &&
18✔
720
      !(headers['box-signature-secondary'] == void 0) &&
721
      (await compareSignatures(
722
        await computeWebhookSignature(body, headers, secondaryKey, true),
723
        headers['box-signature-secondary'],
724
      ))
725
    ) {
726
      return true;
3✔
727
    }
728
    return false;
3✔
729
  }
730
}
731
export interface WebhooksManagerInput {
732
  readonly auth?: Authentication;
733
  readonly networkSession?: NetworkSession;
734
}
735
export function serializeCreateWebhookRequestBodyTargetTypeField(
231✔
736
  val: CreateWebhookRequestBodyTargetTypeField,
737
): SerializedData {
738
  return val;
3✔
739
}
740
export function deserializeCreateWebhookRequestBodyTargetTypeField(
231✔
741
  val: SerializedData,
742
): CreateWebhookRequestBodyTargetTypeField {
743
  if (val == 'file') {
×
744
    return val;
×
745
  }
746
  if (val == 'folder') {
×
747
    return val;
×
748
  }
749
  throw new BoxSdkError({
×
750
    message: "Can't deserialize CreateWebhookRequestBodyTargetTypeField",
751
  });
752
}
753
export function serializeCreateWebhookRequestBodyTargetField(
231✔
754
  val: CreateWebhookRequestBodyTargetField,
755
): SerializedData {
756
  return {
3✔
757
    ['id']: val.id,
758
    ['type']:
759
      val.type == void 0
3!
760
        ? val.type
761
        : serializeCreateWebhookRequestBodyTargetTypeField(val.type),
762
  };
763
}
764
export function deserializeCreateWebhookRequestBodyTargetField(
231✔
765
  val: SerializedData,
766
): CreateWebhookRequestBodyTargetField {
767
  if (!sdIsMap(val)) {
×
768
    throw new BoxSdkError({
×
769
      message: 'Expecting a map for "CreateWebhookRequestBodyTargetField"',
770
    });
771
  }
772
  if (!(val.id == void 0) && !sdIsString(val.id)) {
×
773
    throw new BoxSdkError({
×
774
      message:
775
        'Expecting string for "id" of type "CreateWebhookRequestBodyTargetField"',
776
    });
777
  }
778
  const id: undefined | string = val.id == void 0 ? void 0 : val.id;
×
779
  const type: undefined | CreateWebhookRequestBodyTargetTypeField =
780
    val.type == void 0
×
781
      ? void 0
782
      : deserializeCreateWebhookRequestBodyTargetTypeField(val.type);
783
  return { id: id, type: type } satisfies CreateWebhookRequestBodyTargetField;
×
784
}
785
export function serializeCreateWebhookRequestBodyTriggersField(
231✔
786
  val: CreateWebhookRequestBodyTriggersField,
787
): SerializedData {
788
  return val;
3✔
789
}
790
export function deserializeCreateWebhookRequestBodyTriggersField(
231✔
791
  val: SerializedData,
792
): CreateWebhookRequestBodyTriggersField {
793
  if (val == 'FILE.UPLOADED') {
×
794
    return val;
×
795
  }
796
  if (val == 'FILE.PREVIEWED') {
×
797
    return val;
×
798
  }
799
  if (val == 'FILE.DOWNLOADED') {
×
800
    return val;
×
801
  }
802
  if (val == 'FILE.TRASHED') {
×
803
    return val;
×
804
  }
805
  if (val == 'FILE.DELETED') {
×
806
    return val;
×
807
  }
808
  if (val == 'FILE.RESTORED') {
×
809
    return val;
×
810
  }
811
  if (val == 'FILE.COPIED') {
×
812
    return val;
×
813
  }
814
  if (val == 'FILE.MOVED') {
×
815
    return val;
×
816
  }
817
  if (val == 'FILE.LOCKED') {
×
818
    return val;
×
819
  }
820
  if (val == 'FILE.UNLOCKED') {
×
821
    return val;
×
822
  }
823
  if (val == 'FILE.RENAMED') {
×
824
    return val;
×
825
  }
826
  if (val == 'COMMENT.CREATED') {
×
827
    return val;
×
828
  }
829
  if (val == 'COMMENT.UPDATED') {
×
830
    return val;
×
831
  }
832
  if (val == 'COMMENT.DELETED') {
×
833
    return val;
×
834
  }
835
  if (val == 'TASK_ASSIGNMENT.CREATED') {
×
836
    return val;
×
837
  }
838
  if (val == 'TASK_ASSIGNMENT.UPDATED') {
×
839
    return val;
×
840
  }
841
  if (val == 'METADATA_INSTANCE.CREATED') {
×
842
    return val;
×
843
  }
844
  if (val == 'METADATA_INSTANCE.UPDATED') {
×
845
    return val;
×
846
  }
847
  if (val == 'METADATA_INSTANCE.DELETED') {
×
848
    return val;
×
849
  }
850
  if (val == 'FOLDER.CREATED') {
×
851
    return val;
×
852
  }
853
  if (val == 'FOLDER.RENAMED') {
×
854
    return val;
×
855
  }
856
  if (val == 'FOLDER.DOWNLOADED') {
×
857
    return val;
×
858
  }
859
  if (val == 'FOLDER.RESTORED') {
×
860
    return val;
×
861
  }
862
  if (val == 'FOLDER.DELETED') {
×
863
    return val;
×
864
  }
865
  if (val == 'FOLDER.COPIED') {
×
866
    return val;
×
867
  }
868
  if (val == 'FOLDER.MOVED') {
×
869
    return val;
×
870
  }
871
  if (val == 'FOLDER.TRASHED') {
×
872
    return val;
×
873
  }
874
  if (val == 'WEBHOOK.DELETED') {
×
875
    return val;
×
876
  }
877
  if (val == 'COLLABORATION.CREATED') {
×
878
    return val;
×
879
  }
880
  if (val == 'COLLABORATION.ACCEPTED') {
×
881
    return val;
×
882
  }
883
  if (val == 'COLLABORATION.REJECTED') {
×
884
    return val;
×
885
  }
886
  if (val == 'COLLABORATION.REMOVED') {
×
887
    return val;
×
888
  }
889
  if (val == 'COLLABORATION.UPDATED') {
×
890
    return val;
×
891
  }
892
  if (val == 'SHARED_LINK.DELETED') {
×
893
    return val;
×
894
  }
895
  if (val == 'SHARED_LINK.CREATED') {
×
896
    return val;
×
897
  }
898
  if (val == 'SHARED_LINK.UPDATED') {
×
899
    return val;
×
900
  }
901
  if (val == 'SIGN_REQUEST.COMPLETED') {
×
902
    return val;
×
903
  }
904
  if (val == 'SIGN_REQUEST.DECLINED') {
×
905
    return val;
×
906
  }
907
  if (val == 'SIGN_REQUEST.EXPIRED') {
×
908
    return val;
×
909
  }
910
  if (val == 'SIGN_REQUEST.SIGNER_EMAIL_BOUNCED') {
×
911
    return val;
×
912
  }
NEW
913
  if (val == 'SIGN_REQUEST.SIGN_SIGNER_SIGNED') {
×
NEW
914
    return val;
×
915
  }
NEW
916
  if (val == 'SIGN_REQUEST.SIGN_DOCUMENT_CREATED') {
×
NEW
917
    return val;
×
918
  }
NEW
919
  if (val == 'SIGN_REQUEST.SIGN_ERROR_FINALIZING') {
×
NEW
920
    return val;
×
921
  }
922
  if (sdIsString(val)) {
×
923
    return val;
×
924
  }
925
  throw new BoxSdkError({
×
926
    message: "Can't deserialize CreateWebhookRequestBodyTriggersField",
927
  });
928
}
929
export function serializeCreateWebhookRequestBody(
231✔
930
  val: CreateWebhookRequestBody,
931
): SerializedData {
932
  return {
3✔
933
    ['target']: serializeCreateWebhookRequestBodyTargetField(val.target),
934
    ['address']: val.address,
935
    ['triggers']: val.triggers.map(function (
936
      item: CreateWebhookRequestBodyTriggersField,
937
    ): SerializedData {
938
      return serializeCreateWebhookRequestBodyTriggersField(item);
3✔
939
    }) as readonly any[],
940
  };
941
}
942
export function deserializeCreateWebhookRequestBody(
231✔
943
  val: SerializedData,
944
): CreateWebhookRequestBody {
945
  if (!sdIsMap(val)) {
×
946
    throw new BoxSdkError({
×
947
      message: 'Expecting a map for "CreateWebhookRequestBody"',
948
    });
949
  }
950
  if (val.target == void 0) {
×
951
    throw new BoxSdkError({
×
952
      message:
953
        'Expecting "target" of type "CreateWebhookRequestBody" to be defined',
954
    });
955
  }
956
  const target: CreateWebhookRequestBodyTargetField =
957
    deserializeCreateWebhookRequestBodyTargetField(val.target);
×
958
  if (val.address == void 0) {
×
959
    throw new BoxSdkError({
×
960
      message:
961
        'Expecting "address" of type "CreateWebhookRequestBody" to be defined',
962
    });
963
  }
964
  if (!sdIsString(val.address)) {
×
965
    throw new BoxSdkError({
×
966
      message:
967
        'Expecting string for "address" of type "CreateWebhookRequestBody"',
968
    });
969
  }
970
  const address: string = val.address;
×
971
  if (val.triggers == void 0) {
×
972
    throw new BoxSdkError({
×
973
      message:
974
        'Expecting "triggers" of type "CreateWebhookRequestBody" to be defined',
975
    });
976
  }
977
  if (!sdIsList(val.triggers)) {
×
978
    throw new BoxSdkError({
×
979
      message:
980
        'Expecting array for "triggers" of type "CreateWebhookRequestBody"',
981
    });
982
  }
983
  const triggers: readonly CreateWebhookRequestBodyTriggersField[] = sdIsList(
×
984
    val.triggers,
985
  )
986
    ? (val.triggers.map(function (
987
        itm: SerializedData,
988
      ): CreateWebhookRequestBodyTriggersField {
989
        return deserializeCreateWebhookRequestBodyTriggersField(itm);
×
990
      }) as readonly any[])
991
    : [];
992
  return {
×
993
    target: target,
994
    address: address,
995
    triggers: triggers,
996
  } satisfies CreateWebhookRequestBody;
997
}
998
export function serializeUpdateWebhookByIdRequestBodyTargetTypeField(
231✔
999
  val: UpdateWebhookByIdRequestBodyTargetTypeField,
1000
): SerializedData {
1001
  return val;
×
1002
}
1003
export function deserializeUpdateWebhookByIdRequestBodyTargetTypeField(
231✔
1004
  val: SerializedData,
1005
): UpdateWebhookByIdRequestBodyTargetTypeField {
1006
  if (val == 'file') {
×
1007
    return val;
×
1008
  }
1009
  if (val == 'folder') {
×
1010
    return val;
×
1011
  }
1012
  throw new BoxSdkError({
×
1013
    message: "Can't deserialize UpdateWebhookByIdRequestBodyTargetTypeField",
1014
  });
1015
}
1016
export function serializeUpdateWebhookByIdRequestBodyTargetField(
231✔
1017
  val: UpdateWebhookByIdRequestBodyTargetField,
1018
): SerializedData {
1019
  return {
×
1020
    ['id']: val.id,
1021
    ['type']:
1022
      val.type == void 0
×
1023
        ? val.type
1024
        : serializeUpdateWebhookByIdRequestBodyTargetTypeField(val.type),
1025
  };
1026
}
1027
export function deserializeUpdateWebhookByIdRequestBodyTargetField(
231✔
1028
  val: SerializedData,
1029
): UpdateWebhookByIdRequestBodyTargetField {
1030
  if (!sdIsMap(val)) {
×
1031
    throw new BoxSdkError({
×
1032
      message: 'Expecting a map for "UpdateWebhookByIdRequestBodyTargetField"',
1033
    });
1034
  }
1035
  if (!(val.id == void 0) && !sdIsString(val.id)) {
×
1036
    throw new BoxSdkError({
×
1037
      message:
1038
        'Expecting string for "id" of type "UpdateWebhookByIdRequestBodyTargetField"',
1039
    });
1040
  }
1041
  const id: undefined | string = val.id == void 0 ? void 0 : val.id;
×
1042
  const type: undefined | UpdateWebhookByIdRequestBodyTargetTypeField =
1043
    val.type == void 0
×
1044
      ? void 0
1045
      : deserializeUpdateWebhookByIdRequestBodyTargetTypeField(val.type);
1046
  return {
×
1047
    id: id,
1048
    type: type,
1049
  } satisfies UpdateWebhookByIdRequestBodyTargetField;
1050
}
1051
export function serializeUpdateWebhookByIdRequestBodyTriggersField(
231✔
1052
  val: UpdateWebhookByIdRequestBodyTriggersField,
1053
): SerializedData {
1054
  return val;
×
1055
}
1056
export function deserializeUpdateWebhookByIdRequestBodyTriggersField(
231✔
1057
  val: SerializedData,
1058
): UpdateWebhookByIdRequestBodyTriggersField {
1059
  if (val == 'FILE.UPLOADED') {
×
1060
    return val;
×
1061
  }
1062
  if (val == 'FILE.PREVIEWED') {
×
1063
    return val;
×
1064
  }
1065
  if (val == 'FILE.DOWNLOADED') {
×
1066
    return val;
×
1067
  }
1068
  if (val == 'FILE.TRASHED') {
×
1069
    return val;
×
1070
  }
1071
  if (val == 'FILE.DELETED') {
×
1072
    return val;
×
1073
  }
1074
  if (val == 'FILE.RESTORED') {
×
1075
    return val;
×
1076
  }
1077
  if (val == 'FILE.COPIED') {
×
1078
    return val;
×
1079
  }
1080
  if (val == 'FILE.MOVED') {
×
1081
    return val;
×
1082
  }
1083
  if (val == 'FILE.LOCKED') {
×
1084
    return val;
×
1085
  }
1086
  if (val == 'FILE.UNLOCKED') {
×
1087
    return val;
×
1088
  }
1089
  if (val == 'FILE.RENAMED') {
×
1090
    return val;
×
1091
  }
1092
  if (val == 'COMMENT.CREATED') {
×
1093
    return val;
×
1094
  }
1095
  if (val == 'COMMENT.UPDATED') {
×
1096
    return val;
×
1097
  }
1098
  if (val == 'COMMENT.DELETED') {
×
1099
    return val;
×
1100
  }
1101
  if (val == 'TASK_ASSIGNMENT.CREATED') {
×
1102
    return val;
×
1103
  }
1104
  if (val == 'TASK_ASSIGNMENT.UPDATED') {
×
1105
    return val;
×
1106
  }
1107
  if (val == 'METADATA_INSTANCE.CREATED') {
×
1108
    return val;
×
1109
  }
1110
  if (val == 'METADATA_INSTANCE.UPDATED') {
×
1111
    return val;
×
1112
  }
1113
  if (val == 'METADATA_INSTANCE.DELETED') {
×
1114
    return val;
×
1115
  }
1116
  if (val == 'FOLDER.CREATED') {
×
1117
    return val;
×
1118
  }
1119
  if (val == 'FOLDER.RENAMED') {
×
1120
    return val;
×
1121
  }
1122
  if (val == 'FOLDER.DOWNLOADED') {
×
1123
    return val;
×
1124
  }
1125
  if (val == 'FOLDER.RESTORED') {
×
1126
    return val;
×
1127
  }
1128
  if (val == 'FOLDER.DELETED') {
×
1129
    return val;
×
1130
  }
1131
  if (val == 'FOLDER.COPIED') {
×
1132
    return val;
×
1133
  }
1134
  if (val == 'FOLDER.MOVED') {
×
1135
    return val;
×
1136
  }
1137
  if (val == 'FOLDER.TRASHED') {
×
1138
    return val;
×
1139
  }
1140
  if (val == 'WEBHOOK.DELETED') {
×
1141
    return val;
×
1142
  }
1143
  if (val == 'COLLABORATION.CREATED') {
×
1144
    return val;
×
1145
  }
1146
  if (val == 'COLLABORATION.ACCEPTED') {
×
1147
    return val;
×
1148
  }
1149
  if (val == 'COLLABORATION.REJECTED') {
×
1150
    return val;
×
1151
  }
1152
  if (val == 'COLLABORATION.REMOVED') {
×
1153
    return val;
×
1154
  }
1155
  if (val == 'COLLABORATION.UPDATED') {
×
1156
    return val;
×
1157
  }
1158
  if (val == 'SHARED_LINK.DELETED') {
×
1159
    return val;
×
1160
  }
1161
  if (val == 'SHARED_LINK.CREATED') {
×
1162
    return val;
×
1163
  }
1164
  if (val == 'SHARED_LINK.UPDATED') {
×
1165
    return val;
×
1166
  }
1167
  if (val == 'SIGN_REQUEST.COMPLETED') {
×
1168
    return val;
×
1169
  }
1170
  if (val == 'SIGN_REQUEST.DECLINED') {
×
1171
    return val;
×
1172
  }
1173
  if (val == 'SIGN_REQUEST.EXPIRED') {
×
1174
    return val;
×
1175
  }
1176
  if (val == 'SIGN_REQUEST.SIGNER_EMAIL_BOUNCED') {
×
1177
    return val;
×
1178
  }
NEW
1179
  if (val == 'SIGN_REQUEST.SIGN_SIGNER_SIGNED') {
×
NEW
1180
    return val;
×
1181
  }
NEW
1182
  if (val == 'SIGN_REQUEST.SIGN_DOCUMENT_CREATED') {
×
NEW
1183
    return val;
×
1184
  }
NEW
1185
  if (val == 'SIGN_REQUEST.SIGN_ERROR_FINALIZING') {
×
NEW
1186
    return val;
×
1187
  }
1188
  if (sdIsString(val)) {
×
1189
    return val;
×
1190
  }
1191
  throw new BoxSdkError({
×
1192
    message: "Can't deserialize UpdateWebhookByIdRequestBodyTriggersField",
1193
  });
1194
}
1195
export function serializeUpdateWebhookByIdRequestBody(
231✔
1196
  val: UpdateWebhookByIdRequestBody,
1197
): SerializedData {
1198
  return {
3✔
1199
    ['target']:
1200
      val.target == void 0
3!
1201
        ? val.target
1202
        : serializeUpdateWebhookByIdRequestBodyTargetField(val.target),
1203
    ['address']: val.address,
1204
    ['triggers']:
1205
      val.triggers == void 0
3!
1206
        ? val.triggers
1207
        : (val.triggers.map(function (
1208
            item: UpdateWebhookByIdRequestBodyTriggersField,
1209
          ): SerializedData {
1210
            return serializeUpdateWebhookByIdRequestBodyTriggersField(item);
×
1211
          }) as readonly any[]),
1212
  };
1213
}
1214
export function deserializeUpdateWebhookByIdRequestBody(
231✔
1215
  val: SerializedData,
1216
): UpdateWebhookByIdRequestBody {
1217
  if (!sdIsMap(val)) {
×
1218
    throw new BoxSdkError({
×
1219
      message: 'Expecting a map for "UpdateWebhookByIdRequestBody"',
1220
    });
1221
  }
1222
  const target: undefined | UpdateWebhookByIdRequestBodyTargetField =
1223
    val.target == void 0
×
1224
      ? void 0
1225
      : deserializeUpdateWebhookByIdRequestBodyTargetField(val.target);
1226
  if (!(val.address == void 0) && !sdIsString(val.address)) {
×
1227
    throw new BoxSdkError({
×
1228
      message:
1229
        'Expecting string for "address" of type "UpdateWebhookByIdRequestBody"',
1230
    });
1231
  }
1232
  const address: undefined | string =
1233
    val.address == void 0 ? void 0 : val.address;
×
1234
  if (!(val.triggers == void 0) && !sdIsList(val.triggers)) {
×
1235
    throw new BoxSdkError({
×
1236
      message:
1237
        'Expecting array for "triggers" of type "UpdateWebhookByIdRequestBody"',
1238
    });
1239
  }
1240
  const triggers:
1241
    | undefined
1242
    | readonly UpdateWebhookByIdRequestBodyTriggersField[] =
1243
    val.triggers == void 0
×
1244
      ? void 0
1245
      : sdIsList(val.triggers)
×
1246
        ? (val.triggers.map(function (
1247
            itm: SerializedData,
1248
          ): UpdateWebhookByIdRequestBodyTriggersField {
1249
            return deserializeUpdateWebhookByIdRequestBodyTriggersField(itm);
×
1250
          }) as readonly any[])
1251
        : [];
1252
  return {
×
1253
    target: target,
1254
    address: address,
1255
    triggers: triggers,
1256
  } satisfies UpdateWebhookByIdRequestBody;
1257
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc