Skip to content

Commit f0aaf53

Browse files
generated with codegen at box/box-codegen@23a331c6 and spec at box/box-openapi@d4c873b (#41)
1 parent 1aa8f5a commit f0aaf53

File tree

121 files changed

+4049
-2841
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+4049
-2841
lines changed

.github/workflows/build_and_test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jobs:
3333
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
3434
USER_ID: ${{ secrets.USER_ID }}
3535
ENTERPRISE_ID: ${{ secrets.ENTERPRISE_ID }}
36+
BOX_FILE_REQUEST_ID: ${{ secrets.BOX_FILE_REQUEST_ID }}
3637
- name: Coveralls
3738
uses: coverallsapp/github-action@master
3839
with:

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ Embrace the new generation of Box SDKs and unlock the full potential of the Box
2323

2424
- [Installing](#installing)
2525
- [Getting Started](#getting-started)
26+
- [Integration Tests](#integration-tests)
27+
- [Running integration tests locally](#running-integration-tests-locally)
28+
- [Create Custom Application](#create-custom-application)
29+
- [Export configuration](#export-configuration)
2630
- [Questions, Bugs, and Feature Requests?](#questions-bugs-and-feature-requests)
2731
- [Copyright and License](#copyright-and-license)
2832

@@ -69,6 +73,29 @@ async function main(token) {
6973
main('INSERT YOUR DEVELOPER TOKEN HERE');
7074
```
7175

76+
# Integration Tests
77+
78+
## Running integration tests locally
79+
80+
### Create Custom Application
81+
82+
To run integration tests locally you will need a `Custom App` created in the [Box Developer
83+
Console](https://app.box.com/developers/console) with `Server Authentication (with JWT)` selected as authentication method.
84+
Once created you can edit properties of the application:
85+
86+
- In section `App Access Level` select `App + Enterprise Access`. You can enable all `Application Scopes`.
87+
- In section `Advanced Features` enable `Make API calls using the as-user header` and `Generate user access tokens`.
88+
89+
Now select `Authorization` and submit application to be reviewed by account admin.
90+
91+
### Export configuration
92+
93+
1. Select `Configuration` tab and in the bottom in the section `App Settings`
94+
download your app configuration settings as JSON.
95+
2. Encode configuration file to Base64, e.g. using command: `base64 -i path_to_json_file`
96+
3. Set environment variable: `JWT_CONFIG_BASE_64` with base64 encoded jwt configuration file
97+
4. Set environment variable: `BOX_FILE_REQUEST_ID` with ID of file request already created in the user account.
98+
7299
# Questions, Bugs, and Feature Requests?
73100

74101
Need to contact us directly? [Browse the issues

docs/authentication.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
- [Token storage](#token-storage)
1919
- [In-memory token storage](#in-memory-token-storage)
2020
- [Custom storage](#custom-storage)
21-
- [Setting as-user header](#setting-as-user-header)
2221

2322
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
2423

@@ -354,11 +353,3 @@ const config = {
354353
};
355354
const oauth = new BoxOAuth({ config: config });
356355
```
357-
358-
# Setting as-user header
359-
360-
Use the code below to set the as-user header for your current client
361-
362-
```js
363-
client.networkSession!.setAsUserId('id');
364-
```

docs/chunkedUploads.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,3 +255,5 @@ await client.chunkedUploads.uploadBigFile(
255255
- The total size of the file for the chunked upload in bytes.
256256
- parentFolderId `string`
257257
- The ID of the folder where the file should be uploaded.
258+
- cancellationToken `undefined | CancellationToken`
259+
- Token used for request cancellation.

docs/client.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Client
2+
3+
This is the central entrypoint for all SDK interaction. The BoxClient houses all the API endpoints
4+
divided across resource managers.
5+
6+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
7+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
8+
9+
- [Additional headers](#additional-headers)
10+
- [As-User header](#as-user-header)
11+
- [Suppress notifications](#suppress-notifications)
12+
- [Custom headers](#custom-headers)
13+
14+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
15+
16+
# Additional headers
17+
18+
BoxClient provides a convenient methods, which allow passing additional headers, which will be included
19+
in every API call made by the client.
20+
21+
## As-User header
22+
23+
The As-User header is used by enterprise admins to make API calls on behalf of their enterprise's users.
24+
This requires the API request to pass an As-User: USER-ID header. For more details see the [documentation on As-User](https://developer.box.com/en/guides/authentication/oauth2/as-user/).
25+
26+
The following example assume that the client has been instantiated with an access token belonging to an admin-level user
27+
or Service Account with appropriate privileges to make As-User calls.
28+
29+
Calling the `client.withAsUserHeader()` method creates a new client to impersonate user with the provided ID.
30+
All calls made with the new client will be made in context of the impersonated user, leaving the original client unmodified.
31+
32+
<!-- sample x_auth init_with_as_user_header -->
33+
34+
```js
35+
const userClient = client.withAsUserHeader('1234567');
36+
```
37+
38+
## Suppress notifications
39+
40+
If you are making administrative API calls (that is, your application has “Manage an Enterprise”
41+
scope, and the user signing in is a co-admin with the correct "Edit settings for your company"
42+
permission) then you can suppress both email and webhook notifications. This can be used, for
43+
example, for a virus-scanning tool to download copies of everyone’s files in an enterprise,
44+
without every collaborator on the file getting an email. All actions will still appear in users'
45+
updates feed and audit logs.
46+
47+
> **Note:** This functionality is only available for approved applications.
48+
49+
Calling the `client.withSuppressedNotifications()` method creates a new client.
50+
For all calls made with the new client the notifications will be suppressed.
51+
52+
```js
53+
const newClient = client.withSuppressedNotifications();
54+
```
55+
56+
## Custom headers
57+
58+
You can also specify the custom set of headers, which will be included in every API call made by client.
59+
Calling the `client.withExtraHeaders()` method creates a new client, leaving the original client unmodified.
60+
61+
```js
62+
const newClient = client.withExtraHeaders({ ['customHeader']: 'customValue' });
63+
```

docs/fileRequests.md

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ This operation is performed by calling function `getFileRequestById`.
1414
See the endpoint docs at
1515
[API Reference](https://developer.box.com/reference/get-file-requests-id/).
1616

17-
_Currently we don't have an example for calling `getFileRequestById` in integration tests_
17+
<!-- sample get_file_requests_id -->
18+
19+
```ts
20+
await client.fileRequests.getFileRequestById(updatedFileRequest.id);
21+
```
1822

1923
### Arguments
2024

@@ -41,7 +45,14 @@ This operation is performed by calling function `updateFileRequestById`.
4145
See the endpoint docs at
4246
[API Reference](https://developer.box.com/reference/put-file-requests-id/).
4347

44-
_Currently we don't have an example for calling `updateFileRequestById` in integration tests_
48+
<!-- sample put_file_requests_id -->
49+
50+
```ts
51+
await client.fileRequests.updateFileRequestById(copiedFileRequest.id, {
52+
title: 'updated title',
53+
description: 'updated description',
54+
} satisfies FileRequestUpdateRequest);
55+
```
4556

4657
### Arguments
4758

@@ -69,7 +80,11 @@ This operation is performed by calling function `deleteFileRequestById`.
6980
See the endpoint docs at
7081
[API Reference](https://developer.box.com/reference/delete-file-requests-id/).
7182

72-
_Currently we don't have an example for calling `deleteFileRequestById` in integration tests_
83+
<!-- sample delete_file_requests_id -->
84+
85+
```ts
86+
await client.fileRequests.deleteFileRequestById(updatedFileRequest.id);
87+
```
7388

7489
### Arguments
7590

@@ -97,7 +112,16 @@ This operation is performed by calling function `createFileRequestCopy`.
97112
See the endpoint docs at
98113
[API Reference](https://developer.box.com/reference/post-file-requests-id-copy/).
99114

100-
_Currently we don't have an example for calling `createFileRequestCopy` in integration tests_
115+
<!-- sample post_file_requests_id_copy -->
116+
117+
```ts
118+
await client.fileRequests.createFileRequestCopy(fileRequestId, {
119+
folder: {
120+
id: fileRequest.folder.id,
121+
type: 'folder' as FileRequestCopyRequestFolderFieldTypeField,
122+
} satisfies FileRequestCopyRequestFolderField,
123+
} satisfies FileRequestCopyRequest);
124+
```
101125

102126
### Arguments
103127

docs/legalHoldPolicies.md

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ This operation is performed by calling function `getLegalHoldPolicies`.
1616
See the endpoint docs at
1717
[API Reference](https://developer.box.com/reference/get-legal-hold-policies/).
1818

19-
_Currently we don't have an example for calling `getLegalHoldPolicies` in integration tests_
19+
<!-- sample get_legal_hold_policies -->
20+
21+
```ts
22+
await client.legalHoldPolicies.getLegalHoldPolicies();
23+
```
2024

2125
### Arguments
2226

@@ -42,7 +46,15 @@ This operation is performed by calling function `createLegalHoldPolicy`.
4246
See the endpoint docs at
4347
[API Reference](https://developer.box.com/reference/post-legal-hold-policies/).
4448

45-
_Currently we don't have an example for calling `createLegalHoldPolicy` in integration tests_
49+
<!-- sample post_legal_hold_policies -->
50+
51+
```ts
52+
await client.legalHoldPolicies.createLegalHoldPolicy({
53+
policyName: legalHoldPolicyName,
54+
description: legalHoldDescription,
55+
isOngoing: true,
56+
} satisfies CreateLegalHoldPolicyRequestBodyArg);
57+
```
4658

4759
### Arguments
4860

@@ -68,7 +80,11 @@ This operation is performed by calling function `getLegalHoldPolicyById`.
6880
See the endpoint docs at
6981
[API Reference](https://developer.box.com/reference/get-legal-hold-policies-id/).
7082

71-
_Currently we don't have an example for calling `getLegalHoldPolicyById` in integration tests_
83+
<!-- sample get_legal_hold_policies_id -->
84+
85+
```ts
86+
await client.legalHoldPolicies.getLegalHoldPolicyById(legalHoldPolicyId);
87+
```
7288

7389
### Arguments
7490

@@ -94,7 +110,13 @@ This operation is performed by calling function `updateLegalHoldPolicyById`.
94110
See the endpoint docs at
95111
[API Reference](https://developer.box.com/reference/put-legal-hold-policies-id/).
96112

97-
_Currently we don't have an example for calling `updateLegalHoldPolicyById` in integration tests_
113+
<!-- sample put_legal_hold_policies_id -->
114+
115+
```ts
116+
await client.legalHoldPolicies.updateLegalHoldPolicyById(legalHoldPolicyId, {
117+
policyName: updatedLegalHoldPolicyName,
118+
} satisfies UpdateLegalHoldPolicyByIdRequestBodyArg);
119+
```
98120

99121
### Arguments
100122

@@ -125,7 +147,11 @@ This operation is performed by calling function `deleteLegalHoldPolicyById`.
125147
See the endpoint docs at
126148
[API Reference](https://developer.box.com/reference/delete-legal-hold-policies-id/).
127149

128-
_Currently we don't have an example for calling `deleteLegalHoldPolicyById` in integration tests_
150+
<!-- sample delete_legal_hold_policies_id -->
151+
152+
```ts
153+
await client.legalHoldPolicies.deleteLegalHoldPolicyById(legalHoldPolicyId);
154+
```
129155

130156
### Arguments
131157

docs/zipDownloads.md

Lines changed: 78 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- [Create zip download](#create-zip-download)
44
- [Download zip archive](#download-zip-archive)
55
- [Get zip download status](#get-zip-download-status)
6+
- [](#)
67

78
## Create zip download
89

@@ -28,7 +29,27 @@ This operation is performed by calling function `createZipDownload`.
2829
See the endpoint docs at
2930
[API Reference](https://developer.box.com/reference/post-zip-downloads/).
3031

31-
_Currently we don't have an example for calling `createZipDownload` in integration tests_
32+
<!-- sample post_zip_downloads -->
33+
34+
```ts
35+
await client.zipDownloads.createZipDownload({
36+
items: [
37+
{
38+
id: file1.id,
39+
type: 'file' as ZipDownloadRequestItemsFieldTypeField,
40+
} satisfies ZipDownloadRequestItemsField,
41+
{
42+
id: file2.id,
43+
type: 'file' as ZipDownloadRequestItemsFieldTypeField,
44+
} satisfies ZipDownloadRequestItemsField,
45+
{
46+
id: folder1.id,
47+
type: 'folder' as ZipDownloadRequestItemsFieldTypeField,
48+
} satisfies ZipDownloadRequestItemsField,
49+
],
50+
downloadFileName: 'zip',
51+
} satisfies ZipDownloadRequest);
52+
```
3253

3354
### Arguments
3455

@@ -68,12 +89,16 @@ This operation is performed by calling function `getZipDownloadContent`.
6889
See the endpoint docs at
6990
[API Reference](https://developer.box.com/reference/get-zip-downloads-id-content/).
7091

71-
_Currently we don't have an example for calling `getZipDownloadContent` in integration tests_
92+
<!-- sample get_zip_downloads_id_content -->
93+
94+
```ts
95+
await client.zipDownloads.getZipDownloadContent(zipDownload.downloadUrl!);
96+
```
7297

7398
### Arguments
7499

75-
- zipDownloadId `string`
76-
- The unique identifier that represent this `zip` archive. Example: "Lu6fA9Ob-jyysp3AAvMF4AkLEwZwAYbL=tgj2zIC=eK9RvJnJbjJl9rNh2qBgHDpyOCAOhpM=vajg2mKq8Mdd"
100+
- downloadUrl `string`
101+
- The URL that can be used to download created `zip` archive. Example: `https://dl.boxcloud.com/2.0/zip_downloads/29l00nfxDyHOt7RphI9zT_w==nDnZEDjY2S8iEWWCHEEiptFxwoWojjlibZjJ6geuE5xnXENDTPxzgbks_yY=/content`
77102
- headers `GetZipDownloadContentHeadersArg`
78103
- Headers of getZipDownloadContent method
79104
- cancellationToken `undefined | CancellationToken`
@@ -106,12 +131,16 @@ This operation is performed by calling function `getZipDownloadStatus`.
106131
See the endpoint docs at
107132
[API Reference](https://developer.box.com/reference/get-zip-downloads-id-status/).
108133

109-
_Currently we don't have an example for calling `getZipDownloadStatus` in integration tests_
134+
<!-- sample get_zip_downloads_id_status -->
135+
136+
```ts
137+
await client.zipDownloads.getZipDownloadStatus(zipDownload.statusUrl!);
138+
```
110139

111140
### Arguments
112141

113-
- zipDownloadId `string`
114-
- The unique identifier that represent this `zip` archive. Example: "Lu6fA9Ob-jyysp3AAvMF4AkLEwZwAYbL=tgj2zIC=eK9RvJnJbjJl9rNh2qBgHDpyOCAOhpM=vajg2mKq8Mdd"
142+
- statusUrl `string`
143+
- The URL that can be used to get the status of the `zip` archive being downloaded. Example: `https://dl.boxcloud.com/2.0/zip_downloads/29l00nfxDyHOt7RphI9zT_w==nDnZEDjY2S8iEWWCHEEiptFxwoWojjlibZjJ6geuE5xnXENDTPxzgbks_yY=/status`
115144
- headers `GetZipDownloadStatusHeadersArg`
116145
- Headers of getZipDownloadStatus method
117146
- cancellationToken `undefined | CancellationToken`
@@ -122,3 +151,45 @@ _Currently we don't have an example for calling `getZipDownloadStatus` in integr
122151
This function returns a value of type `ZipDownloadStatus`.
123152

124153
Returns the status of the `zip` archive that is being downloaded.
154+
155+
##
156+
157+
This operation is performed by calling function `downloadZip`.
158+
159+
See the endpoint docs at
160+
[API Reference](https://developer.box.com/reference//).
161+
162+
<!-- sample -->
163+
164+
```ts
165+
await client.zipDownloads.downloadZip({
166+
items: [
167+
{
168+
id: file1.id,
169+
type: 'file' as ZipDownloadRequestItemsFieldTypeField,
170+
} satisfies ZipDownloadRequestItemsField,
171+
{
172+
id: file2.id,
173+
type: 'file' as ZipDownloadRequestItemsFieldTypeField,
174+
} satisfies ZipDownloadRequestItemsField,
175+
{
176+
id: folder1.id,
177+
type: 'folder' as ZipDownloadRequestItemsFieldTypeField,
178+
} satisfies ZipDownloadRequestItemsField,
179+
],
180+
downloadFileName: 'zip',
181+
} satisfies ZipDownloadRequest);
182+
```
183+
184+
### Arguments
185+
186+
- requestBody `ZipDownloadRequest`
187+
- Zip download request body
188+
- headers `DownloadZipHeadersArg`
189+
- Headers of zip download method
190+
- cancellationToken `undefined | CancellationToken`
191+
- Token used for request cancellation.
192+
193+
### Returns
194+
195+
This function returns a value of type `ByteStream`.

0 commit comments

Comments
 (0)