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

box / box-typescript-sdk-gen / 6814673855

09 Nov 2023 04:31PM UTC coverage: 31.432% (+1.3%) from 30.127%
6814673855

Pull #41

github

web-flow
Merge 3aec2106f into 1aa8f5afc
Pull Request #41: codegen output 13ed41f186c7473db272e90659610b17

1501 of 9137 branches covered (0.0%)

Branch coverage included in aggregate %.

492 of 992 new or added lines in 75 files covered. (49.6%)

160 existing lines in 14 files now uncovered.

5124 of 11940 relevant lines covered (42.91%)

27.06 hits per line

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

70.0
/src/managers/comments.generated.ts
1
import { serializeComments } from '../schemas.generated.js';
2
import { deserializeComments } from '../schemas.generated.js';
70✔
3
import { serializeClientError } from '../schemas.generated.js';
4
import { deserializeClientError } from '../schemas.generated.js';
5
import { serializeCommentFull } from '../schemas.generated.js';
6
import { deserializeCommentFull } from '../schemas.generated.js';
70✔
7
import { serializeComment } from '../schemas.generated.js';
8
import { deserializeComment } from '../schemas.generated.js';
70✔
9
import { Comments } from '../schemas.generated.js';
10
import { ClientError } from '../schemas.generated.js';
11
import { CommentFull } from '../schemas.generated.js';
12
import { Comment } from '../schemas.generated.js';
13
import { Authentication } from '../auth.js';
14
import { NetworkSession } from '../network.js';
15
import { prepareParams } from '../utils.js';
70✔
16
import { toString } from '../utils.js';
70✔
17
import { ByteStream } from '../utils.js';
18
import { CancellationToken } from '../utils.js';
19
import { sdToJson } from '../json.js';
20
import { fetch } from '../fetch.js';
70✔
21
import { FetchOptions } from '../fetch.js';
22
import { FetchResponse } from '../fetch.js';
23
import { SerializedData } from '../json.js';
24
import { sdIsEmpty } from '../json.js';
25
import { sdIsBoolean } from '../json.js';
26
import { sdIsNumber } from '../json.js';
27
import { sdIsString } from '../json.js';
70✔
28
import { sdIsList } from '../json.js';
29
import { sdIsMap } from '../json.js';
30
export interface GetFileCommentsQueryParamsArg {
31
  readonly fields?: readonly string[];
32
  readonly limit?: number;
33
  readonly offset?: number;
34
}
35
export class GetFileCommentsHeadersArg {
70✔
36
  readonly extraHeaders?: {
4✔
37
    readonly [key: string]: undefined | string;
38
  } = {};
39
  constructor(
40
    fields:
41
      | Omit<GetFileCommentsHeadersArg, 'extraHeaders'>
42
      | Partial<Pick<GetFileCommentsHeadersArg, 'extraHeaders'>>
43
  ) {
44
    Object.assign(this, fields);
4✔
45
  }
46
}
47
export interface GetCommentByIdQueryParamsArg {
48
  readonly fields?: readonly string[];
49
}
50
export class GetCommentByIdHeadersArg {
70✔
51
  readonly extraHeaders?: {
4✔
52
    readonly [key: string]: undefined | string;
53
  } = {};
54
  constructor(
55
    fields:
56
      | Omit<GetCommentByIdHeadersArg, 'extraHeaders'>
57
      | Partial<Pick<GetCommentByIdHeadersArg, 'extraHeaders'>>
58
  ) {
59
    Object.assign(this, fields);
4✔
60
  }
61
}
62
export interface UpdateCommentByIdRequestBodyArg {
63
  readonly message?: string;
64
}
65
export interface UpdateCommentByIdQueryParamsArg {
66
  readonly fields?: readonly string[];
67
}
68
export class UpdateCommentByIdHeadersArg {
70✔
69
  readonly extraHeaders?: {
2✔
70
    readonly [key: string]: undefined | string;
71
  } = {};
72
  constructor(
73
    fields:
74
      | Omit<UpdateCommentByIdHeadersArg, 'extraHeaders'>
75
      | Partial<Pick<UpdateCommentByIdHeadersArg, 'extraHeaders'>>
76
  ) {
77
    Object.assign(this, fields);
2✔
78
  }
79
}
80
export class DeleteCommentByIdHeadersArg {
70✔
81
  readonly extraHeaders?: {
2✔
82
    readonly [key: string]: undefined | string;
83
  } = {};
84
  constructor(
85
    fields:
86
      | Omit<DeleteCommentByIdHeadersArg, 'extraHeaders'>
87
      | Partial<Pick<DeleteCommentByIdHeadersArg, 'extraHeaders'>>
88
  ) {
89
    Object.assign(this, fields);
2✔
90
  }
91
}
92
export type CreateCommentRequestBodyArgItemFieldTypeField = 'file' | 'comment';
93
export interface CreateCommentRequestBodyArgItemField {
94
  readonly id: string;
95
  readonly type: CreateCommentRequestBodyArgItemFieldTypeField;
96
}
97
export interface CreateCommentRequestBodyArg {
98
  readonly message: string;
99
  readonly taggedMessage?: string;
100
  readonly item: CreateCommentRequestBodyArgItemField;
101
}
102
export interface CreateCommentQueryParamsArg {
103
  readonly fields?: readonly string[];
104
}
105
export class CreateCommentHeadersArg {
70✔
106
  readonly extraHeaders?: {
4✔
107
    readonly [key: string]: undefined | string;
108
  } = {};
109
  constructor(
110
    fields:
111
      | Omit<CreateCommentHeadersArg, 'extraHeaders'>
112
      | Partial<Pick<CreateCommentHeadersArg, 'extraHeaders'>>
113
  ) {
114
    Object.assign(this, fields);
4✔
115
  }
116
}
117
export class CommentsManager {
70✔
118
  readonly auth?: Authentication;
119
  readonly networkSession?: NetworkSession;
120
  constructor(
121
    fields: Omit<
122
      CommentsManager,
123
      | 'getFileComments'
124
      | 'getCommentById'
125
      | 'updateCommentById'
126
      | 'deleteCommentById'
127
      | 'createComment'
128
    >
129
  ) {
130
    Object.assign(this, fields);
104✔
131
  }
132
  async getFileComments(
133
    fileId: string,
134
    queryParams: GetFileCommentsQueryParamsArg = {} satisfies GetFileCommentsQueryParamsArg,
4✔
135
    headers: GetFileCommentsHeadersArg = new GetFileCommentsHeadersArg({}),
4✔
136
    cancellationToken?: CancellationToken
137
  ): Promise<Comments> {
138
    const queryParamsMap: {
139
      readonly [key: string]: string;
140
    } = prepareParams({
4✔
141
      ['fields']: queryParams.fields
4!
142
        ? queryParams.fields.map(toString).join(',')
143
        : undefined,
144
      ['limit']: toString(queryParams.limit) as string,
145
      ['offset']: toString(queryParams.offset) as string,
146
    });
147
    const headersMap: {
148
      readonly [key: string]: string;
149
    } = prepareParams({ ...{}, ...headers.extraHeaders });
4✔
150
    const response: FetchResponse = (await fetch(
4✔
151
      ''.concat(
152
        'https://api.box.com/2.0/files/',
153
        toString(fileId) as string,
154
        '/comments'
155
      ) as string,
156
      {
157
        method: 'GET',
158
        params: queryParamsMap,
159
        headers: headersMap,
160
        responseFormat: 'json',
161
        auth: this.auth,
162
        networkSession: this.networkSession,
163
        cancellationToken: cancellationToken,
164
      } satisfies FetchOptions
165
    )) as FetchResponse;
166
    return deserializeComments(response.data);
4✔
167
  }
168
  async getCommentById(
169
    commentId: string,
170
    queryParams: GetCommentByIdQueryParamsArg = {} satisfies GetCommentByIdQueryParamsArg,
4✔
171
    headers: GetCommentByIdHeadersArg = new GetCommentByIdHeadersArg({}),
4✔
172
    cancellationToken?: CancellationToken
173
  ): Promise<CommentFull> {
174
    const queryParamsMap: {
175
      readonly [key: string]: string;
176
    } = prepareParams({
4✔
177
      ['fields']: queryParams.fields
4!
178
        ? queryParams.fields.map(toString).join(',')
179
        : undefined,
180
    });
181
    const headersMap: {
182
      readonly [key: string]: string;
183
    } = prepareParams({ ...{}, ...headers.extraHeaders });
4✔
184
    const response: FetchResponse = (await fetch(
4✔
185
      ''.concat(
186
        'https://api.box.com/2.0/comments/',
187
        toString(commentId) as string
188
      ) as string,
189
      {
190
        method: 'GET',
191
        params: queryParamsMap,
192
        headers: headersMap,
193
        responseFormat: 'json',
194
        auth: this.auth,
195
        networkSession: this.networkSession,
196
        cancellationToken: cancellationToken,
197
      } satisfies FetchOptions
198
    )) as FetchResponse;
199
    return deserializeCommentFull(response.data);
2✔
200
  }
201
  async updateCommentById(
202
    commentId: string,
203
    requestBody: UpdateCommentByIdRequestBodyArg = {} satisfies UpdateCommentByIdRequestBodyArg,
×
204
    queryParams: UpdateCommentByIdQueryParamsArg = {} satisfies UpdateCommentByIdQueryParamsArg,
2✔
205
    headers: UpdateCommentByIdHeadersArg = new UpdateCommentByIdHeadersArg({}),
2✔
206
    cancellationToken?: CancellationToken
207
  ): Promise<CommentFull> {
208
    const queryParamsMap: {
209
      readonly [key: string]: string;
210
    } = prepareParams({
2✔
211
      ['fields']: queryParams.fields
2!
212
        ? queryParams.fields.map(toString).join(',')
213
        : undefined,
214
    });
215
    const headersMap: {
216
      readonly [key: string]: string;
217
    } = prepareParams({ ...{}, ...headers.extraHeaders });
2✔
218
    const response: FetchResponse = (await fetch(
2✔
219
      ''.concat(
220
        'https://api.box.com/2.0/comments/',
221
        toString(commentId) as string
222
      ) as string,
223
      {
224
        method: 'PUT',
225
        params: queryParamsMap,
226
        headers: headersMap,
227
        data: serializeUpdateCommentByIdRequestBodyArg(requestBody),
228
        contentType: 'application/json',
229
        responseFormat: 'json',
230
        auth: this.auth,
231
        networkSession: this.networkSession,
232
        cancellationToken: cancellationToken,
233
      } satisfies FetchOptions
234
    )) as FetchResponse;
235
    return deserializeCommentFull(response.data);
2✔
236
  }
237
  async deleteCommentById(
238
    commentId: string,
239
    headers: DeleteCommentByIdHeadersArg = new DeleteCommentByIdHeadersArg({}),
2✔
240
    cancellationToken?: CancellationToken
241
  ): Promise<undefined> {
242
    const headersMap: {
243
      readonly [key: string]: string;
244
    } = prepareParams({ ...{}, ...headers.extraHeaders });
2✔
245
    const response: FetchResponse = (await fetch(
2✔
246
      ''.concat(
247
        'https://api.box.com/2.0/comments/',
248
        toString(commentId) as string
249
      ) as string,
250
      {
251
        method: 'DELETE',
252
        headers: headersMap,
253
        responseFormat: void 0,
254
        auth: this.auth,
255
        networkSession: this.networkSession,
256
        cancellationToken: cancellationToken,
257
      } satisfies FetchOptions
258
    )) as FetchResponse;
259
    return void 0;
2✔
260
  }
261
  async createComment(
262
    requestBody: CreateCommentRequestBodyArg,
263
    queryParams: CreateCommentQueryParamsArg = {} satisfies CreateCommentQueryParamsArg,
4✔
264
    headers: CreateCommentHeadersArg = new CreateCommentHeadersArg({}),
4✔
265
    cancellationToken?: CancellationToken
266
  ): Promise<Comment> {
267
    const queryParamsMap: {
268
      readonly [key: string]: string;
269
    } = prepareParams({
4✔
270
      ['fields']: queryParams.fields
4!
271
        ? queryParams.fields.map(toString).join(',')
272
        : undefined,
273
    });
274
    const headersMap: {
275
      readonly [key: string]: string;
276
    } = prepareParams({ ...{}, ...headers.extraHeaders });
4✔
277
    const response: FetchResponse = (await fetch(
4✔
278
      ''.concat('https://api.box.com/2.0/comments') as string,
279
      {
280
        method: 'POST',
281
        params: queryParamsMap,
282
        headers: headersMap,
283
        data: serializeCreateCommentRequestBodyArg(requestBody),
284
        contentType: 'application/json',
285
        responseFormat: 'json',
286
        auth: this.auth,
287
        networkSession: this.networkSession,
288
        cancellationToken: cancellationToken,
289
      } satisfies FetchOptions
290
    )) as FetchResponse;
291
    return deserializeComment(response.data);
4✔
292
  }
293
}
294
export function serializeUpdateCommentByIdRequestBodyArg(
70✔
295
  val: UpdateCommentByIdRequestBodyArg
296
): SerializedData {
297
  return { ['message']: val.message == void 0 ? void 0 : val.message };
2!
298
}
299
export function deserializeUpdateCommentByIdRequestBodyArg(
70✔
300
  val: any
301
): UpdateCommentByIdRequestBodyArg {
302
  const message: undefined | string =
303
    val.message == void 0 ? void 0 : val.message;
×
304
  return { message: message } satisfies UpdateCommentByIdRequestBodyArg;
×
305
}
306
export function serializeCreateCommentRequestBodyArgItemFieldTypeField(
70✔
307
  val: CreateCommentRequestBodyArgItemFieldTypeField
308
): SerializedData {
309
  return val;
4✔
310
}
311
export function deserializeCreateCommentRequestBodyArgItemFieldTypeField(
70✔
312
  val: any
313
): CreateCommentRequestBodyArgItemFieldTypeField {
NEW
314
  if (!sdIsString(val)) {
×
315
    throw 'Expecting a string for "CreateCommentRequestBodyArgItemFieldTypeField"';
×
316
  }
317
  if (val == 'file') {
×
318
    return 'file';
×
319
  }
320
  if (val == 'comment') {
×
321
    return 'comment';
×
322
  }
323
  throw ''.concat('Invalid value: ', val) as string;
×
324
}
325
export function serializeCreateCommentRequestBodyArgItemField(
70✔
326
  val: CreateCommentRequestBodyArgItemField
327
): SerializedData {
328
  return {
4✔
329
    ['id']: val.id,
330
    ['type']: serializeCreateCommentRequestBodyArgItemFieldTypeField(val.type),
331
  };
332
}
333
export function deserializeCreateCommentRequestBodyArgItemField(
70✔
334
  val: any
335
): CreateCommentRequestBodyArgItemField {
336
  const id: string = val.id;
×
337
  const type: CreateCommentRequestBodyArgItemFieldTypeField =
338
    deserializeCreateCommentRequestBodyArgItemFieldTypeField(val.type);
×
339
  return { id: id, type: type } satisfies CreateCommentRequestBodyArgItemField;
×
340
}
341
export function serializeCreateCommentRequestBodyArg(
70✔
342
  val: CreateCommentRequestBodyArg
343
): SerializedData {
344
  return {
4✔
345
    ['message']: val.message,
346
    ['tagged_message']:
347
      val.taggedMessage == void 0 ? void 0 : val.taggedMessage,
4!
348
    ['item']: serializeCreateCommentRequestBodyArgItemField(val.item),
349
  };
350
}
351
export function deserializeCreateCommentRequestBodyArg(
70✔
352
  val: any
353
): CreateCommentRequestBodyArg {
354
  const message: string = val.message;
×
355
  const taggedMessage: undefined | string =
356
    val.tagged_message == void 0 ? void 0 : val.tagged_message;
×
357
  const item: CreateCommentRequestBodyArgItemField =
358
    deserializeCreateCommentRequestBodyArgItemField(val.item);
×
359
  return {
×
360
    message: message,
361
    taggedMessage: taggedMessage,
362
    item: item,
363
  } satisfies CreateCommentRequestBodyArg;
364
}
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

© 2025 Coveralls, Inc