Skip to content

Commit 163a367

Browse files
authored
feat: Support integration mappings for Teams (#579)
1 parent 6750708 commit 163a367

File tree

8 files changed

+544
-46
lines changed

8 files changed

+544
-46
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
'use strict';
2+
3+
const BoxCommand = require('../../../box-command');
4+
const { Args } = require('@oclif/core');
5+
6+
class IntegrationMappingsTeamsCreateCommand extends BoxCommand {
7+
async run() {
8+
const { args } = await this.parse(IntegrationMappingsTeamsCreateCommand);
9+
let body = {};
10+
body.boxItem = {
11+
type: 'folder',
12+
id: args.boxItemID
13+
};
14+
body.partnerItem = {
15+
type: args.partnerItemType,
16+
id: args.partnerItemID,
17+
teamId: args.partnerItemTeamID,
18+
tenantId: args.partnerItemTenantID
19+
};
20+
21+
let integrationMapping = await this.tsClient.integrationMappings.createTeamsIntegrationMapping(body);
22+
delete integrationMapping.rawData;
23+
await this.output(integrationMapping);
24+
}
25+
}
26+
27+
IntegrationMappingsTeamsCreateCommand.description = 'Create Teams integration mapping';
28+
IntegrationMappingsTeamsCreateCommand.examples = [
29+
'box integration-mappings:teams:create 123 19%ABCD-Avgfggkggyftdtfgghjhkhkhh%40thread:tacv2 hjgjgjg-bhhj-564a-b643-hghgj685u abcd-defg-1235-7890',
30+
];
31+
IntegrationMappingsTeamsCreateCommand._endpoint = 'post_integration_mappings_teams';
32+
33+
IntegrationMappingsTeamsCreateCommand.args = {
34+
boxItemID: Args.string({
35+
name: 'boxItemID',
36+
required: true,
37+
hidden: false,
38+
description: 'ID of the mapped folder'
39+
}),
40+
partnerItemID: Args.string({
41+
name: 'partnerItemID',
42+
required: true,
43+
hidden: false,
44+
description: 'ID of the mapped item'
45+
}),
46+
partnerItemType: Args.string({
47+
name: 'partnerItemType',
48+
required: true,
49+
hidden: false,
50+
description: 'Type of the mapped item, value is one of: channel, team'
51+
}),
52+
partnerItemTeamID: Args.string({
53+
name: 'partnerItemTeamID',
54+
required: true,
55+
hidden: false,
56+
description: 'ID of the team that is registered with Microsoft Teams'
57+
}),
58+
partnerItemTenantID: Args.string({
59+
name: 'partnerItemTenantID',
60+
required: true,
61+
hidden: false,
62+
description: 'ID of the tenant that is registered with Microsoft Teams'
63+
})
64+
};
65+
66+
module.exports = IntegrationMappingsTeamsCreateCommand;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
'use strict';
2+
3+
const { Args } = require('@oclif/core');
4+
const BoxCommand = require('../../../box-command');
5+
6+
class IntegrationMappingsTeamsDeleteCommand extends BoxCommand {
7+
async run() {
8+
const { args } = await this.parse(IntegrationMappingsTeamsDeleteCommand);
9+
10+
await this.tsClient.integrationMappings.deleteTeamsIntegrationMappingById(args.id);
11+
this.info(`Deleted Teams integration mapping ${args.id}`);
12+
}
13+
}
14+
15+
IntegrationMappingsTeamsDeleteCommand.description = 'Delete Teams integration mapping';
16+
IntegrationMappingsTeamsDeleteCommand.examples = ['box integration-mappings:teams:delete 123'];
17+
IntegrationMappingsTeamsDeleteCommand._endpoint = 'delete_integration_mappings_teams_id';
18+
19+
IntegrationMappingsTeamsDeleteCommand.flags = {
20+
...BoxCommand.flags
21+
};
22+
23+
IntegrationMappingsTeamsDeleteCommand.args = {
24+
id: Args.string({
25+
name: 'id',
26+
required: true,
27+
hidden: false,
28+
description: 'ID of the integration mapping',
29+
}),
30+
};
31+
32+
module.exports = IntegrationMappingsTeamsDeleteCommand;
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
'use strict';
2+
3+
const BoxCommand = require('../../../box-command');
4+
const { Flags } = require('@oclif/core');
5+
const PaginationUtils = require('../../../pagination-utils');
6+
7+
class IntegrationMappingsTeamsListCommand extends BoxCommand {
8+
async run() {
9+
const { flags } = await this.parse(IntegrationMappingsTeamsListCommand);
10+
let options = {};
11+
12+
if (flags['partner-item-id']) {
13+
options.partnerItemId = flags['partner-item-id'];
14+
}
15+
if (flags['partner-item-type']) {
16+
options.partnerItemType = flags['partner-item-type'];
17+
}
18+
if (flags['box-item-id']) {
19+
options.boxItemId = flags['box-item-id'];
20+
}
21+
if (flags['box-item-type']) {
22+
options.boxItemType = flags['box-item-type'];
23+
}
24+
25+
let teamsIntegrationMappings = await this.tsClient.integrationMappings.getTeamsIntegrationMapping(options);
26+
delete teamsIntegrationMappings.rawData;
27+
await this.output(teamsIntegrationMappings);
28+
}
29+
}
30+
31+
IntegrationMappingsTeamsListCommand.aliases = [ 'integration-mappings:teams:list' ];
32+
33+
IntegrationMappingsTeamsListCommand.description = 'List Teams integration mappings';
34+
IntegrationMappingsTeamsListCommand.examples = [
35+
'box integration-mappings:teams --partner-item-id 123 --partner-item-type channel',
36+
'box integration-mappings:teams --box-item-id 456 --box-item-type folder'
37+
];
38+
IntegrationMappingsTeamsListCommand._endpoint = 'get_integration_mappings_teams';
39+
40+
IntegrationMappingsTeamsListCommand.flags = {
41+
...BoxCommand.flags,
42+
...PaginationUtils.flags,
43+
'partner-item-id': Flags.string({
44+
hidden: false,
45+
description: 'ID of the mapped item, for which the mapping should be returned',
46+
}),
47+
'partner-item-type': Flags.string({
48+
hidden: false,
49+
description: 'Mapped item type, for which the mapping should be returned, value is one of: channel, team',
50+
}),
51+
'box-item-id': Flags.string({
52+
hidden: false,
53+
description: 'Box item ID, for which the mappings should be returned',
54+
}),
55+
'box-item-type': Flags.string({
56+
hidden: false,
57+
description: 'Box item type, for which the mappings should be returned, value is one of: folder',
58+
})
59+
};
60+
61+
module.exports = IntegrationMappingsTeamsListCommand;
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
'use strict';
2+
3+
const BoxCommand = require('../../../box-command');
4+
const { Flags, Args } = require('@oclif/core');
5+
6+
class IntegrationMappingsTeamsUpdateCommand extends BoxCommand {
7+
async run() {
8+
const { flags, args } = await this.parse(IntegrationMappingsTeamsUpdateCommand);
9+
let body = {};
10+
11+
if (flags['box-item-id']) {
12+
body.boxItem = {
13+
id: flags['box-item-id'],
14+
type: 'folder'
15+
};
16+
}
17+
18+
let integrationMapping = await this.tsClient.integrationMappings.updateTeamsIntegrationMappingById(args.id, {
19+
requestBody: body
20+
});
21+
delete integrationMapping.rawData;
22+
await this.output(integrationMapping);
23+
}
24+
}
25+
26+
IntegrationMappingsTeamsUpdateCommand.description = 'Update Teams integration mapping';
27+
IntegrationMappingsTeamsUpdateCommand.examples = ['box integration-mappings:teams:update 123 --box-item-id 789'];
28+
IntegrationMappingsTeamsUpdateCommand._endpoint = 'put_integration_mappings_teams_id';
29+
30+
IntegrationMappingsTeamsUpdateCommand.flags = {
31+
...BoxCommand.flags,
32+
'box-item-id': Flags.string({
33+
description: 'ID of the mapped folder',
34+
}),
35+
};
36+
37+
IntegrationMappingsTeamsUpdateCommand.args = {
38+
id: Args.string({
39+
name: 'id',
40+
required: true,
41+
hidden: false,
42+
description: 'ID of an integration mapping',
43+
}),
44+
};
45+
46+
module.exports = IntegrationMappingsTeamsUpdateCommand;

0 commit comments

Comments
 (0)