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

box / box-node-sdk / 19555963099

20 Nov 2025 03:38PM UTC coverage: 40.654% (-54.5%) from 95.198%
19555963099

push

github

web-flow
docs: Update Readme for migrating `sdk-gen` to main (box/box-codegen#889) (#1212)

4525 of 19644 branches covered (23.04%)

Branch coverage included in aggregate %.

16708 of 32584 relevant lines covered (51.28%)

140.69 hits per line

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

27.87
/src/managers/users.ts
1
import { serializeUsers } from '../schemas/users';
2
import { deserializeUsers } from '../schemas/users';
237✔
3
import { serializeClientError } from '../schemas/clientError';
4
import { deserializeClientError } from '../schemas/clientError';
5
import { serializeUserFull } from '../schemas/userFull';
6
import { deserializeUserFull } from '../schemas/userFull';
237✔
7
import { serializeTrackingCode } from '../schemas/trackingCode';
237✔
8
import { deserializeTrackingCode } from '../schemas/trackingCode';
237✔
9
import { ResponseFormat } from '../networking/fetchOptions';
10
import { Users } from '../schemas/users';
11
import { ClientError } from '../schemas/clientError';
12
import { UserFull } from '../schemas/userFull';
13
import { TrackingCode } from '../schemas/trackingCode';
14
import { BoxSdkError } from '../box/errors';
237✔
15
import { Authentication } from '../networking/auth';
16
import { NetworkSession } from '../networking/network';
237✔
17
import { FetchOptions } from '../networking/fetchOptions';
237✔
18
import { FetchResponse } from '../networking/fetchResponse';
19
import { prepareParams } from '../internal/utils';
237✔
20
import { toString } from '../internal/utils';
237✔
21
import { ByteStream } from '../internal/utils';
22
import { CancellationToken } from '../internal/utils';
23
import { sdToJson } from '../serialization/json';
24
import { SerializedData } from '../serialization/json';
25
import { sdIsEmpty } from '../serialization/json';
26
import { sdIsBoolean } from '../serialization/json';
237✔
27
import { sdIsNumber } from '../serialization/json';
237✔
28
import { sdIsString } from '../serialization/json';
237✔
29
import { sdIsList } from '../serialization/json';
237✔
30
import { sdIsMap } from '../serialization/json';
237✔
31
export class CreateUserOptionals {
237✔
32
  readonly queryParams: CreateUserQueryParams =
33✔
33
    {} satisfies CreateUserQueryParams;
34
  readonly headers: CreateUserHeaders = new CreateUserHeaders({});
33✔
35
  readonly cancellationToken?: CancellationToken = void 0;
33✔
36
  constructor(
37
    fields: Omit<
38
      CreateUserOptionals,
39
      'queryParams' | 'headers' | 'cancellationToken'
40
    > &
41
      Partial<
42
        Pick<
43
          CreateUserOptionals,
44
          'queryParams' | 'headers' | 'cancellationToken'
45
        >
46
      >,
47
  ) {
48
    if (fields.queryParams !== undefined) {
33!
49
      this.queryParams = fields.queryParams;
×
50
    }
51
    if (fields.headers !== undefined) {
33!
52
      this.headers = fields.headers;
×
53
    }
54
    if (fields.cancellationToken !== undefined) {
33!
55
      this.cancellationToken = fields.cancellationToken;
×
56
    }
57
  }
58
}
59
export interface CreateUserOptionalsInput {
60
  readonly queryParams?: CreateUserQueryParams;
61
  readonly headers?: CreateUserHeaders;
62
  readonly cancellationToken?: undefined | CancellationToken;
63
}
64
export class GetUserByIdOptionals {
237✔
65
  readonly queryParams: GetUserByIdQueryParams =
3✔
66
    {} satisfies GetUserByIdQueryParams;
67
  readonly headers: GetUserByIdHeaders = new GetUserByIdHeaders({});
3✔
68
  readonly cancellationToken?: CancellationToken = void 0;
3✔
69
  constructor(
70
    fields: Omit<
71
      GetUserByIdOptionals,
72
      'queryParams' | 'headers' | 'cancellationToken'
73
    > &
74
      Partial<
75
        Pick<
76
          GetUserByIdOptionals,
77
          'queryParams' | 'headers' | 'cancellationToken'
78
        >
79
      >,
80
  ) {
81
    if (fields.queryParams !== undefined) {
3!
82
      this.queryParams = fields.queryParams;
×
83
    }
84
    if (fields.headers !== undefined) {
3!
85
      this.headers = fields.headers;
×
86
    }
87
    if (fields.cancellationToken !== undefined) {
3!
88
      this.cancellationToken = fields.cancellationToken;
×
89
    }
90
  }
91
}
92
export interface GetUserByIdOptionalsInput {
93
  readonly queryParams?: GetUserByIdQueryParams;
94
  readonly headers?: GetUserByIdHeaders;
95
  readonly cancellationToken?: undefined | CancellationToken;
96
}
97
export class UpdateUserByIdOptionals {
237✔
98
  readonly requestBody: UpdateUserByIdRequestBody =
3✔
99
    {} satisfies UpdateUserByIdRequestBody;
100
  readonly queryParams: UpdateUserByIdQueryParams =
3✔
101
    {} satisfies UpdateUserByIdQueryParams;
102
  readonly headers: UpdateUserByIdHeaders = new UpdateUserByIdHeaders({});
3✔
103
  readonly cancellationToken?: CancellationToken = void 0;
3✔
104
  constructor(
105
    fields: Omit<
106
      UpdateUserByIdOptionals,
107
      'requestBody' | 'queryParams' | 'headers' | 'cancellationToken'
108
    > &
109
      Partial<
110
        Pick<
111
          UpdateUserByIdOptionals,
112
          'requestBody' | 'queryParams' | 'headers' | 'cancellationToken'
113
        >
114
      >,
115
  ) {
116
    if (fields.requestBody !== undefined) {
3✔
117
      this.requestBody = fields.requestBody;
3✔
118
    }
119
    if (fields.queryParams !== undefined) {
3!
120
      this.queryParams = fields.queryParams;
×
121
    }
122
    if (fields.headers !== undefined) {
3!
123
      this.headers = fields.headers;
×
124
    }
125
    if (fields.cancellationToken !== undefined) {
3!
126
      this.cancellationToken = fields.cancellationToken;
×
127
    }
128
  }
129
}
130
export interface UpdateUserByIdOptionalsInput {
131
  readonly requestBody?: UpdateUserByIdRequestBody;
132
  readonly queryParams?: UpdateUserByIdQueryParams;
133
  readonly headers?: UpdateUserByIdHeaders;
134
  readonly cancellationToken?: undefined | CancellationToken;
135
}
136
export class DeleteUserByIdOptionals {
237✔
137
  readonly queryParams: DeleteUserByIdQueryParams =
33✔
138
    {} satisfies DeleteUserByIdQueryParams;
139
  readonly headers: DeleteUserByIdHeaders = new DeleteUserByIdHeaders({});
33✔
140
  readonly cancellationToken?: CancellationToken = void 0;
33✔
141
  constructor(
142
    fields: Omit<
143
      DeleteUserByIdOptionals,
144
      'queryParams' | 'headers' | 'cancellationToken'
145
    > &
146
      Partial<
147
        Pick<
148
          DeleteUserByIdOptionals,
149
          'queryParams' | 'headers' | 'cancellationToken'
150
        >
151
      >,
152
  ) {
153
    if (fields.queryParams !== undefined) {
33✔
154
      this.queryParams = fields.queryParams;
3✔
155
    }
156
    if (fields.headers !== undefined) {
33!
157
      this.headers = fields.headers;
×
158
    }
159
    if (fields.cancellationToken !== undefined) {
33!
160
      this.cancellationToken = fields.cancellationToken;
×
161
    }
162
  }
163
}
164
export interface DeleteUserByIdOptionalsInput {
165
  readonly queryParams?: DeleteUserByIdQueryParams;
166
  readonly headers?: DeleteUserByIdHeaders;
167
  readonly cancellationToken?: undefined | CancellationToken;
168
}
169
export type GetUsersQueryParamsUserTypeField =
170
  | 'all'
171
  | 'managed'
172
  | 'external'
173
  | string;
174
export interface GetUsersQueryParams {
175
  /**
176
   * Limits the results to only users who's `name` or
177
   * `login` start with the search term.
178
   *
179
   * For externally managed users, the search term needs
180
   * to completely match the in order to find the user, and
181
   * it will only return one user at a time. */
182
  readonly filterTerm?: string;
183
  /**
184
   * Limits the results to the kind of user specified.
185
   *
186
   * * `all` returns every kind of user for whom the
187
   *   `login` or `name` partially matches the
188
   *   `filter_term`. It will only return an external user
189
   *   if the login matches the `filter_term` completely,
190
   *   and in that case it will only return that user.
191
   * * `managed` returns all managed and app users for whom
192
   *   the `login` or `name` partially matches the
193
   *   `filter_term`.
194
   * * `external` returns all external users for whom the
195
   *   `login` matches the `filter_term` exactly. */
196
  readonly userType?: GetUsersQueryParamsUserTypeField;
197
  /**
198
   * Limits the results to app users with the given
199
   * `external_app_user_id` value.
200
   *
201
   * When creating an app user, an
202
   * `external_app_user_id` value can be set. This value can
203
   * then be used in this endpoint to find any users that
204
   * match that `external_app_user_id` value. */
205
  readonly externalAppUserId?: string;
206
  /**
207
   * A comma-separated list of attributes to include in the
208
   * response. This can be used to request fields that are
209
   * not normally returned in a standard response.
210
   *
211
   * Be aware that specifying this parameter will have the
212
   * effect that none of the standard fields are returned in
213
   * the response unless explicitly specified, instead only
214
   * fields for the mini representation are returned, additional
215
   * to the fields requested. */
216
  readonly fields?: readonly string[];
217
  /**
218
   * The offset of the item at which to begin the response.
219
   *
220
   * Queries with offset parameter value
221
   * exceeding 10000 will be rejected
222
   * with a 400 response. */
223
  readonly offset?: number;
224
  /**
225
   * The maximum number of items to return per page. */
226
  readonly limit?: number;
227
  /**
228
   * Specifies whether to use marker-based pagination instead of
229
   * offset-based pagination. Only one pagination method can
230
   * be used at a time.
231
   *
232
   * By setting this value to true, the API will return a `marker` field
233
   * that can be passed as a parameter to this endpoint to get the next
234
   * page of the response. */
235
  readonly usemarker?: boolean;
236
  /**
237
   * Defines the position marker at which to begin returning results. This is
238
   * used when paginating using marker-based pagination.
239
   *
240
   * This requires `usemarker` to be set to `true`. */
241
  readonly marker?: string;
242
}
243
export class GetUsersHeaders {
237✔
244
  /**
245
   * Extra headers that will be included in the HTTP request. */
246
  readonly extraHeaders?: {
6✔
247
    readonly [key: string]: undefined | string;
248
  } = {};
249
  constructor(
250
    fields: Omit<GetUsersHeaders, 'extraHeaders'> &
251
      Partial<Pick<GetUsersHeaders, 'extraHeaders'>>,
252
  ) {
253
    if (fields.extraHeaders !== undefined) {
6✔
254
      this.extraHeaders = fields.extraHeaders;
3✔
255
    }
256
  }
257
}
258
export interface GetUsersHeadersInput {
259
  /**
260
   * Extra headers that will be included in the HTTP request. */
261
  readonly extraHeaders?:
262
    | undefined
263
    | {
264
        readonly [key: string]: undefined | string;
265
      };
266
}
267
export type CreateUserRequestBodyRoleField = 'coadmin' | 'user' | string;
268
export type CreateUserRequestBodyStatusField =
269
  | 'active'
270
  | 'inactive'
271
  | 'cannot_delete_edit'
272
  | 'cannot_delete_edit_upload'
273
  | string;
274
export interface CreateUserRequestBody {
275
  /**
276
   * The name of the user. */
277
  readonly name: string;
278
  /**
279
   * The email address the user uses to log in
280
   *
281
   * Required, unless `is_platform_access_only`
282
   * is set to `true`. */
283
  readonly login?: string;
284
  /**
285
   * Specifies that the user is an app user. */
286
  readonly isPlatformAccessOnly?: boolean;
287
  /**
288
   * The user’s enterprise role. */
289
  readonly role?: CreateUserRequestBodyRoleField;
290
  /**
291
   * The language of the user, formatted in modified version of the
292
   * [ISO 639-1](/guides/api-calls/language-codes) format. */
293
  readonly language?: string;
294
  /**
295
   * Whether the user can use Box Sync. */
296
  readonly isSyncEnabled?: boolean;
297
  /**
298
   * The user’s job title. */
299
  readonly jobTitle?: string;
300
  /**
301
   * The user’s phone number. */
302
  readonly phone?: string;
303
  /**
304
   * The user’s address. */
305
  readonly address?: string;
306
  /**
307
   * The user’s total available space in bytes. Set this to `-1` to
308
   * indicate unlimited storage. */
309
  readonly spaceAmount?: number;
310
  /**
311
   * Tracking codes allow an admin to generate reports from the
312
   * admin console and assign an attribute to a specific group
313
   * of users. This setting must be enabled for an enterprise before it
314
   * can be used. */
315
  readonly trackingCodes?: readonly TrackingCode[];
316
  /**
317
   * Whether the user can see other enterprise users in their
318
   * contact list. */
319
  readonly canSeeManagedUsers?: boolean;
320
  /**
321
   * The user's timezone. */
322
  readonly timezone?: string;
323
  /**
324
   * Whether the user is allowed to collaborate with users outside
325
   * their enterprise. */
326
  readonly isExternalCollabRestricted?: boolean;
327
  /**
328
   * Whether to exempt the user from enterprise device limits. */
329
  readonly isExemptFromDeviceLimits?: boolean;
330
  /**
331
   * Whether the user must use two-factor authentication. */
332
  readonly isExemptFromLoginVerification?: boolean;
333
  /**
334
   * The user's account status. */
335
  readonly status?: CreateUserRequestBodyStatusField;
336
  /**
337
   * An external identifier for an app user, which can be used to look
338
   * up the user. This can be used to tie user IDs from external
339
   * identity providers to Box users. */
340
  readonly externalAppUserId?: string;
341
  readonly rawData?: SerializedData;
342
}
343
export interface CreateUserQueryParams {
344
  /**
345
   * A comma-separated list of attributes to include in the
346
   * response. This can be used to request fields that are
347
   * not normally returned in a standard response.
348
   *
349
   * Be aware that specifying this parameter will have the
350
   * effect that none of the standard fields are returned in
351
   * the response unless explicitly specified, instead only
352
   * fields for the mini representation are returned, additional
353
   * to the fields requested. */
354
  readonly fields?: readonly string[];
355
}
356
export class CreateUserHeaders {
237✔
357
  /**
358
   * Extra headers that will be included in the HTTP request. */
359
  readonly extraHeaders?: {
33✔
360
    readonly [key: string]: undefined | string;
361
  } = {};
362
  constructor(
363
    fields: Omit<CreateUserHeaders, 'extraHeaders'> &
364
      Partial<Pick<CreateUserHeaders, 'extraHeaders'>>,
365
  ) {
366
    if (fields.extraHeaders !== undefined) {
33!
367
      this.extraHeaders = fields.extraHeaders;
×
368
    }
369
  }
370
}
371
export interface CreateUserHeadersInput {
372
  /**
373
   * Extra headers that will be included in the HTTP request. */
374
  readonly extraHeaders?:
375
    | undefined
376
    | {
377
        readonly [key: string]: undefined | string;
378
      };
379
}
380
export interface GetUserMeQueryParams {
381
  /**
382
   * A comma-separated list of attributes to include in the
383
   * response. This can be used to request fields that are
384
   * not normally returned in a standard response.
385
   *
386
   * Be aware that specifying this parameter will have the
387
   * effect that none of the standard fields are returned in
388
   * the response unless explicitly specified, instead only
389
   * fields for the mini representation are returned, additional
390
   * to the fields requested. */
391
  readonly fields?: readonly string[];
392
}
393
export class GetUserMeHeaders {
237✔
394
  /**
395
   * Extra headers that will be included in the HTTP request. */
396
  readonly extraHeaders?: {
144✔
397
    readonly [key: string]: undefined | string;
398
  } = {};
399
  constructor(
400
    fields: Omit<GetUserMeHeaders, 'extraHeaders'> &
401
      Partial<Pick<GetUserMeHeaders, 'extraHeaders'>>,
402
  ) {
403
    if (fields.extraHeaders !== undefined) {
144✔
404
      this.extraHeaders = fields.extraHeaders;
72✔
405
    }
406
  }
407
}
408
export interface GetUserMeHeadersInput {
409
  /**
410
   * Extra headers that will be included in the HTTP request. */
411
  readonly extraHeaders?:
412
    | undefined
413
    | {
414
        readonly [key: string]: undefined | string;
415
      };
416
}
417
export interface GetUserByIdQueryParams {
418
  /**
419
   * A comma-separated list of attributes to include in the
420
   * response. This can be used to request fields that are
421
   * not normally returned in a standard response.
422
   *
423
   * Be aware that specifying this parameter will have the
424
   * effect that none of the standard fields are returned in
425
   * the response unless explicitly specified, instead only
426
   * fields for the mini representation are returned, additional
427
   * to the fields requested. */
428
  readonly fields?: readonly string[];
429
}
430
export class GetUserByIdHeaders {
237✔
431
  /**
432
   * Extra headers that will be included in the HTTP request. */
433
  readonly extraHeaders?: {
3✔
434
    readonly [key: string]: undefined | string;
435
  } = {};
436
  constructor(
437
    fields: Omit<GetUserByIdHeaders, 'extraHeaders'> &
438
      Partial<Pick<GetUserByIdHeaders, 'extraHeaders'>>,
439
  ) {
440
    if (fields.extraHeaders !== undefined) {
3!
441
      this.extraHeaders = fields.extraHeaders;
×
442
    }
443
  }
444
}
445
export interface GetUserByIdHeadersInput {
446
  /**
447
   * Extra headers that will be included in the HTTP request. */
448
  readonly extraHeaders?:
449
    | undefined
450
    | {
451
        readonly [key: string]: undefined | string;
452
      };
453
}
454
export type UpdateUserByIdRequestBodyRoleField = 'coadmin' | 'user' | string;
455
export type UpdateUserByIdRequestBodyStatusField =
456
  | 'active'
457
  | 'inactive'
458
  | 'cannot_delete_edit'
459
  | 'cannot_delete_edit_upload'
460
  | string;
461
export interface UpdateUserByIdRequestBodyNotificationEmailField {
462
  /**
463
   * The email address to send the notifications to. */
464
  readonly email?: string;
465
  readonly rawData?: SerializedData;
466
}
467
export interface UpdateUserByIdRequestBody {
468
  /**
469
   * Set this to `null` to roll the user out of the enterprise
470
   * and make them a free user. */
471
  readonly enterprise?: string | null;
472
  /**
473
   * Whether the user should receive an email when they
474
   * are rolled out of an enterprise. */
475
  readonly notify?: boolean;
476
  /**
477
   * The name of the user. */
478
  readonly name?: string;
479
  /**
480
   * The email address the user uses to log in
481
   *
482
   * Note: If the target user's email is not confirmed, then the
483
   * primary login address cannot be changed. */
484
  readonly login?: string;
485
  /**
486
   * The user’s enterprise role. */
487
  readonly role?: UpdateUserByIdRequestBodyRoleField;
488
  /**
489
   * The language of the user, formatted in modified version of the
490
   * [ISO 639-1](/guides/api-calls/language-codes) format. */
491
  readonly language?: string;
492
  /**
493
   * Whether the user can use Box Sync. */
494
  readonly isSyncEnabled?: boolean;
495
  /**
496
   * The user’s job title. */
497
  readonly jobTitle?: string;
498
  /**
499
   * The user’s phone number. */
500
  readonly phone?: string;
501
  /**
502
   * The user’s address. */
503
  readonly address?: string;
504
  /**
505
   * Tracking codes allow an admin to generate reports from the
506
   * admin console and assign an attribute to a specific group
507
   * of users. This setting must be enabled for an enterprise before it
508
   * can be used. */
509
  readonly trackingCodes?: readonly TrackingCode[];
510
  /**
511
   * Whether the user can see other enterprise users in their
512
   * contact list. */
513
  readonly canSeeManagedUsers?: boolean;
514
  /**
515
   * The user's timezone. */
516
  readonly timezone?: string;
517
  /**
518
   * Whether the user is allowed to collaborate with users outside
519
   * their enterprise. */
520
  readonly isExternalCollabRestricted?: boolean;
521
  /**
522
   * Whether to exempt the user from enterprise device limits. */
523
  readonly isExemptFromDeviceLimits?: boolean;
524
  /**
525
   * Whether the user must use two-factor authentication. */
526
  readonly isExemptFromLoginVerification?: boolean;
527
  /**
528
   * Whether the user is required to reset their password. */
529
  readonly isPasswordResetRequired?: boolean;
530
  /**
531
   * The user's account status. */
532
  readonly status?: UpdateUserByIdRequestBodyStatusField;
533
  /**
534
   * The user’s total available space in bytes. Set this to `-1` to
535
   * indicate unlimited storage. */
536
  readonly spaceAmount?: number;
537
  /**
538
   * An alternate notification email address to which email
539
   * notifications are sent. When it's confirmed, this will be
540
   * the email address to which notifications are sent instead of
541
   * to the primary email address.
542
   *
543
   * Set this value to `null` to remove the notification email. */
544
  readonly notificationEmail?: UpdateUserByIdRequestBodyNotificationEmailField | null;
545
  /**
546
   * An external identifier for an app user, which can be used to look
547
   * up the user. This can be used to tie user IDs from external
548
   * identity providers to Box users.
549
   *
550
   * Note: In order to update this field, you need to request a token
551
   * using the application that created the app user. */
552
  readonly externalAppUserId?: string;
553
  readonly rawData?: SerializedData;
554
}
555
export interface UpdateUserByIdQueryParams {
556
  /**
557
   * A comma-separated list of attributes to include in the
558
   * response. This can be used to request fields that are
559
   * not normally returned in a standard response.
560
   *
561
   * Be aware that specifying this parameter will have the
562
   * effect that none of the standard fields are returned in
563
   * the response unless explicitly specified, instead only
564
   * fields for the mini representation are returned, additional
565
   * to the fields requested. */
566
  readonly fields?: readonly string[];
567
}
568
export class UpdateUserByIdHeaders {
237✔
569
  /**
570
   * Extra headers that will be included in the HTTP request. */
571
  readonly extraHeaders?: {
3✔
572
    readonly [key: string]: undefined | string;
573
  } = {};
574
  constructor(
575
    fields: Omit<UpdateUserByIdHeaders, 'extraHeaders'> &
576
      Partial<Pick<UpdateUserByIdHeaders, 'extraHeaders'>>,
577
  ) {
578
    if (fields.extraHeaders !== undefined) {
3!
579
      this.extraHeaders = fields.extraHeaders;
×
580
    }
581
  }
582
}
583
export interface UpdateUserByIdHeadersInput {
584
  /**
585
   * Extra headers that will be included in the HTTP request. */
586
  readonly extraHeaders?:
587
    | undefined
588
    | {
589
        readonly [key: string]: undefined | string;
590
      };
591
}
592
export interface DeleteUserByIdQueryParams {
593
  /**
594
   * Whether the user will receive email notification of
595
   * the deletion. */
596
  readonly notify?: boolean;
597
  /**
598
   * Specifies whether to delete the user even if they still own files,
599
   * were recently active, or recently joined the enterprise from a free account. */
600
  readonly force?: boolean;
601
}
602
export class DeleteUserByIdHeaders {
237✔
603
  /**
604
   * Extra headers that will be included in the HTTP request. */
605
  readonly extraHeaders?: {
33✔
606
    readonly [key: string]: undefined | string;
607
  } = {};
608
  constructor(
609
    fields: Omit<DeleteUserByIdHeaders, 'extraHeaders'> &
610
      Partial<Pick<DeleteUserByIdHeaders, 'extraHeaders'>>,
611
  ) {
612
    if (fields.extraHeaders !== undefined) {
33!
613
      this.extraHeaders = fields.extraHeaders;
×
614
    }
615
  }
616
}
617
export interface DeleteUserByIdHeadersInput {
618
  /**
619
   * Extra headers that will be included in the HTTP request. */
620
  readonly extraHeaders?:
621
    | undefined
622
    | {
623
        readonly [key: string]: undefined | string;
624
      };
625
}
626
export class UsersManager {
237✔
627
  readonly auth?: Authentication;
628
  readonly networkSession: NetworkSession = new NetworkSession({});
510✔
629
  constructor(
630
    fields: Omit<
631
      UsersManager,
632
      | 'networkSession'
633
      | 'getUsers'
634
      | 'createUser'
635
      | 'getUserMe'
636
      | 'getUserById'
637
      | 'updateUserById'
638
      | 'deleteUserById'
639
    > &
640
      Partial<Pick<UsersManager, 'networkSession'>>,
641
  ) {
642
    if (fields.auth !== undefined) {
510✔
643
      this.auth = fields.auth;
510✔
644
    }
645
    if (fields.networkSession !== undefined) {
510✔
646
      this.networkSession = fields.networkSession;
510✔
647
    }
648
  }
649
  /**
650
   * Returns a list of all users for the Enterprise along with their `user_id`,
651
   * `public_name`, and `login`.
652
   *
653
   * The application and the authenticated user need to
654
   * have the permission to look up users in the entire
655
   * enterprise.
656
   * @param {GetUsersQueryParams} queryParams Query parameters of getUsers method
657
   * @param {GetUsersHeadersInput} headersInput Headers of getUsers method
658
   * @param {CancellationToken} cancellationToken Token used for request cancellation.
659
   * @returns {Promise<Users>}
660
   */
661
  async getUsers(
662
    queryParams: GetUsersQueryParams = {} satisfies GetUsersQueryParams,
3✔
663
    headersInput: GetUsersHeadersInput = new GetUsersHeaders({}),
3✔
664
    cancellationToken?: CancellationToken,
665
  ): Promise<Users> {
666
    const headers: GetUsersHeaders = new GetUsersHeaders({
3✔
667
      extraHeaders: headersInput.extraHeaders,
668
    });
669
    const queryParamsMap: {
670
      readonly [key: string]: string;
671
    } = prepareParams({
3✔
672
      ['filter_term']: toString(queryParams.filterTerm) as string,
673
      ['user_type']: toString(queryParams.userType) as string,
674
      ['external_app_user_id']: toString(
675
        queryParams.externalAppUserId,
676
      ) as string,
677
      ['fields']: queryParams.fields
3!
678
        ? queryParams.fields.map(toString).join(',')
679
        : undefined,
680
      ['offset']: toString(queryParams.offset) as string,
681
      ['limit']: toString(queryParams.limit) as string,
682
      ['usemarker']: toString(queryParams.usemarker) as string,
683
      ['marker']: toString(queryParams.marker) as string,
684
    });
685
    const headersMap: {
686
      readonly [key: string]: string;
687
    } = prepareParams({ ...{}, ...headers.extraHeaders });
3✔
688
    const response: FetchResponse =
689
      await this.networkSession.networkClient.fetch(
3✔
690
        new FetchOptions({
691
          url: ''.concat(
692
            this.networkSession.baseUrls.baseUrl,
693
            '/2.0/users',
694
          ) as string,
695
          method: 'GET',
696
          params: queryParamsMap,
697
          headers: headersMap,
698
          responseFormat: 'json' as ResponseFormat,
699
          auth: this.auth,
700
          networkSession: this.networkSession,
701
          cancellationToken: cancellationToken,
702
        }),
703
      );
704
    return {
3✔
705
      ...deserializeUsers(response.data!),
706
      rawData: response.data!,
707
    };
708
  }
709
  /**
710
   * Creates a new managed user in an enterprise. This endpoint
711
   * is only available to users and applications with the right
712
   * admin permissions.
713
   * @param {CreateUserRequestBody} requestBody Request body of createUser method
714
   * @param {CreateUserOptionalsInput} optionalsInput
715
   * @returns {Promise<UserFull>}
716
   */
717
  async createUser(
718
    requestBody: CreateUserRequestBody,
33✔
719
    optionalsInput: CreateUserOptionalsInput = {},
33✔
720
  ): Promise<UserFull> {
721
    const optionals: CreateUserOptionals = new CreateUserOptionals({
33✔
722
      queryParams: optionalsInput.queryParams,
723
      headers: optionalsInput.headers,
724
      cancellationToken: optionalsInput.cancellationToken,
725
    });
726
    const queryParams: any = optionals.queryParams;
33✔
727
    const headers: any = optionals.headers;
33✔
728
    const cancellationToken: any = optionals.cancellationToken;
33✔
729
    const queryParamsMap: {
730
      readonly [key: string]: string;
731
    } = prepareParams({
33✔
732
      ['fields']: queryParams.fields
33!
733
        ? queryParams.fields.map(toString).join(',')
734
        : undefined,
735
    });
736
    const headersMap: {
737
      readonly [key: string]: string;
738
    } = prepareParams({ ...{}, ...headers.extraHeaders });
33✔
739
    const response: FetchResponse =
740
      await this.networkSession.networkClient.fetch(
33✔
741
        new FetchOptions({
742
          url: ''.concat(
743
            this.networkSession.baseUrls.baseUrl,
744
            '/2.0/users',
745
          ) as string,
746
          method: 'POST',
747
          params: queryParamsMap,
748
          headers: headersMap,
749
          data: serializeCreateUserRequestBody(requestBody),
750
          contentType: 'application/json',
751
          responseFormat: 'json' as ResponseFormat,
752
          auth: this.auth,
753
          networkSession: this.networkSession,
754
          cancellationToken: cancellationToken,
755
        }),
756
      );
757
    return {
33✔
758
      ...deserializeUserFull(response.data!),
759
      rawData: response.data!,
760
    };
761
  }
762
  /**
763
   * Retrieves information about the user who is currently authenticated.
764
   *
765
   * In the case of a client-side authenticated OAuth 2.0 application
766
   * this will be the user who authorized the app.
767
   *
768
   * In the case of a JWT, server-side authenticated application
769
   * this will be the service account that belongs to the application
770
   * by default.
771
   *
772
   * Use the `As-User` header to change who this API call is made on behalf of.
773
   * @param {GetUserMeQueryParams} queryParams Query parameters of getUserMe method
774
   * @param {GetUserMeHeadersInput} headersInput Headers of getUserMe method
775
   * @param {CancellationToken} cancellationToken Token used for request cancellation.
776
   * @returns {Promise<UserFull>}
777
   */
778
  async getUserMe(
779
    queryParams: GetUserMeQueryParams = {} satisfies GetUserMeQueryParams,
72✔
780
    headersInput: GetUserMeHeadersInput = new GetUserMeHeaders({}),
72✔
781
    cancellationToken?: CancellationToken,
782
  ): Promise<UserFull> {
783
    const headers: GetUserMeHeaders = new GetUserMeHeaders({
72✔
784
      extraHeaders: headersInput.extraHeaders,
785
    });
786
    const queryParamsMap: {
787
      readonly [key: string]: string;
788
    } = prepareParams({
72✔
789
      ['fields']: queryParams.fields
72✔
790
        ? queryParams.fields.map(toString).join(',')
791
        : undefined,
792
    });
793
    const headersMap: {
794
      readonly [key: string]: string;
795
    } = prepareParams({ ...{}, ...headers.extraHeaders });
72✔
796
    const response: FetchResponse =
797
      await this.networkSession.networkClient.fetch(
72✔
798
        new FetchOptions({
799
          url: ''.concat(
800
            this.networkSession.baseUrls.baseUrl,
801
            '/2.0/users/me',
802
          ) as string,
803
          method: 'GET',
804
          params: queryParamsMap,
805
          headers: headersMap,
806
          responseFormat: 'json' as ResponseFormat,
807
          auth: this.auth,
808
          networkSession: this.networkSession,
809
          cancellationToken: cancellationToken,
810
        }),
811
      );
812
    return {
63✔
813
      ...deserializeUserFull(response.data!),
814
      rawData: response.data!,
815
    };
816
  }
817
  /**
818
     * Retrieves information about a user in the enterprise.
819
     *
820
     * The application and the authenticated user need to
821
     * have the permission to look up users in the entire
822
     * enterprise.
823
     *
824
     * This endpoint also returns a limited set of information
825
     * for external users who are collaborated on content
826
     * owned by the enterprise for authenticated users with the
827
     * right scopes. In this case, disallowed fields will return
828
     * null instead.
829
     * @param {string} userId The ID of the user.
830
    Example: "12345"
831
     * @param {GetUserByIdOptionalsInput} optionalsInput
832
     * @returns {Promise<UserFull>}
833
     */
834
  async getUserById(
835
    userId: string,
3✔
836
    optionalsInput: GetUserByIdOptionalsInput = {},
3✔
837
  ): Promise<UserFull> {
838
    const optionals: GetUserByIdOptionals = new GetUserByIdOptionals({
3✔
839
      queryParams: optionalsInput.queryParams,
840
      headers: optionalsInput.headers,
841
      cancellationToken: optionalsInput.cancellationToken,
842
    });
843
    const queryParams: any = optionals.queryParams;
3✔
844
    const headers: any = optionals.headers;
3✔
845
    const cancellationToken: any = optionals.cancellationToken;
3✔
846
    const queryParamsMap: {
847
      readonly [key: string]: string;
848
    } = prepareParams({
3✔
849
      ['fields']: queryParams.fields
3!
850
        ? queryParams.fields.map(toString).join(',')
851
        : undefined,
852
    });
853
    const headersMap: {
854
      readonly [key: string]: string;
855
    } = prepareParams({ ...{}, ...headers.extraHeaders });
3✔
856
    const response: FetchResponse =
857
      await this.networkSession.networkClient.fetch(
3✔
858
        new FetchOptions({
859
          url: ''.concat(
860
            this.networkSession.baseUrls.baseUrl,
861
            '/2.0/users/',
862
            toString(userId) as string,
863
          ) as string,
864
          method: 'GET',
865
          params: queryParamsMap,
866
          headers: headersMap,
867
          responseFormat: 'json' as ResponseFormat,
868
          auth: this.auth,
869
          networkSession: this.networkSession,
870
          cancellationToken: cancellationToken,
871
        }),
872
      );
873
    return {
3✔
874
      ...deserializeUserFull(response.data!),
875
      rawData: response.data!,
876
    };
877
  }
878
  /**
879
     * Updates a managed or app user in an enterprise. This endpoint
880
     * is only available to users and applications with the right
881
     * admin permissions.
882
     * @param {string} userId The ID of the user.
883
    Example: "12345"
884
     * @param {UpdateUserByIdOptionalsInput} optionalsInput
885
     * @returns {Promise<UserFull>}
886
     */
887
  async updateUserById(
888
    userId: string,
3✔
889
    optionalsInput: UpdateUserByIdOptionalsInput = {},
×
890
  ): Promise<UserFull> {
891
    const optionals: UpdateUserByIdOptionals = new UpdateUserByIdOptionals({
3✔
892
      requestBody: optionalsInput.requestBody,
893
      queryParams: optionalsInput.queryParams,
894
      headers: optionalsInput.headers,
895
      cancellationToken: optionalsInput.cancellationToken,
896
    });
897
    const requestBody: any = optionals.requestBody;
3✔
898
    const queryParams: any = optionals.queryParams;
3✔
899
    const headers: any = optionals.headers;
3✔
900
    const cancellationToken: any = optionals.cancellationToken;
3✔
901
    const queryParamsMap: {
902
      readonly [key: string]: string;
903
    } = prepareParams({
3✔
904
      ['fields']: queryParams.fields
3!
905
        ? queryParams.fields.map(toString).join(',')
906
        : undefined,
907
    });
908
    const headersMap: {
909
      readonly [key: string]: string;
910
    } = prepareParams({ ...{}, ...headers.extraHeaders });
3✔
911
    const response: FetchResponse =
912
      await this.networkSession.networkClient.fetch(
3✔
913
        new FetchOptions({
914
          url: ''.concat(
915
            this.networkSession.baseUrls.baseUrl,
916
            '/2.0/users/',
917
            toString(userId) as string,
918
          ) as string,
919
          method: 'PUT',
920
          params: queryParamsMap,
921
          headers: headersMap,
922
          data: serializeUpdateUserByIdRequestBody(requestBody),
923
          contentType: 'application/json',
924
          responseFormat: 'json' as ResponseFormat,
925
          auth: this.auth,
926
          networkSession: this.networkSession,
927
          cancellationToken: cancellationToken,
928
        }),
929
      );
930
    return {
3✔
931
      ...deserializeUserFull(response.data!),
932
      rawData: response.data!,
933
    };
934
  }
935
  /**
936
     * Deletes a user. By default, this operation fails if the user
937
     * still owns any content, was recently active, or recently joined the enterprise from a free account.
938
     * To proceed, move their owned content first, or use the `force` parameter to delete
939
     * the user and their files.
940
     * @param {string} userId The ID of the user.
941
    Example: "12345"
942
     * @param {DeleteUserByIdOptionalsInput} optionalsInput
943
     * @returns {Promise<undefined>}
944
     */
945
  async deleteUserById(
946
    userId: string,
33✔
947
    optionalsInput: DeleteUserByIdOptionalsInput = {},
30✔
948
  ): Promise<undefined> {
949
    const optionals: DeleteUserByIdOptionals = new DeleteUserByIdOptionals({
33✔
950
      queryParams: optionalsInput.queryParams,
951
      headers: optionalsInput.headers,
952
      cancellationToken: optionalsInput.cancellationToken,
953
    });
954
    const queryParams: any = optionals.queryParams;
33✔
955
    const headers: any = optionals.headers;
33✔
956
    const cancellationToken: any = optionals.cancellationToken;
33✔
957
    const queryParamsMap: {
958
      readonly [key: string]: string;
959
    } = prepareParams({
33✔
960
      ['notify']: toString(queryParams.notify) as string,
961
      ['force']: toString(queryParams.force) as string,
962
    });
963
    const headersMap: {
964
      readonly [key: string]: string;
965
    } = prepareParams({ ...{}, ...headers.extraHeaders });
33✔
966
    const response: FetchResponse =
967
      await this.networkSession.networkClient.fetch(
33✔
968
        new FetchOptions({
969
          url: ''.concat(
970
            this.networkSession.baseUrls.baseUrl,
971
            '/2.0/users/',
972
            toString(userId) as string,
973
          ) as string,
974
          method: 'DELETE',
975
          params: queryParamsMap,
976
          headers: headersMap,
977
          responseFormat: 'no_content' as ResponseFormat,
978
          auth: this.auth,
979
          networkSession: this.networkSession,
980
          cancellationToken: cancellationToken,
981
        }),
982
      );
983
    return void 0;
33✔
984
  }
985
}
986
export interface UsersManagerInput {
987
  readonly auth?: Authentication;
988
  readonly networkSession?: NetworkSession;
989
}
990
export function serializeGetUsersQueryParamsUserTypeField(
237✔
991
  val: GetUsersQueryParamsUserTypeField,
992
): SerializedData {
993
  return val;
×
994
}
995
export function deserializeGetUsersQueryParamsUserTypeField(
237✔
996
  val: SerializedData,
997
): GetUsersQueryParamsUserTypeField {
998
  if (val == 'all') {
×
999
    return val;
×
1000
  }
1001
  if (val == 'managed') {
×
1002
    return val;
×
1003
  }
1004
  if (val == 'external') {
×
1005
    return val;
×
1006
  }
1007
  if (sdIsString(val)) {
×
1008
    return val;
×
1009
  }
1010
  throw new BoxSdkError({
×
1011
    message: "Can't deserialize GetUsersQueryParamsUserTypeField",
1012
  });
1013
}
1014
export function serializeCreateUserRequestBodyRoleField(
237✔
1015
  val: CreateUserRequestBodyRoleField,
1016
): SerializedData {
1017
  return val;
×
1018
}
1019
export function deserializeCreateUserRequestBodyRoleField(
237✔
1020
  val: SerializedData,
1021
): CreateUserRequestBodyRoleField {
1022
  if (val == 'coadmin') {
×
1023
    return val;
×
1024
  }
1025
  if (val == 'user') {
×
1026
    return val;
×
1027
  }
1028
  if (sdIsString(val)) {
×
1029
    return val;
×
1030
  }
1031
  throw new BoxSdkError({
×
1032
    message: "Can't deserialize CreateUserRequestBodyRoleField",
1033
  });
1034
}
1035
export function serializeCreateUserRequestBodyStatusField(
237✔
1036
  val: CreateUserRequestBodyStatusField,
1037
): SerializedData {
1038
  return val;
×
1039
}
1040
export function deserializeCreateUserRequestBodyStatusField(
237✔
1041
  val: SerializedData,
1042
): CreateUserRequestBodyStatusField {
1043
  if (val == 'active') {
×
1044
    return val;
×
1045
  }
1046
  if (val == 'inactive') {
×
1047
    return val;
×
1048
  }
1049
  if (val == 'cannot_delete_edit') {
×
1050
    return val;
×
1051
  }
1052
  if (val == 'cannot_delete_edit_upload') {
×
1053
    return val;
×
1054
  }
1055
  if (sdIsString(val)) {
×
1056
    return val;
×
1057
  }
1058
  throw new BoxSdkError({
×
1059
    message: "Can't deserialize CreateUserRequestBodyStatusField",
1060
  });
1061
}
1062
export function serializeCreateUserRequestBody(
237✔
1063
  val: CreateUserRequestBody,
1064
): SerializedData {
1065
  return {
33✔
1066
    ['name']: val.name,
1067
    ['login']: val.login,
1068
    ['is_platform_access_only']: val.isPlatformAccessOnly,
1069
    ['role']:
1070
      val.role == void 0
33!
1071
        ? val.role
1072
        : serializeCreateUserRequestBodyRoleField(val.role),
1073
    ['language']: val.language,
1074
    ['is_sync_enabled']: val.isSyncEnabled,
1075
    ['job_title']: val.jobTitle,
1076
    ['phone']: val.phone,
1077
    ['address']: val.address,
1078
    ['space_amount']: val.spaceAmount,
1079
    ['tracking_codes']:
1080
      val.trackingCodes == void 0
33!
1081
        ? val.trackingCodes
1082
        : (val.trackingCodes.map(function (item: TrackingCode): SerializedData {
1083
            return serializeTrackingCode(item);
×
1084
          }) as readonly any[]),
1085
    ['can_see_managed_users']: val.canSeeManagedUsers,
1086
    ['timezone']: val.timezone,
1087
    ['is_external_collab_restricted']: val.isExternalCollabRestricted,
1088
    ['is_exempt_from_device_limits']: val.isExemptFromDeviceLimits,
1089
    ['is_exempt_from_login_verification']: val.isExemptFromLoginVerification,
1090
    ['status']:
1091
      val.status == void 0
33!
1092
        ? val.status
1093
        : serializeCreateUserRequestBodyStatusField(val.status),
1094
    ['external_app_user_id']: val.externalAppUserId,
1095
  };
1096
}
1097
export function deserializeCreateUserRequestBody(
237✔
1098
  val: SerializedData,
1099
): CreateUserRequestBody {
1100
  if (!sdIsMap(val)) {
×
1101
    throw new BoxSdkError({
×
1102
      message: 'Expecting a map for "CreateUserRequestBody"',
1103
    });
1104
  }
1105
  if (val.name == void 0) {
×
1106
    throw new BoxSdkError({
×
1107
      message: 'Expecting "name" of type "CreateUserRequestBody" to be defined',
1108
    });
1109
  }
1110
  if (!sdIsString(val.name)) {
×
1111
    throw new BoxSdkError({
×
1112
      message: 'Expecting string for "name" of type "CreateUserRequestBody"',
1113
    });
1114
  }
1115
  const name: string = val.name;
×
1116
  if (!(val.login == void 0) && !sdIsString(val.login)) {
×
1117
    throw new BoxSdkError({
×
1118
      message: 'Expecting string for "login" of type "CreateUserRequestBody"',
1119
    });
1120
  }
1121
  const login: undefined | string = val.login == void 0 ? void 0 : val.login;
×
1122
  if (
×
1123
    !(val.is_platform_access_only == void 0) &&
×
1124
    !sdIsBoolean(val.is_platform_access_only)
1125
  ) {
1126
    throw new BoxSdkError({
×
1127
      message:
1128
        'Expecting boolean for "is_platform_access_only" of type "CreateUserRequestBody"',
1129
    });
1130
  }
1131
  const isPlatformAccessOnly: undefined | boolean =
1132
    val.is_platform_access_only == void 0
×
1133
      ? void 0
1134
      : val.is_platform_access_only;
1135
  const role: undefined | CreateUserRequestBodyRoleField =
1136
    val.role == void 0
×
1137
      ? void 0
1138
      : deserializeCreateUserRequestBodyRoleField(val.role);
1139
  if (!(val.language == void 0) && !sdIsString(val.language)) {
×
1140
    throw new BoxSdkError({
×
1141
      message:
1142
        'Expecting string for "language" of type "CreateUserRequestBody"',
1143
    });
1144
  }
1145
  const language: undefined | string =
1146
    val.language == void 0 ? void 0 : val.language;
×
1147
  if (!(val.is_sync_enabled == void 0) && !sdIsBoolean(val.is_sync_enabled)) {
×
1148
    throw new BoxSdkError({
×
1149
      message:
1150
        'Expecting boolean for "is_sync_enabled" of type "CreateUserRequestBody"',
1151
    });
1152
  }
1153
  const isSyncEnabled: undefined | boolean =
1154
    val.is_sync_enabled == void 0 ? void 0 : val.is_sync_enabled;
×
1155
  if (!(val.job_title == void 0) && !sdIsString(val.job_title)) {
×
1156
    throw new BoxSdkError({
×
1157
      message:
1158
        'Expecting string for "job_title" of type "CreateUserRequestBody"',
1159
    });
1160
  }
1161
  const jobTitle: undefined | string =
1162
    val.job_title == void 0 ? void 0 : val.job_title;
×
1163
  if (!(val.phone == void 0) && !sdIsString(val.phone)) {
×
1164
    throw new BoxSdkError({
×
1165
      message: 'Expecting string for "phone" of type "CreateUserRequestBody"',
1166
    });
1167
  }
1168
  const phone: undefined | string = val.phone == void 0 ? void 0 : val.phone;
×
1169
  if (!(val.address == void 0) && !sdIsString(val.address)) {
×
1170
    throw new BoxSdkError({
×
1171
      message: 'Expecting string for "address" of type "CreateUserRequestBody"',
1172
    });
1173
  }
1174
  const address: undefined | string =
1175
    val.address == void 0 ? void 0 : val.address;
×
1176
  if (!(val.space_amount == void 0) && !sdIsNumber(val.space_amount)) {
×
1177
    throw new BoxSdkError({
×
1178
      message:
1179
        'Expecting number for "space_amount" of type "CreateUserRequestBody"',
1180
    });
1181
  }
1182
  const spaceAmount: undefined | number =
1183
    val.space_amount == void 0 ? void 0 : val.space_amount;
×
1184
  if (!(val.tracking_codes == void 0) && !sdIsList(val.tracking_codes)) {
×
1185
    throw new BoxSdkError({
×
1186
      message:
1187
        'Expecting array for "tracking_codes" of type "CreateUserRequestBody"',
1188
    });
1189
  }
1190
  const trackingCodes: undefined | readonly TrackingCode[] =
1191
    val.tracking_codes == void 0
×
1192
      ? void 0
1193
      : sdIsList(val.tracking_codes)
×
1194
        ? (val.tracking_codes.map(function (itm: SerializedData): TrackingCode {
1195
            return deserializeTrackingCode(itm);
×
1196
          }) as readonly any[])
1197
        : [];
1198
  if (
×
1199
    !(val.can_see_managed_users == void 0) &&
×
1200
    !sdIsBoolean(val.can_see_managed_users)
1201
  ) {
1202
    throw new BoxSdkError({
×
1203
      message:
1204
        'Expecting boolean for "can_see_managed_users" of type "CreateUserRequestBody"',
1205
    });
1206
  }
1207
  const canSeeManagedUsers: undefined | boolean =
1208
    val.can_see_managed_users == void 0 ? void 0 : val.can_see_managed_users;
×
1209
  if (!(val.timezone == void 0) && !sdIsString(val.timezone)) {
×
1210
    throw new BoxSdkError({
×
1211
      message:
1212
        'Expecting string for "timezone" of type "CreateUserRequestBody"',
1213
    });
1214
  }
1215
  const timezone: undefined | string =
1216
    val.timezone == void 0 ? void 0 : val.timezone;
×
1217
  if (
×
1218
    !(val.is_external_collab_restricted == void 0) &&
×
1219
    !sdIsBoolean(val.is_external_collab_restricted)
1220
  ) {
1221
    throw new BoxSdkError({
×
1222
      message:
1223
        'Expecting boolean for "is_external_collab_restricted" of type "CreateUserRequestBody"',
1224
    });
1225
  }
1226
  const isExternalCollabRestricted: undefined | boolean =
1227
    val.is_external_collab_restricted == void 0
×
1228
      ? void 0
1229
      : val.is_external_collab_restricted;
1230
  if (
×
1231
    !(val.is_exempt_from_device_limits == void 0) &&
×
1232
    !sdIsBoolean(val.is_exempt_from_device_limits)
1233
  ) {
1234
    throw new BoxSdkError({
×
1235
      message:
1236
        'Expecting boolean for "is_exempt_from_device_limits" of type "CreateUserRequestBody"',
1237
    });
1238
  }
1239
  const isExemptFromDeviceLimits: undefined | boolean =
1240
    val.is_exempt_from_device_limits == void 0
×
1241
      ? void 0
1242
      : val.is_exempt_from_device_limits;
1243
  if (
×
1244
    !(val.is_exempt_from_login_verification == void 0) &&
×
1245
    !sdIsBoolean(val.is_exempt_from_login_verification)
1246
  ) {
1247
    throw new BoxSdkError({
×
1248
      message:
1249
        'Expecting boolean for "is_exempt_from_login_verification" of type "CreateUserRequestBody"',
1250
    });
1251
  }
1252
  const isExemptFromLoginVerification: undefined | boolean =
1253
    val.is_exempt_from_login_verification == void 0
×
1254
      ? void 0
1255
      : val.is_exempt_from_login_verification;
1256
  const status: undefined | CreateUserRequestBodyStatusField =
1257
    val.status == void 0
×
1258
      ? void 0
1259
      : deserializeCreateUserRequestBodyStatusField(val.status);
1260
  if (
×
1261
    !(val.external_app_user_id == void 0) &&
×
1262
    !sdIsString(val.external_app_user_id)
1263
  ) {
1264
    throw new BoxSdkError({
×
1265
      message:
1266
        'Expecting string for "external_app_user_id" of type "CreateUserRequestBody"',
1267
    });
1268
  }
1269
  const externalAppUserId: undefined | string =
1270
    val.external_app_user_id == void 0 ? void 0 : val.external_app_user_id;
×
1271
  return {
×
1272
    name: name,
1273
    login: login,
1274
    isPlatformAccessOnly: isPlatformAccessOnly,
1275
    role: role,
1276
    language: language,
1277
    isSyncEnabled: isSyncEnabled,
1278
    jobTitle: jobTitle,
1279
    phone: phone,
1280
    address: address,
1281
    spaceAmount: spaceAmount,
1282
    trackingCodes: trackingCodes,
1283
    canSeeManagedUsers: canSeeManagedUsers,
1284
    timezone: timezone,
1285
    isExternalCollabRestricted: isExternalCollabRestricted,
1286
    isExemptFromDeviceLimits: isExemptFromDeviceLimits,
1287
    isExemptFromLoginVerification: isExemptFromLoginVerification,
1288
    status: status,
1289
    externalAppUserId: externalAppUserId,
1290
  } satisfies CreateUserRequestBody;
1291
}
1292
export function serializeUpdateUserByIdRequestBodyRoleField(
237✔
1293
  val: UpdateUserByIdRequestBodyRoleField,
1294
): SerializedData {
1295
  return val;
×
1296
}
1297
export function deserializeUpdateUserByIdRequestBodyRoleField(
237✔
1298
  val: SerializedData,
1299
): UpdateUserByIdRequestBodyRoleField {
1300
  if (val == 'coadmin') {
×
1301
    return val;
×
1302
  }
1303
  if (val == 'user') {
×
1304
    return val;
×
1305
  }
1306
  if (sdIsString(val)) {
×
1307
    return val;
×
1308
  }
1309
  throw new BoxSdkError({
×
1310
    message: "Can't deserialize UpdateUserByIdRequestBodyRoleField",
1311
  });
1312
}
1313
export function serializeUpdateUserByIdRequestBodyStatusField(
237✔
1314
  val: UpdateUserByIdRequestBodyStatusField,
1315
): SerializedData {
1316
  return val;
×
1317
}
1318
export function deserializeUpdateUserByIdRequestBodyStatusField(
237✔
1319
  val: SerializedData,
1320
): UpdateUserByIdRequestBodyStatusField {
1321
  if (val == 'active') {
×
1322
    return val;
×
1323
  }
1324
  if (val == 'inactive') {
×
1325
    return val;
×
1326
  }
1327
  if (val == 'cannot_delete_edit') {
×
1328
    return val;
×
1329
  }
1330
  if (val == 'cannot_delete_edit_upload') {
×
1331
    return val;
×
1332
  }
1333
  if (sdIsString(val)) {
×
1334
    return val;
×
1335
  }
1336
  throw new BoxSdkError({
×
1337
    message: "Can't deserialize UpdateUserByIdRequestBodyStatusField",
1338
  });
1339
}
1340
export function serializeUpdateUserByIdRequestBodyNotificationEmailField(
237✔
1341
  val: UpdateUserByIdRequestBodyNotificationEmailField,
1342
): SerializedData {
1343
  return { ['email']: val.email };
×
1344
}
1345
export function deserializeUpdateUserByIdRequestBodyNotificationEmailField(
237✔
1346
  val: SerializedData,
1347
): UpdateUserByIdRequestBodyNotificationEmailField {
1348
  if (!sdIsMap(val)) {
×
1349
    throw new BoxSdkError({
×
1350
      message:
1351
        'Expecting a map for "UpdateUserByIdRequestBodyNotificationEmailField"',
1352
    });
1353
  }
1354
  if (!(val.email == void 0) && !sdIsString(val.email)) {
×
1355
    throw new BoxSdkError({
×
1356
      message:
1357
        'Expecting string for "email" of type "UpdateUserByIdRequestBodyNotificationEmailField"',
1358
    });
1359
  }
1360
  const email: undefined | string = val.email == void 0 ? void 0 : val.email;
×
1361
  return {
×
1362
    email: email,
1363
  } satisfies UpdateUserByIdRequestBodyNotificationEmailField;
1364
}
1365
export function serializeUpdateUserByIdRequestBody(
237✔
1366
  val: UpdateUserByIdRequestBody,
1367
): SerializedData {
1368
  return {
3✔
1369
    ['enterprise']: val.enterprise,
1370
    ['notify']: val.notify,
1371
    ['name']: val.name,
1372
    ['login']: val.login,
1373
    ['role']:
1374
      val.role == void 0
3!
1375
        ? val.role
1376
        : serializeUpdateUserByIdRequestBodyRoleField(val.role),
1377
    ['language']: val.language,
1378
    ['is_sync_enabled']: val.isSyncEnabled,
1379
    ['job_title']: val.jobTitle,
1380
    ['phone']: val.phone,
1381
    ['address']: val.address,
1382
    ['tracking_codes']:
1383
      val.trackingCodes == void 0
3!
1384
        ? val.trackingCodes
1385
        : (val.trackingCodes.map(function (item: TrackingCode): SerializedData {
1386
            return serializeTrackingCode(item);
×
1387
          }) as readonly any[]),
1388
    ['can_see_managed_users']: val.canSeeManagedUsers,
1389
    ['timezone']: val.timezone,
1390
    ['is_external_collab_restricted']: val.isExternalCollabRestricted,
1391
    ['is_exempt_from_device_limits']: val.isExemptFromDeviceLimits,
1392
    ['is_exempt_from_login_verification']: val.isExemptFromLoginVerification,
1393
    ['is_password_reset_required']: val.isPasswordResetRequired,
1394
    ['status']:
1395
      val.status == void 0
3!
1396
        ? val.status
1397
        : serializeUpdateUserByIdRequestBodyStatusField(val.status),
1398
    ['space_amount']: val.spaceAmount,
1399
    ['notification_email']:
1400
      val.notificationEmail == void 0
3!
1401
        ? val.notificationEmail
1402
        : serializeUpdateUserByIdRequestBodyNotificationEmailField(
1403
            val.notificationEmail,
1404
          ),
1405
    ['external_app_user_id']: val.externalAppUserId,
1406
  };
1407
}
1408
export function deserializeUpdateUserByIdRequestBody(
237✔
1409
  val: SerializedData,
1410
): UpdateUserByIdRequestBody {
1411
  if (!sdIsMap(val)) {
×
1412
    throw new BoxSdkError({
×
1413
      message: 'Expecting a map for "UpdateUserByIdRequestBody"',
1414
    });
1415
  }
1416
  if (!(val.enterprise == void 0) && !sdIsString(val.enterprise)) {
×
1417
    throw new BoxSdkError({
×
1418
      message:
1419
        'Expecting string for "enterprise" of type "UpdateUserByIdRequestBody"',
1420
    });
1421
  }
1422
  const enterprise: undefined | string =
1423
    val.enterprise == void 0 ? void 0 : val.enterprise;
×
1424
  if (!(val.notify == void 0) && !sdIsBoolean(val.notify)) {
×
1425
    throw new BoxSdkError({
×
1426
      message:
1427
        'Expecting boolean for "notify" of type "UpdateUserByIdRequestBody"',
1428
    });
1429
  }
1430
  const notify: undefined | boolean =
1431
    val.notify == void 0 ? void 0 : val.notify;
×
1432
  if (!(val.name == void 0) && !sdIsString(val.name)) {
×
1433
    throw new BoxSdkError({
×
1434
      message:
1435
        'Expecting string for "name" of type "UpdateUserByIdRequestBody"',
1436
    });
1437
  }
1438
  const name: undefined | string = val.name == void 0 ? void 0 : val.name;
×
1439
  if (!(val.login == void 0) && !sdIsString(val.login)) {
×
1440
    throw new BoxSdkError({
×
1441
      message:
1442
        'Expecting string for "login" of type "UpdateUserByIdRequestBody"',
1443
    });
1444
  }
1445
  const login: undefined | string = val.login == void 0 ? void 0 : val.login;
×
1446
  const role: undefined | UpdateUserByIdRequestBodyRoleField =
1447
    val.role == void 0
×
1448
      ? void 0
1449
      : deserializeUpdateUserByIdRequestBodyRoleField(val.role);
1450
  if (!(val.language == void 0) && !sdIsString(val.language)) {
×
1451
    throw new BoxSdkError({
×
1452
      message:
1453
        'Expecting string for "language" of type "UpdateUserByIdRequestBody"',
1454
    });
1455
  }
1456
  const language: undefined | string =
1457
    val.language == void 0 ? void 0 : val.language;
×
1458
  if (!(val.is_sync_enabled == void 0) && !sdIsBoolean(val.is_sync_enabled)) {
×
1459
    throw new BoxSdkError({
×
1460
      message:
1461
        'Expecting boolean for "is_sync_enabled" of type "UpdateUserByIdRequestBody"',
1462
    });
1463
  }
1464
  const isSyncEnabled: undefined | boolean =
1465
    val.is_sync_enabled == void 0 ? void 0 : val.is_sync_enabled;
×
1466
  if (!(val.job_title == void 0) && !sdIsString(val.job_title)) {
×
1467
    throw new BoxSdkError({
×
1468
      message:
1469
        'Expecting string for "job_title" of type "UpdateUserByIdRequestBody"',
1470
    });
1471
  }
1472
  const jobTitle: undefined | string =
1473
    val.job_title == void 0 ? void 0 : val.job_title;
×
1474
  if (!(val.phone == void 0) && !sdIsString(val.phone)) {
×
1475
    throw new BoxSdkError({
×
1476
      message:
1477
        'Expecting string for "phone" of type "UpdateUserByIdRequestBody"',
1478
    });
1479
  }
1480
  const phone: undefined | string = val.phone == void 0 ? void 0 : val.phone;
×
1481
  if (!(val.address == void 0) && !sdIsString(val.address)) {
×
1482
    throw new BoxSdkError({
×
1483
      message:
1484
        'Expecting string for "address" of type "UpdateUserByIdRequestBody"',
1485
    });
1486
  }
1487
  const address: undefined | string =
1488
    val.address == void 0 ? void 0 : val.address;
×
1489
  if (!(val.tracking_codes == void 0) && !sdIsList(val.tracking_codes)) {
×
1490
    throw new BoxSdkError({
×
1491
      message:
1492
        'Expecting array for "tracking_codes" of type "UpdateUserByIdRequestBody"',
1493
    });
1494
  }
1495
  const trackingCodes: undefined | readonly TrackingCode[] =
1496
    val.tracking_codes == void 0
×
1497
      ? void 0
1498
      : sdIsList(val.tracking_codes)
×
1499
        ? (val.tracking_codes.map(function (itm: SerializedData): TrackingCode {
1500
            return deserializeTrackingCode(itm);
×
1501
          }) as readonly any[])
1502
        : [];
1503
  if (
×
1504
    !(val.can_see_managed_users == void 0) &&
×
1505
    !sdIsBoolean(val.can_see_managed_users)
1506
  ) {
1507
    throw new BoxSdkError({
×
1508
      message:
1509
        'Expecting boolean for "can_see_managed_users" of type "UpdateUserByIdRequestBody"',
1510
    });
1511
  }
1512
  const canSeeManagedUsers: undefined | boolean =
1513
    val.can_see_managed_users == void 0 ? void 0 : val.can_see_managed_users;
×
1514
  if (!(val.timezone == void 0) && !sdIsString(val.timezone)) {
×
1515
    throw new BoxSdkError({
×
1516
      message:
1517
        'Expecting string for "timezone" of type "UpdateUserByIdRequestBody"',
1518
    });
1519
  }
1520
  const timezone: undefined | string =
1521
    val.timezone == void 0 ? void 0 : val.timezone;
×
1522
  if (
×
1523
    !(val.is_external_collab_restricted == void 0) &&
×
1524
    !sdIsBoolean(val.is_external_collab_restricted)
1525
  ) {
1526
    throw new BoxSdkError({
×
1527
      message:
1528
        'Expecting boolean for "is_external_collab_restricted" of type "UpdateUserByIdRequestBody"',
1529
    });
1530
  }
1531
  const isExternalCollabRestricted: undefined | boolean =
1532
    val.is_external_collab_restricted == void 0
×
1533
      ? void 0
1534
      : val.is_external_collab_restricted;
1535
  if (
×
1536
    !(val.is_exempt_from_device_limits == void 0) &&
×
1537
    !sdIsBoolean(val.is_exempt_from_device_limits)
1538
  ) {
1539
    throw new BoxSdkError({
×
1540
      message:
1541
        'Expecting boolean for "is_exempt_from_device_limits" of type "UpdateUserByIdRequestBody"',
1542
    });
1543
  }
1544
  const isExemptFromDeviceLimits: undefined | boolean =
1545
    val.is_exempt_from_device_limits == void 0
×
1546
      ? void 0
1547
      : val.is_exempt_from_device_limits;
1548
  if (
×
1549
    !(val.is_exempt_from_login_verification == void 0) &&
×
1550
    !sdIsBoolean(val.is_exempt_from_login_verification)
1551
  ) {
1552
    throw new BoxSdkError({
×
1553
      message:
1554
        'Expecting boolean for "is_exempt_from_login_verification" of type "UpdateUserByIdRequestBody"',
1555
    });
1556
  }
1557
  const isExemptFromLoginVerification: undefined | boolean =
1558
    val.is_exempt_from_login_verification == void 0
×
1559
      ? void 0
1560
      : val.is_exempt_from_login_verification;
1561
  if (
×
1562
    !(val.is_password_reset_required == void 0) &&
×
1563
    !sdIsBoolean(val.is_password_reset_required)
1564
  ) {
1565
    throw new BoxSdkError({
×
1566
      message:
1567
        'Expecting boolean for "is_password_reset_required" of type "UpdateUserByIdRequestBody"',
1568
    });
1569
  }
1570
  const isPasswordResetRequired: undefined | boolean =
1571
    val.is_password_reset_required == void 0
×
1572
      ? void 0
1573
      : val.is_password_reset_required;
1574
  const status: undefined | UpdateUserByIdRequestBodyStatusField =
1575
    val.status == void 0
×
1576
      ? void 0
1577
      : deserializeUpdateUserByIdRequestBodyStatusField(val.status);
1578
  if (!(val.space_amount == void 0) && !sdIsNumber(val.space_amount)) {
×
1579
    throw new BoxSdkError({
×
1580
      message:
1581
        'Expecting number for "space_amount" of type "UpdateUserByIdRequestBody"',
1582
    });
1583
  }
1584
  const spaceAmount: undefined | number =
1585
    val.space_amount == void 0 ? void 0 : val.space_amount;
×
1586
  const notificationEmail:
1587
    | undefined
1588
    | UpdateUserByIdRequestBodyNotificationEmailField =
1589
    val.notification_email == void 0
×
1590
      ? void 0
1591
      : deserializeUpdateUserByIdRequestBodyNotificationEmailField(
1592
          val.notification_email,
1593
        );
1594
  if (
×
1595
    !(val.external_app_user_id == void 0) &&
×
1596
    !sdIsString(val.external_app_user_id)
1597
  ) {
1598
    throw new BoxSdkError({
×
1599
      message:
1600
        'Expecting string for "external_app_user_id" of type "UpdateUserByIdRequestBody"',
1601
    });
1602
  }
1603
  const externalAppUserId: undefined | string =
1604
    val.external_app_user_id == void 0 ? void 0 : val.external_app_user_id;
×
1605
  return {
×
1606
    enterprise: enterprise,
1607
    notify: notify,
1608
    name: name,
1609
    login: login,
1610
    role: role,
1611
    language: language,
1612
    isSyncEnabled: isSyncEnabled,
1613
    jobTitle: jobTitle,
1614
    phone: phone,
1615
    address: address,
1616
    trackingCodes: trackingCodes,
1617
    canSeeManagedUsers: canSeeManagedUsers,
1618
    timezone: timezone,
1619
    isExternalCollabRestricted: isExternalCollabRestricted,
1620
    isExemptFromDeviceLimits: isExemptFromDeviceLimits,
1621
    isExemptFromLoginVerification: isExemptFromLoginVerification,
1622
    isPasswordResetRequired: isPasswordResetRequired,
1623
    status: status,
1624
    spaceAmount: spaceAmount,
1625
    notificationEmail: notificationEmail,
1626
    externalAppUserId: externalAppUserId,
1627
  } satisfies UpdateUserByIdRequestBody;
1628
}
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