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

box / box-typescript-sdk-gen / 12867243695

20 Jan 2025 11:41AM UTC coverage: 42.419%. First build
12867243695

Pull #487

github

web-flow
Merge 19517b363 into 0d3bc1813
Pull Request #487: fix: Use extensible enums Typescript (box/box-codegen#639)

3990 of 15999 branches covered (24.94%)

Branch coverage included in aggregate %.

0 of 408 new or added lines in 104 files covered. (0.0%)

14249 of 26998 relevant lines covered (52.78%)

93.01 hits per line

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

23.76
/src/managers/devicePinners.generated.ts
1
import { serializeDevicePinner } from '../schemas/devicePinner.generated.js';
2
import { deserializeDevicePinner } from '../schemas/devicePinner.generated.js';
144✔
3
import { serializeClientError } from '../schemas/clientError.generated.js';
4
import { deserializeClientError } from '../schemas/clientError.generated.js';
5
import { serializeDevicePinners } from '../schemas/devicePinners.generated.js';
6
import { deserializeDevicePinners } from '../schemas/devicePinners.generated.js';
144✔
7
import { ResponseFormat } from '../networking/fetchOptions.generated.js';
8
import { DevicePinner } from '../schemas/devicePinner.generated.js';
9
import { ClientError } from '../schemas/clientError.generated.js';
10
import { DevicePinners } from '../schemas/devicePinners.generated.js';
11
import { BoxSdkError } from '../box/errors.js';
144✔
12
import { Authentication } from '../networking/auth.generated.js';
13
import { NetworkSession } from '../networking/network.generated.js';
144✔
14
import { FetchOptions } from '../networking/fetchOptions.generated.js';
144✔
15
import { FetchResponse } from '../networking/fetchResponse.generated.js';
16
import { prepareParams } from '../internal/utils.js';
144✔
17
import { toString } from '../internal/utils.js';
144✔
18
import { ByteStream } from '../internal/utils.js';
19
import { CancellationToken } from '../internal/utils.js';
20
import { sdToJson } from '../serialization/json.js';
21
import { SerializedData } from '../serialization/json.js';
22
import { sdIsEmpty } from '../serialization/json.js';
23
import { sdIsBoolean } from '../serialization/json.js';
24
import { sdIsNumber } from '../serialization/json.js';
25
import { sdIsString } from '../serialization/json.js';
144✔
26
import { sdIsList } from '../serialization/json.js';
27
import { sdIsMap } from '../serialization/json.js';
28
export class GetDevicePinnerByIdOptionals {
144✔
29
  readonly headers: GetDevicePinnerByIdHeaders = new GetDevicePinnerByIdHeaders(
×
30
    {},
31
  );
32
  readonly cancellationToken?: CancellationToken = void 0;
×
33
  constructor(
34
    fields: Omit<
35
      GetDevicePinnerByIdOptionals,
36
      'headers' | 'cancellationToken'
37
    > &
38
      Partial<
39
        Pick<GetDevicePinnerByIdOptionals, 'headers' | 'cancellationToken'>
40
      >,
41
  ) {
42
    if (fields.headers !== undefined) {
×
43
      this.headers = fields.headers;
×
44
    }
45
    if (fields.cancellationToken !== undefined) {
×
46
      this.cancellationToken = fields.cancellationToken;
×
47
    }
48
  }
49
}
50
export interface GetDevicePinnerByIdOptionalsInput {
51
  readonly headers?: GetDevicePinnerByIdHeaders;
52
  readonly cancellationToken?: undefined | CancellationToken;
53
}
54
export class DeleteDevicePinnerByIdOptionals {
144✔
55
  readonly headers: DeleteDevicePinnerByIdHeaders =
×
56
    new DeleteDevicePinnerByIdHeaders({});
57
  readonly cancellationToken?: CancellationToken = void 0;
×
58
  constructor(
59
    fields: Omit<
60
      DeleteDevicePinnerByIdOptionals,
61
      'headers' | 'cancellationToken'
62
    > &
63
      Partial<
64
        Pick<DeleteDevicePinnerByIdOptionals, 'headers' | 'cancellationToken'>
65
      >,
66
  ) {
67
    if (fields.headers !== undefined) {
×
68
      this.headers = fields.headers;
×
69
    }
70
    if (fields.cancellationToken !== undefined) {
×
71
      this.cancellationToken = fields.cancellationToken;
×
72
    }
73
  }
74
}
75
export interface DeleteDevicePinnerByIdOptionalsInput {
76
  readonly headers?: DeleteDevicePinnerByIdHeaders;
77
  readonly cancellationToken?: undefined | CancellationToken;
78
}
79
export class GetEnterpriseDevicePinnersOptionals {
144✔
80
  readonly queryParams: GetEnterpriseDevicePinnersQueryParams =
×
81
    {} satisfies GetEnterpriseDevicePinnersQueryParams;
82
  readonly headers: GetEnterpriseDevicePinnersHeaders =
×
83
    new GetEnterpriseDevicePinnersHeaders({});
84
  readonly cancellationToken?: CancellationToken = void 0;
×
85
  constructor(
86
    fields: Omit<
87
      GetEnterpriseDevicePinnersOptionals,
88
      'queryParams' | 'headers' | 'cancellationToken'
89
    > &
90
      Partial<
91
        Pick<
92
          GetEnterpriseDevicePinnersOptionals,
93
          'queryParams' | 'headers' | 'cancellationToken'
94
        >
95
      >,
96
  ) {
97
    if (fields.queryParams !== undefined) {
×
98
      this.queryParams = fields.queryParams;
×
99
    }
100
    if (fields.headers !== undefined) {
×
101
      this.headers = fields.headers;
×
102
    }
103
    if (fields.cancellationToken !== undefined) {
×
104
      this.cancellationToken = fields.cancellationToken;
×
105
    }
106
  }
107
}
108
export interface GetEnterpriseDevicePinnersOptionalsInput {
109
  readonly queryParams?: GetEnterpriseDevicePinnersQueryParams;
110
  readonly headers?: GetEnterpriseDevicePinnersHeaders;
111
  readonly cancellationToken?: undefined | CancellationToken;
112
}
113
export class GetDevicePinnerByIdHeaders {
144✔
114
  /**
115
   * Extra headers that will be included in the HTTP request. */
116
  readonly extraHeaders?: {
×
117
    readonly [key: string]: undefined | string;
118
  } = {};
119
  constructor(
120
    fields: Omit<GetDevicePinnerByIdHeaders, 'extraHeaders'> &
121
      Partial<Pick<GetDevicePinnerByIdHeaders, 'extraHeaders'>>,
122
  ) {
123
    if (fields.extraHeaders !== undefined) {
×
124
      this.extraHeaders = fields.extraHeaders;
×
125
    }
126
  }
127
}
128
export interface GetDevicePinnerByIdHeadersInput {
129
  /**
130
   * Extra headers that will be included in the HTTP request. */
131
  readonly extraHeaders?:
132
    | undefined
133
    | {
134
        readonly [key: string]: undefined | string;
135
      };
136
}
137
export class DeleteDevicePinnerByIdHeaders {
144✔
138
  /**
139
   * Extra headers that will be included in the HTTP request. */
140
  readonly extraHeaders?: {
×
141
    readonly [key: string]: undefined | string;
142
  } = {};
143
  constructor(
144
    fields: Omit<DeleteDevicePinnerByIdHeaders, 'extraHeaders'> &
145
      Partial<Pick<DeleteDevicePinnerByIdHeaders, 'extraHeaders'>>,
146
  ) {
147
    if (fields.extraHeaders !== undefined) {
×
148
      this.extraHeaders = fields.extraHeaders;
×
149
    }
150
  }
151
}
152
export interface DeleteDevicePinnerByIdHeadersInput {
153
  /**
154
   * Extra headers that will be included in the HTTP request. */
155
  readonly extraHeaders?:
156
    | undefined
157
    | {
158
        readonly [key: string]: undefined | string;
159
      };
160
}
161
export type GetEnterpriseDevicePinnersQueryParamsDirectionField =
162
  | 'ASC'
163
  | 'DESC'
164
  | string;
165
export interface GetEnterpriseDevicePinnersQueryParams {
166
  /**
167
   * Defines the position marker at which to begin returning results. This is
168
   * used when paginating using marker-based pagination.
169
   *
170
   * This requires `usemarker` to be set to `true`. */
171
  readonly marker?: string;
172
  /**
173
   * The maximum number of items to return per page. */
174
  readonly limit?: number;
175
  /**
176
   * The direction to sort results in. This can be either in alphabetical ascending
177
   * (`ASC`) or descending (`DESC`) order. */
178
  readonly direction?: GetEnterpriseDevicePinnersQueryParamsDirectionField;
179
}
180
export class GetEnterpriseDevicePinnersHeaders {
144✔
181
  /**
182
   * Extra headers that will be included in the HTTP request. */
183
  readonly extraHeaders?: {
×
184
    readonly [key: string]: undefined | string;
185
  } = {};
186
  constructor(
187
    fields: Omit<GetEnterpriseDevicePinnersHeaders, 'extraHeaders'> &
188
      Partial<Pick<GetEnterpriseDevicePinnersHeaders, 'extraHeaders'>>,
189
  ) {
190
    if (fields.extraHeaders !== undefined) {
×
191
      this.extraHeaders = fields.extraHeaders;
×
192
    }
193
  }
194
}
195
export interface GetEnterpriseDevicePinnersHeadersInput {
196
  /**
197
   * Extra headers that will be included in the HTTP request. */
198
  readonly extraHeaders?:
199
    | undefined
200
    | {
201
        readonly [key: string]: undefined | string;
202
      };
203
}
204
export class DevicePinnersManager {
144✔
205
  readonly auth?: Authentication;
206
  readonly networkSession: NetworkSession = new NetworkSession({});
312✔
207
  constructor(
208
    fields: Omit<
209
      DevicePinnersManager,
210
      | 'networkSession'
211
      | 'getDevicePinnerById'
212
      | 'deleteDevicePinnerById'
213
      | 'getEnterpriseDevicePinners'
214
    > &
215
      Partial<Pick<DevicePinnersManager, 'networkSession'>>,
216
  ) {
217
    if (fields.auth !== undefined) {
312✔
218
      this.auth = fields.auth;
312✔
219
    }
220
    if (fields.networkSession !== undefined) {
312✔
221
      this.networkSession = fields.networkSession;
312✔
222
    }
223
  }
224
  /**
225
     * Retrieves information about an individual device pin.
226
     * @param {string} devicePinnerId The ID of the device pin
227
    Example: "2324234"
228
     * @param {GetDevicePinnerByIdOptionalsInput} optionalsInput
229
     * @returns {Promise<DevicePinner>}
230
     */
231
  async getDevicePinnerById(
232
    devicePinnerId: string,
×
233
    optionalsInput: GetDevicePinnerByIdOptionalsInput = {},
×
234
  ): Promise<DevicePinner> {
235
    const optionals: GetDevicePinnerByIdOptionals =
236
      new GetDevicePinnerByIdOptionals({
×
237
        headers: optionalsInput.headers,
238
        cancellationToken: optionalsInput.cancellationToken,
239
      });
240
    const headers: any = optionals.headers;
×
241
    const cancellationToken: any = optionals.cancellationToken;
×
242
    const headersMap: {
243
      readonly [key: string]: string;
244
    } = prepareParams({ ...{}, ...headers.extraHeaders });
×
245
    const response: FetchResponse =
246
      await this.networkSession.networkClient.fetch(
×
247
        new FetchOptions({
248
          url: ''.concat(
249
            this.networkSession.baseUrls.baseUrl,
250
            '/2.0/device_pinners/',
251
            toString(devicePinnerId) as string,
252
          ) as string,
253
          method: 'GET',
254
          headers: headersMap,
255
          responseFormat: 'json' as ResponseFormat,
256
          auth: this.auth,
257
          networkSession: this.networkSession,
258
          cancellationToken: cancellationToken,
259
        }),
260
      );
261
    return {
×
262
      ...deserializeDevicePinner(response.data!),
263
      rawData: response.data!,
264
    };
265
  }
266
  /**
267
     * Deletes an individual device pin.
268
     * @param {string} devicePinnerId The ID of the device pin
269
    Example: "2324234"
270
     * @param {DeleteDevicePinnerByIdOptionalsInput} optionalsInput
271
     * @returns {Promise<undefined>}
272
     */
273
  async deleteDevicePinnerById(
274
    devicePinnerId: string,
×
275
    optionalsInput: DeleteDevicePinnerByIdOptionalsInput = {},
×
276
  ): Promise<undefined> {
277
    const optionals: DeleteDevicePinnerByIdOptionals =
278
      new DeleteDevicePinnerByIdOptionals({
×
279
        headers: optionalsInput.headers,
280
        cancellationToken: optionalsInput.cancellationToken,
281
      });
282
    const headers: any = optionals.headers;
×
283
    const cancellationToken: any = optionals.cancellationToken;
×
284
    const headersMap: {
285
      readonly [key: string]: string;
286
    } = prepareParams({ ...{}, ...headers.extraHeaders });
×
287
    const response: FetchResponse =
288
      await this.networkSession.networkClient.fetch(
×
289
        new FetchOptions({
290
          url: ''.concat(
291
            this.networkSession.baseUrls.baseUrl,
292
            '/2.0/device_pinners/',
293
            toString(devicePinnerId) as string,
294
          ) as string,
295
          method: 'DELETE',
296
          headers: headersMap,
297
          responseFormat: 'no_content' as ResponseFormat,
298
          auth: this.auth,
299
          networkSession: this.networkSession,
300
          cancellationToken: cancellationToken,
301
        }),
302
      );
303
    return void 0;
×
304
  }
305
  /**
306
     * Retrieves all the device pins within an enterprise.
307
     *
308
     * The user must have admin privileges, and the application
309
     * needs the "manage enterprise" scope to make this call.
310
     * @param {string} enterpriseId The ID of the enterprise
311
    Example: "3442311"
312
     * @param {GetEnterpriseDevicePinnersOptionalsInput} optionalsInput
313
     * @returns {Promise<DevicePinners>}
314
     */
315
  async getEnterpriseDevicePinners(
316
    enterpriseId: string,
×
317
    optionalsInput: GetEnterpriseDevicePinnersOptionalsInput = {},
×
318
  ): Promise<DevicePinners> {
319
    const optionals: GetEnterpriseDevicePinnersOptionals =
320
      new GetEnterpriseDevicePinnersOptionals({
×
321
        queryParams: optionalsInput.queryParams,
322
        headers: optionalsInput.headers,
323
        cancellationToken: optionalsInput.cancellationToken,
324
      });
325
    const queryParams: any = optionals.queryParams;
×
326
    const headers: any = optionals.headers;
×
327
    const cancellationToken: any = optionals.cancellationToken;
×
328
    const queryParamsMap: {
329
      readonly [key: string]: string;
330
    } = prepareParams({
×
331
      ['marker']: toString(queryParams.marker) as string,
332
      ['limit']: toString(queryParams.limit) as string,
333
      ['direction']: toString(queryParams.direction) as string,
334
    });
335
    const headersMap: {
336
      readonly [key: string]: string;
337
    } = prepareParams({ ...{}, ...headers.extraHeaders });
×
338
    const response: FetchResponse =
339
      await this.networkSession.networkClient.fetch(
×
340
        new FetchOptions({
341
          url: ''.concat(
342
            this.networkSession.baseUrls.baseUrl,
343
            '/2.0/enterprises/',
344
            toString(enterpriseId) as string,
345
            '/device_pinners',
346
          ) as string,
347
          method: 'GET',
348
          params: queryParamsMap,
349
          headers: headersMap,
350
          responseFormat: 'json' as ResponseFormat,
351
          auth: this.auth,
352
          networkSession: this.networkSession,
353
          cancellationToken: cancellationToken,
354
        }),
355
      );
356
    return {
×
357
      ...deserializeDevicePinners(response.data!),
358
      rawData: response.data!,
359
    };
360
  }
361
}
362
export interface DevicePinnersManagerInput {
363
  readonly auth?: Authentication;
364
  readonly networkSession?: NetworkSession;
365
}
366
export function serializeGetEnterpriseDevicePinnersQueryParamsDirectionField(
144✔
367
  val: GetEnterpriseDevicePinnersQueryParamsDirectionField,
368
): SerializedData {
369
  return val;
×
370
}
371
export function deserializeGetEnterpriseDevicePinnersQueryParamsDirectionField(
144✔
372
  val: SerializedData,
373
): GetEnterpriseDevicePinnersQueryParamsDirectionField {
374
  if (val == 'ASC') {
×
375
    return val;
×
376
  }
377
  if (val == 'DESC') {
×
378
    return val;
×
379
  }
NEW
380
  if (sdIsString(val)) {
×
NEW
381
    return val;
×
382
  }
383
  throw new BoxSdkError({
×
384
    message:
385
      "Can't deserialize GetEnterpriseDevicePinnersQueryParamsDirectionField",
386
  });
387
}
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