-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathtransfer-content.js
57 lines (48 loc) · 1.58 KB
/
transfer-content.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
47
48
49
50
51
52
53
54
55
56
57
'use strict';
const BoxCommand = require('../../box-command');
const { Flags, Args } = require('@oclif/core');
class UsersMoveRootContentCommand extends BoxCommand {
async run() {
const { flags, args } = await this.parse(UsersMoveRootContentCommand);
let params = {
body: {
owned_by: {
id: args.newUserID
}
},
qs: {}
};
if (flags.hasOwnProperty('notify')) {
params.qs.notify = flags.notify;
}
// @TODO (2018-07-07): Should implement this using the Node SDK. Existing this.client.enterprise.transferUserContent() does not allow the notify option to be passed
let movedFolder = await this.client.wrapWithDefaultHandler(this.client.put)(`/users/${args.userID}/folders/0`, params);
await this.output(movedFolder);
}
}
UsersMoveRootContentCommand.aliases = [ 'users:move-root-content' ];
UsersMoveRootContentCommand.description = 'Move a user\'s root content to another user';
UsersMoveRootContentCommand.examples = ['box users:transfer-content 33333 44444'];
UsersMoveRootContentCommand._endpoint = 'put_users_id_folders_id';
UsersMoveRootContentCommand.flags = {
...BoxCommand.flags,
notify: Flags.boolean({
description: 'Notify the user that their content has been moved',
allowNo: true
})
};
UsersMoveRootContentCommand.args = {
userID: Args.string({
name: 'userID',
required: true,
hidden: false,
description: 'User whose content should be moved'
}),
newUserID: Args.string({
name: 'newUserID',
required: true,
hidden: false,
description: 'User to whom the content should be moved'
}),
};
module.exports = UsersMoveRootContentCommand;