• 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

27.91
/src/managers/sessionTermination.generated.ts
1
import { serializeSessionTerminationMessage } from '../schemas.generated.js';
2
import { deserializeSessionTerminationMessage } from '../schemas.generated.js';
70✔
3
import { serializeClientError } from '../schemas.generated.js';
4
import { deserializeClientError } from '../schemas.generated.js';
5
import { SessionTerminationMessage } from '../schemas.generated.js';
6
import { ClientError } from '../schemas.generated.js';
7
import { Authentication } from '../auth.js';
8
import { NetworkSession } from '../network.js';
9
import { prepareParams } from '../utils.js';
70✔
10
import { toString } from '../utils.js';
11
import { ByteStream } from '../utils.js';
12
import { CancellationToken } from '../utils.js';
13
import { fetch } from '../fetch.js';
70✔
14
import { FetchOptions } from '../fetch.js';
15
import { FetchResponse } from '../fetch.js';
16
import { SerializedData } from '../json.js';
17
import { sdIsEmpty } from '../json.js';
18
import { sdIsBoolean } from '../json.js';
19
import { sdIsNumber } from '../json.js';
20
import { sdIsString } from '../json.js';
21
import { sdIsList } from '../json.js';
70✔
22
import { sdIsMap } from '../json.js';
23
export interface CreateUserTerminateSessionRequestBodyArg {
24
  readonly userIds: readonly string[];
25
  readonly userLogins: readonly string[];
26
}
27
export class CreateUserTerminateSessionHeadersArg {
70✔
28
  readonly extraHeaders?: {
×
29
    readonly [key: string]: undefined | string;
30
  } = {};
31
  constructor(
32
    fields:
33
      | Omit<CreateUserTerminateSessionHeadersArg, 'extraHeaders'>
34
      | Partial<Pick<CreateUserTerminateSessionHeadersArg, 'extraHeaders'>>
35
  ) {
36
    Object.assign(this, fields);
×
37
  }
38
}
39
export interface CreateGroupTerminateSessionRequestBodyArg {
40
  readonly groupIds: readonly string[];
41
}
42
export class CreateGroupTerminateSessionHeadersArg {
70✔
43
  readonly extraHeaders?: {
×
44
    readonly [key: string]: undefined | string;
45
  } = {};
46
  constructor(
47
    fields:
48
      | Omit<CreateGroupTerminateSessionHeadersArg, 'extraHeaders'>
49
      | Partial<Pick<CreateGroupTerminateSessionHeadersArg, 'extraHeaders'>>
50
  ) {
51
    Object.assign(this, fields);
×
52
  }
53
}
54
export class SessionTerminationManager {
70✔
55
  readonly auth?: Authentication;
56
  readonly networkSession?: NetworkSession;
57
  constructor(
58
    fields: Omit<
59
      SessionTerminationManager,
60
      'createUserTerminateSession' | 'createGroupTerminateSession'
61
    >
62
  ) {
63
    Object.assign(this, fields);
104✔
64
  }
65
  async createUserTerminateSession(
66
    requestBody: CreateUserTerminateSessionRequestBodyArg,
67
    headers: CreateUserTerminateSessionHeadersArg = new CreateUserTerminateSessionHeadersArg(
×
68
      {}
69
    ),
70
    cancellationToken?: CancellationToken
71
  ): Promise<SessionTerminationMessage> {
72
    const headersMap: {
73
      readonly [key: string]: string;
74
    } = prepareParams({ ...{}, ...headers.extraHeaders });
×
75
    const response: FetchResponse = (await fetch(
×
76
      ''.concat('https://api.box.com/2.0/users/terminate_sessions') as string,
77
      {
78
        method: 'POST',
79
        headers: headersMap,
80
        data: serializeCreateUserTerminateSessionRequestBodyArg(requestBody),
81
        contentType: 'application/json',
82
        responseFormat: 'json',
83
        auth: this.auth,
84
        networkSession: this.networkSession,
85
        cancellationToken: cancellationToken,
86
      } satisfies FetchOptions
87
    )) as FetchResponse;
NEW
88
    return deserializeSessionTerminationMessage(response.data);
×
89
  }
90
  async createGroupTerminateSession(
91
    requestBody: CreateGroupTerminateSessionRequestBodyArg,
92
    headers: CreateGroupTerminateSessionHeadersArg = new CreateGroupTerminateSessionHeadersArg(
×
93
      {}
94
    ),
95
    cancellationToken?: CancellationToken
96
  ): Promise<SessionTerminationMessage> {
97
    const headersMap: {
98
      readonly [key: string]: string;
99
    } = prepareParams({ ...{}, ...headers.extraHeaders });
×
100
    const response: FetchResponse = (await fetch(
×
101
      ''.concat('https://api.box.com/2.0/groups/terminate_sessions') as string,
102
      {
103
        method: 'POST',
104
        headers: headersMap,
105
        data: serializeCreateGroupTerminateSessionRequestBodyArg(requestBody),
106
        contentType: 'application/json',
107
        responseFormat: 'json',
108
        auth: this.auth,
109
        networkSession: this.networkSession,
110
        cancellationToken: cancellationToken,
111
      } satisfies FetchOptions
112
    )) as FetchResponse;
NEW
113
    return deserializeSessionTerminationMessage(response.data);
×
114
  }
115
}
116
export function serializeCreateUserTerminateSessionRequestBodyArg(
70✔
117
  val: CreateUserTerminateSessionRequestBodyArg
118
): SerializedData {
119
  return {
×
120
    ['user_ids']: val.userIds.map(function (item: string): any {
121
      return item;
×
122
    }) as readonly any[],
123
    ['user_logins']: val.userLogins.map(function (item: string): any {
124
      return item;
×
125
    }) as readonly any[],
126
  };
127
}
128
export function deserializeCreateUserTerminateSessionRequestBodyArg(
70✔
129
  val: any
130
): CreateUserTerminateSessionRequestBodyArg {
NEW
131
  const userIds: readonly string[] = sdIsList(val.user_ids)
×
132
    ? (val.user_ids.map(function (itm: SerializedData): any {
UNCOV
133
        return itm;
×
134
      }) as readonly any[])
135
    : [];
NEW
136
  const userLogins: readonly string[] = sdIsList(val.user_logins)
×
137
    ? (val.user_logins.map(function (itm: SerializedData): any {
UNCOV
138
        return itm;
×
139
      }) as readonly any[])
140
    : [];
141
  return {
×
142
    userIds: userIds,
143
    userLogins: userLogins,
144
  } satisfies CreateUserTerminateSessionRequestBodyArg;
145
}
146
export function serializeCreateGroupTerminateSessionRequestBodyArg(
70✔
147
  val: CreateGroupTerminateSessionRequestBodyArg
148
): SerializedData {
149
  return {
×
150
    ['group_ids']: val.groupIds.map(function (item: string): any {
151
      return item;
×
152
    }) as readonly any[],
153
  };
154
}
155
export function deserializeCreateGroupTerminateSessionRequestBodyArg(
70✔
156
  val: any
157
): CreateGroupTerminateSessionRequestBodyArg {
NEW
158
  const groupIds: readonly string[] = sdIsList(val.group_ids)
×
159
    ? (val.group_ids.map(function (itm: SerializedData): any {
UNCOV
160
        return itm;
×
161
      }) as readonly any[])
162
    : [];
163
  return {
×
164
    groupIds: groupIds,
165
  } satisfies CreateGroupTerminateSessionRequestBodyArg;
166
}
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