-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathshare.js
46 lines (37 loc) · 1.23 KB
/
share.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
'use strict';
const BoxCommand = require('../../box-command');
const { Args } = require('@oclif/core');
const { sharedLinkFlags, sharedLinkFileFlags } = require('../shared-links/create');
const SharedLinksModule = require('../../modules/shared-links');
class FilesShareCommand extends BoxCommand {
async run() {
const { args, flags } = await this.parse(FilesShareCommand);
// Transform arguments for generic module
args.itemType = 'file';
args.itemID = args.id;
delete args.id;
let sharedLinksModule = new SharedLinksModule(this.client);
let updatedItem = await sharedLinksModule.createSharedLink(args, flags);
await this.output(updatedItem);
}
}
FilesShareCommand.aliases = [
'files:shared-links:create',
'files:shared-links:update',
];
FilesShareCommand.description = 'Create a shared link for a file';
FilesShareCommand.examples = ['box files:share 11111 --access company --vanity-name my-custom-name-123'];
FilesShareCommand._endpoint = 'put_files_id create_shared_link';
FilesShareCommand.flags = {
...sharedLinkFlags,
...sharedLinkFileFlags
};
FilesShareCommand.args = {
id: Args.string({
name: 'id',
required: true,
hidden: false,
description: 'ID of the file to share',
}),
};
module.exports = FilesShareCommand;