Skip to content

Commit

Permalink
feat: Add id and type field to shared-links:create response (#427)
Browse files Browse the repository at this point in the history
* feat: Add `id` and `type` field  to shared-links:create response
  • Loading branch information
congminh1254 authored Nov 10, 2022
1 parent 2c89af1 commit 5ea4cb8
Show file tree
Hide file tree
Showing 15 changed files with 90 additions and 245 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@oclif/plugin-help": "^2.2.1",
"@oclif/plugin-not-found": "^1.2.0",
"archiver": "^3.0.0",
"box-node-sdk": "^2.7.1",
"box-node-sdk": "^2.7.2",
"chalk": "^2.4.1",
"cli-progress": "^2.1.0",
"csv": "^3.1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/files/share.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class FilesShareCommand extends BoxCommand {

let sharedLinksModule = new SharedLinksModule(this.client);
let updatedItem = await sharedLinksModule.createSharedLink(args, flags);
await this.output(updatedItem.shared_link);
await this.output(updatedItem);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/folders/share.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class FoldersShareCommand extends BoxCommand {

let sharedLinksModule = new SharedLinksModule(this.client);
let updatedItem = await sharedLinksModule.createSharedLink(args, flags);
await this.output(updatedItem.shared_link);
await this.output(updatedItem);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/commands/shared-links/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ const SharedLinksModule = require('../../modules/shared-links');
class SharedLinksCreateCommand extends BoxCommand {
async run() {
const { flags, args } = this.parse(SharedLinksCreateCommand);

let sharedLinksModule = new SharedLinksModule(this.client);
let updatedItem = await sharedLinksModule.createSharedLink(args, flags);
await this.output(updatedItem.shared_link);
await this.output(updatedItem);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/modules/shared-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class SharedLinksModule {
* @returns {Promise<Object>} A promise resolving to the updated item object
*/
createSharedLink(args, flags) {
let updates = { shared_link: { permissions: {} } };
let updates = { shared_link: { permissions: {} }, fields: 'shared_link' };

if (flags.access) {
updates.shared_link.access = flags.access;
Expand Down
8 changes: 4 additions & 4 deletions test/commands/files.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ describe('Files', () => {

test
.nock(TEST_API_ROOT, api => api
.put(`/2.0/files/${fileId}`, sharedLinkBody)
.put(`/2.0/files/${fileId}?fields=shared_link`, sharedLinkBody)
.reply(200, createSharedLinkFixture)
)
.stdout()
Expand All @@ -1140,7 +1140,7 @@ describe('Files', () => {

test
.nock(TEST_API_ROOT, api => api
.put(`/2.0/files/${fileId}`, sharedLinkBody)
.put(`/2.0/files/${fileId}?fields=shared_link`, sharedLinkBody)
.reply(200, createSharedLinkFixture)
)
.stdout()
Expand All @@ -1159,7 +1159,7 @@ describe('Files', () => {

test
.nock(TEST_API_ROOT, api => api
.put(`/2.0/files/${fileId}`, {
.put(`/2.0/files/${fileId}?fields=shared_link`, {
shared_link: {
permissions: {},
unshared_at: unsharedDate,
Expand All @@ -1181,7 +1181,7 @@ describe('Files', () => {

test
.nock(TEST_API_ROOT, api => api
.put(`/2.0/files/${fileId}`, {
.put(`/2.0/files/${fileId}?fields=shared_link`, {
shared_link: {
permissions: {},
unshared_at: unsharedDate,
Expand Down
6 changes: 3 additions & 3 deletions test/commands/folders.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ describe('Folders', () => {

test
.nock(TEST_API_ROOT, api => api
.put(`/2.0/folders/${folderId}`, sharedLinkBody)
.put(`/2.0/folders/${folderId}?fields=shared_link`, sharedLinkBody)
.reply(200, createSharedLinkFixture)
)
.stdout()
Expand All @@ -927,7 +927,7 @@ describe('Folders', () => {

test
.nock(TEST_API_ROOT, api => api
.put(`/2.0/folders/${folderId}`, sharedLinkBody)
.put(`/2.0/folders/${folderId}?fields=shared_link`, sharedLinkBody)
.reply(200, createSharedLinkFixture)
)
.stdout()
Expand All @@ -945,7 +945,7 @@ describe('Folders', () => {

test
.nock(TEST_API_ROOT, api => api
.put(`/2.0/folders/${folderId}`, {
.put(`/2.0/folders/${folderId}?fields=shared_link`, {
shared_link: {
permissions: {},
unshared_at: unshareDate,
Expand Down
8 changes: 4 additions & 4 deletions test/commands/shared-links.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('Shared-Links', () => {
test
.nock(TEST_API_ROOT, (api) =>
api
.put(`/2.0/files/${fileId}`, fileSharedLinkBody)
.put(`/2.0/files/${fileId}?fields=shared_link`, fileSharedLinkBody)
.reply(200, createFileSharedLinkFixture)
)
.stdout()
Expand All @@ -84,7 +84,7 @@ describe('Shared-Links', () => {
test
.nock(TEST_API_ROOT, (api) =>
api
.put(`/2.0/files/${fileId}`, fileSharedLinkBody)
.put(`/2.0/files/${fileId}?fields=shared_link`, fileSharedLinkBody)
.reply(200, createFileSharedLinkFixture)
)
.stdout()
Expand Down Expand Up @@ -117,7 +117,7 @@ describe('Shared-Links', () => {
test
.nock(TEST_API_ROOT, (api) =>
api
.put(`/2.0/folders/${folderId}`, folderSharedLinkBody)
.put(`/2.0/folders/${folderId}?fields=shared_link`, folderSharedLinkBody)
.reply(200, createFolderSharedLinkFixture)
)
.stdout()
Expand All @@ -138,7 +138,7 @@ describe('Shared-Links', () => {
test
.nock(TEST_API_ROOT, (api) =>
api
.put(`/2.0/folders/${folderId}`, folderSharedLinkBody)
.put(`/2.0/folders/${folderId}?fields=shared_link`, folderSharedLinkBody)
.reply(200, createFolderSharedLinkFixture)
)
.stdout()
Expand Down
64 changes: 1 addition & 63 deletions test/fixtures/files/put_files_id_shared_link.json
Original file line number Diff line number Diff line change
@@ -1,60 +1,6 @@
{
"type": "file",
"id": "1234567890",
"file_version": {
"type": "file_version",
"id": "11223344556677",
"sha1": "97b3dbba6eab7ad0f058240744c8636b7c7bea93"
},
"sequence_id": "1",
"etag": "1",
"sha1": "97b3dbba6eab7ad0f058240744c8636b7c7bea93",
"name": "Puppy.png",
"description": "",
"size": 106833,
"path_collection": {
"total_count": 2,
"entries": [
{
"type": "folder",
"id": "0",
"sequence_id": null,
"etag": null,
"name": "All Files"
},
{
"type": "folder",
"id": "987654321",
"sequence_id": "0",
"etag": "0",
"name": "Collaborated Folder"
}
]
},
"created_at": "2016-11-16T22:01:44-08:00",
"modified_at": "2016-11-16T22:01:51-08:00",
"trashed_at": null,
"purged_at": null,
"content_created_at": "2016-10-29T18:33:50-07:00",
"content_modified_at": "2016-10-29T18:33:50-07:00",
"created_by": {
"type": "user",
"id": "1357924680",
"name": "Owner",
"login": "owner@example.com"
},
"modified_by": {
"type": "user",
"id": "1357924680",
"name": "Owner",
"login": "owner@example.com"
},
"owned_by": {
"type": "user",
"id": "1357924680",
"name": "Owner",
"login": "owner@example.com"
},
"shared_link": {
"url": "https://blosserdemoaccount.box.com/s/7mcmdlavtye5o5i0ue8xmtwh2sx5bv8p",
"download_url": "https://blosserdemoaccount.box.com/shared/static/7mcmdlavtye5o5i0ue8xmtwh2sx5bv8p.png",
Expand All @@ -70,13 +16,5 @@
"can_preview": true,
"can_edit": true
}
},
"parent": {
"type": "folder",
"id": "987654321",
"sequence_id": "0",
"etag": "0",
"name": "Collaborated Folder"
},
"item_status": "active"
}
}
107 changes: 0 additions & 107 deletions test/fixtures/folders/put_folders_id_shared_link.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,6 @@
{
"type": "folder",
"id": "0",
"sequence_id": null,
"etag": null,
"name": "All Files",
"created_at": null,
"modified_at": null,
"description": "",
"size": 8183737,
"path_collection": {
"total_count": 0,
"entries": []
},
"created_by": {
"type": "user",
"id": "",
"name": "",
"login": ""
},
"modified_by": {
"type": "user",
"id": "33333",
"name": "Test User",
"login": "testuser@example.com"
},
"trashed_at": null,
"purged_at": null,
"content_created_at": null,
"content_modified_at": null,
"owned_by": {
"type": "user",
"id": "33333",
"name": "Test User",
"login": "testuser@example.com"
},
"shared_link": {
"url": "https://blosserdemoaccount.box.com/s/7mcmdlavtye5o5i0ue8xmtwh2sx5bv8p",
"download_url": "https://blosserdemoaccount.box.com/shared/static/7mcmdlavtye5o5i0ue8xmtwh2sx5bv8p.png",
Expand All @@ -48,79 +15,5 @@
"can_download": true,
"can_preview": true
}
},
"folder_upload_email": null,
"parent": null,
"item_status": "active",
"item_collection": {
"total_count": 6,
"entries": [
{
"type": "folder",
"id": "44444",
"sequence_id": "1",
"etag": "1",
"name": "Collab Folder"
},
{
"type": "folder",
"id": "55555",
"sequence_id": "0",
"etag": "0",
"name": "Copied Folder"
},
{
"type": "folder",
"id": "66666",
"sequence_id": "0",
"etag": "0",
"name": "SDK Test Folder"
},
{
"type": "folder",
"id": "77777",
"sequence_id": "1",
"etag": "1",
"name": "Test Folder"
},
{
"type": "file",
"id": "88888",
"file_version": {
"type": "file_version",
"id": "888880",
"sha1": "6afc05eae22e994f1c7dd48e58f8895dd9028223"
},
"sequence_id": "0",
"etag": "0",
"sha1": "6afc05eae22e994f1c7dd48e58f8895dd9028223",
"name": "Copied file.txt"
},
{
"type": "file",
"id": "99999",
"file_version": {
"type": "file_version",
"id": "999990",
"sha1": "97cc02de7c356f94e3beeb1e0c63f78a6edb01fd"
},
"sequence_id": "9",
"etag": "9",
"sha1": "97cc02de7c356f94e3beeb1e0c63f78a6edb01fd",
"name": "test file.txt"
}
],
"offset": 0,
"limit": 100,
"order": [
{
"by": "type",
"direction": "ASC"
},
{
"by": "name",
"direction": "ASC"
}
]
}
}
Loading

0 comments on commit 5ea4cb8

Please sign in to comment.