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

box / box-typescript-sdk-gen / 12049597708

27 Nov 2024 11:43AM UTC coverage: 43.349%. First build
12049597708

Pull #431

github

web-flow
Merge 63b3d5cc8 into 991dc29bc
Pull Request #431: feat: Expose fetch method (box/box-codegen#610)

3883 of 15146 branches covered (25.64%)

Branch coverage included in aggregate %.

369 of 392 new or added lines in 74 files covered. (94.13%)

13570 of 25116 relevant lines covered (54.03%)

80.8 hits per line

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

24.49
/src/managers/devicePinners.generated.ts
1
import { serializeDevicePinner } from '../schemas/devicePinner.generated.js';
2
import { deserializeDevicePinner } from '../schemas/devicePinner.generated.js';
140✔
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';
140✔
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 { Authentication } from '../networking/auth.generated.js';
12
import { NetworkSession } from '../networking/network.generated.js';
140✔
13
import { prepareParams } from '../internal/utils.js';
140✔
14
import { toString } from '../internal/utils.js';
140✔
15
import { ByteStream } from '../internal/utils.js';
16
import { CancellationToken } from '../internal/utils.js';
17
import { FetchOptions } from '../networking/fetchOptions.generated.js';
140✔
18
import { FetchResponse } from '../networking/fetchResponse.generated.js';
19
import { fetch } from '../networking/fetch.js';
140✔
20
import { sdToJson } from '../serialization/json.js';
21
import { SerializedData } from '../serialization/json.js';
22
import { BoxSdkError } from '../box/errors.js';
140✔
23
import { sdIsEmpty } from '../serialization/json.js';
24
import { sdIsBoolean } from '../serialization/json.js';
25
import { sdIsNumber } from '../serialization/json.js';
26
import { sdIsString } from '../serialization/json.js';
27
import { sdIsList } from '../serialization/json.js';
28
import { sdIsMap } from '../serialization/json.js';
29
export class GetDevicePinnerByIdOptionals {
140✔
30
  readonly headers: GetDevicePinnerByIdHeaders = new GetDevicePinnerByIdHeaders(
×
31
    {},
32
  );
33
  readonly cancellationToken?: CancellationToken = void 0;
×
34
  constructor(
35
    fields: Omit<
36
      GetDevicePinnerByIdOptionals,
37
      'headers' | 'cancellationToken'
38
    > &
39
      Partial<
40
        Pick<GetDevicePinnerByIdOptionals, 'headers' | 'cancellationToken'>
41
      >,
42
  ) {
43
    if (fields.headers) {
×
44
      this.headers = fields.headers;
×
45
    }
46
    if (fields.cancellationToken) {
×
47
      this.cancellationToken = fields.cancellationToken;
×
48
    }
49
  }
50
}
51
export interface GetDevicePinnerByIdOptionalsInput {
52
  readonly headers?: GetDevicePinnerByIdHeaders;
53
  readonly cancellationToken?: undefined | CancellationToken;
54
}
55
export class DeleteDevicePinnerByIdOptionals {
140✔
56
  readonly headers: DeleteDevicePinnerByIdHeaders =
×
57
    new DeleteDevicePinnerByIdHeaders({});
58
  readonly cancellationToken?: CancellationToken = void 0;
×
59
  constructor(
60
    fields: Omit<
61
      DeleteDevicePinnerByIdOptionals,
62
      'headers' | 'cancellationToken'
63
    > &
64
      Partial<
65
        Pick<DeleteDevicePinnerByIdOptionals, 'headers' | 'cancellationToken'>
66
      >,
67
  ) {
68
    if (fields.headers) {
×
69
      this.headers = fields.headers;
×
70
    }
71
    if (fields.cancellationToken) {
×
72
      this.cancellationToken = fields.cancellationToken;
×
73
    }
74
  }
75
}
76
export interface DeleteDevicePinnerByIdOptionalsInput {
77
  readonly headers?: DeleteDevicePinnerByIdHeaders;
78
  readonly cancellationToken?: undefined | CancellationToken;
79
}
80
export class GetEnterpriseDevicePinnersOptionals {
140✔
81
  readonly queryParams: GetEnterpriseDevicePinnersQueryParams =
×
82
    {} satisfies GetEnterpriseDevicePinnersQueryParams;
83
  readonly headers: GetEnterpriseDevicePinnersHeaders =
×
84
    new GetEnterpriseDevicePinnersHeaders({});
85
  readonly cancellationToken?: CancellationToken = void 0;
×
86
  constructor(
87
    fields: Omit<
88
      GetEnterpriseDevicePinnersOptionals,
89
      'queryParams' | 'headers' | 'cancellationToken'
90
    > &
91
      Partial<
92
        Pick<
93
          GetEnterpriseDevicePinnersOptionals,
94
          'queryParams' | 'headers' | 'cancellationToken'
95
        >
96
      >,
97
  ) {
98
    if (fields.queryParams) {
×
99
      this.queryParams = fields.queryParams;
×
100
    }
101
    if (fields.headers) {
×
102
      this.headers = fields.headers;
×
103
    }
104
    if (fields.cancellationToken) {
×
105
      this.cancellationToken = fields.cancellationToken;
×
106
    }
107
  }
108
}
109
export interface GetEnterpriseDevicePinnersOptionalsInput {
110
  readonly queryParams?: GetEnterpriseDevicePinnersQueryParams;
111
  readonly headers?: GetEnterpriseDevicePinnersHeaders;
112
  readonly cancellationToken?: undefined | CancellationToken;
113
}
114
export class GetDevicePinnerByIdHeaders {
140✔
115
  /**
116
   * Extra headers that will be included in the HTTP request. */
117
  readonly extraHeaders?: {
×
118
    readonly [key: string]: undefined | string;
119
  } = {};
120
  constructor(
121
    fields: Omit<GetDevicePinnerByIdHeaders, 'extraHeaders'> &
122
      Partial<Pick<GetDevicePinnerByIdHeaders, 'extraHeaders'>>,
123
  ) {
124
    if (fields.extraHeaders) {
×
125
      this.extraHeaders = fields.extraHeaders;
×
126
    }
127
  }
128
}
129
export interface GetDevicePinnerByIdHeadersInput {
130
  /**
131
   * Extra headers that will be included in the HTTP request. */
132
  readonly extraHeaders?:
133
    | undefined
134
    | {
135
        readonly [key: string]: undefined | string;
136
      };
137
}
138
export class DeleteDevicePinnerByIdHeaders {
140✔
139
  /**
140
   * Extra headers that will be included in the HTTP request. */
141
  readonly extraHeaders?: {
×
142
    readonly [key: string]: undefined | string;
143
  } = {};
144
  constructor(
145
    fields: Omit<DeleteDevicePinnerByIdHeaders, 'extraHeaders'> &
146
      Partial<Pick<DeleteDevicePinnerByIdHeaders, 'extraHeaders'>>,
147
  ) {
148
    if (fields.extraHeaders) {
×
149
      this.extraHeaders = fields.extraHeaders;
×
150
    }
151
  }
152
}
153
export interface DeleteDevicePinnerByIdHeadersInput {
154
  /**
155
   * Extra headers that will be included in the HTTP request. */
156
  readonly extraHeaders?:
157
    | undefined
158
    | {
159
        readonly [key: string]: undefined | string;
160
      };
161
}
162
export type GetEnterpriseDevicePinnersQueryParamsDirectionField =
163
  | 'ASC'
164
  | 'DESC';
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 {
140✔
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) {
×
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 {
140✔
205
  readonly auth?: Authentication;
206
  readonly networkSession: NetworkSession = new NetworkSession({});
300✔
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) {
300✔
218
      this.auth = fields.auth;
300✔
219
    }
220
    if (fields.networkSession) {
300✔
221
      this.networkSession = fields.networkSession;
300✔
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 });
×
NEW
245
    const response: FetchResponse = (await fetch(
×
246
      new FetchOptions({
247
        url: ''.concat(
248
          this.networkSession.baseUrls.baseUrl,
249
          '/2.0/device_pinners/',
250
          toString(devicePinnerId) as string,
251
        ) as string,
252
        method: 'GET',
253
        headers: headersMap,
254
        responseFormat: 'json' as ResponseFormat,
255
        auth: this.auth,
256
        networkSession: this.networkSession,
257
        cancellationToken: cancellationToken,
258
      }),
259
    )) as FetchResponse;
260
    return {
×
261
      ...deserializeDevicePinner(response.data!),
262
      rawData: response.data!,
263
    };
264
  }
265
  /**
266
     * Deletes an individual device pin.
267
     * @param {string} devicePinnerId The ID of the device pin
268
    Example: "2324234"
269
     * @param {DeleteDevicePinnerByIdOptionalsInput} optionalsInput
270
     * @returns {Promise<undefined>}
271
     */
272
  async deleteDevicePinnerById(
273
    devicePinnerId: string,
×
274
    optionalsInput: DeleteDevicePinnerByIdOptionalsInput = {},
×
275
  ): Promise<undefined> {
276
    const optionals: DeleteDevicePinnerByIdOptionals =
277
      new DeleteDevicePinnerByIdOptionals({
×
278
        headers: optionalsInput.headers,
279
        cancellationToken: optionalsInput.cancellationToken,
280
      });
281
    const headers: any = optionals.headers;
×
282
    const cancellationToken: any = optionals.cancellationToken;
×
283
    const headersMap: {
284
      readonly [key: string]: string;
285
    } = prepareParams({ ...{}, ...headers.extraHeaders });
×
NEW
286
    const response: FetchResponse = (await fetch(
×
287
      new FetchOptions({
288
        url: ''.concat(
289
          this.networkSession.baseUrls.baseUrl,
290
          '/2.0/device_pinners/',
291
          toString(devicePinnerId) as string,
292
        ) as string,
293
        method: 'DELETE',
294
        headers: headersMap,
295
        responseFormat: 'no_content' as ResponseFormat,
296
        auth: this.auth,
297
        networkSession: this.networkSession,
298
        cancellationToken: cancellationToken,
299
      }),
300
    )) as FetchResponse;
301
    return void 0;
×
302
  }
303
  /**
304
     * Retrieves all the device pins within an enterprise.
305
     *
306
     * The user must have admin privileges, and the application
307
     * needs the "manage enterprise" scope to make this call.
308
     * @param {string} enterpriseId The ID of the enterprise
309
    Example: "3442311"
310
     * @param {GetEnterpriseDevicePinnersOptionalsInput} optionalsInput
311
     * @returns {Promise<DevicePinners>}
312
     */
313
  async getEnterpriseDevicePinners(
314
    enterpriseId: string,
×
315
    optionalsInput: GetEnterpriseDevicePinnersOptionalsInput = {},
×
316
  ): Promise<DevicePinners> {
317
    const optionals: GetEnterpriseDevicePinnersOptionals =
318
      new GetEnterpriseDevicePinnersOptionals({
×
319
        queryParams: optionalsInput.queryParams,
320
        headers: optionalsInput.headers,
321
        cancellationToken: optionalsInput.cancellationToken,
322
      });
323
    const queryParams: any = optionals.queryParams;
×
324
    const headers: any = optionals.headers;
×
325
    const cancellationToken: any = optionals.cancellationToken;
×
326
    const queryParamsMap: {
327
      readonly [key: string]: string;
328
    } = prepareParams({
×
329
      ['marker']: toString(queryParams.marker) as string,
330
      ['limit']: toString(queryParams.limit) as string,
331
      ['direction']: toString(queryParams.direction) as string,
332
    });
333
    const headersMap: {
334
      readonly [key: string]: string;
335
    } = prepareParams({ ...{}, ...headers.extraHeaders });
×
NEW
336
    const response: FetchResponse = (await fetch(
×
337
      new FetchOptions({
338
        url: ''.concat(
339
          this.networkSession.baseUrls.baseUrl,
340
          '/2.0/enterprises/',
341
          toString(enterpriseId) as string,
342
          '/device_pinners',
343
        ) as string,
344
        method: 'GET',
345
        params: queryParamsMap,
346
        headers: headersMap,
347
        responseFormat: 'json' as ResponseFormat,
348
        auth: this.auth,
349
        networkSession: this.networkSession,
350
        cancellationToken: cancellationToken,
351
      }),
352
    )) as FetchResponse;
353
    return {
×
354
      ...deserializeDevicePinners(response.data!),
355
      rawData: response.data!,
356
    };
357
  }
358
}
359
export interface DevicePinnersManagerInput {
360
  readonly auth?: Authentication;
361
  readonly networkSession?: NetworkSession;
362
}
363
export function serializeGetEnterpriseDevicePinnersQueryParamsDirectionField(
140✔
364
  val: GetEnterpriseDevicePinnersQueryParamsDirectionField,
365
): SerializedData {
366
  return val;
×
367
}
368
export function deserializeGetEnterpriseDevicePinnersQueryParamsDirectionField(
140✔
369
  val: SerializedData,
370
): GetEnterpriseDevicePinnersQueryParamsDirectionField {
371
  if (val == 'ASC') {
×
372
    return val;
×
373
  }
374
  if (val == 'DESC') {
×
375
    return val;
×
376
  }
377
  throw new BoxSdkError({
×
378
    message:
379
      "Can't deserialize GetEnterpriseDevicePinnersQueryParamsDirectionField",
380
  });
381
}
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