Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions src/commands/integration-mappings/teams/create.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
'use strict';

const BoxCommand = require('../../../box-command');
const { Args } = require('@oclif/core');

class IntegrationMappingsTeamsCreateCommand extends BoxCommand {
async run() {
const { args } = await this.parse(IntegrationMappingsTeamsCreateCommand);
let body = {};
body.boxItem = {
type: 'folder',
id: args.boxItemID
};
body.partnerItem = {
type: args.partnerItemType,
id: args.partnerItemID,
teamId: args.partnerItemTeamID,
tenantId: args.partnerItemTenantID
};

let integrationMapping = await this.tsClient.integrationMappings.createTeamsIntegrationMapping(body);
delete integrationMapping.rawData;
await this.output(integrationMapping);
}
}

IntegrationMappingsTeamsCreateCommand.description = 'Create Teams integration mapping';
IntegrationMappingsTeamsCreateCommand.examples = [
'box integration-mappings:teams:create 123 19%ABCD-Avgfggkggyftdtfgghjhkhkhh%40thread:tacv2 hjgjgjg-bhhj-564a-b643-hghgj685u abcd-defg-1235-7890',
];
IntegrationMappingsTeamsCreateCommand._endpoint = 'post_integration_mappings_teams';

IntegrationMappingsTeamsCreateCommand.args = {
boxItemID: Args.string({
name: 'boxItemID',
required: true,
hidden: false,
description: 'ID of the mapped folder'
}),
partnerItemID: Args.string({
name: 'partnerItemID',
required: true,
hidden: false,
description: 'ID of the mapped item'
}),
partnerItemType: Args.string({
name: 'partnerItemType',
required: true,
hidden: false,
description: 'Type of the mapped item, value is one of: channel, team'
}),
partnerItemTeamID: Args.string({
name: 'partnerItemTeamID',
required: true,
hidden: false,
description: 'ID of the team that is registered with Microsoft Teams'
}),
partnerItemTenantID: Args.string({
name: 'partnerItemTenantID',
required: true,
hidden: false,
description: 'ID of the tenant that is registered with Microsoft Teams'
})
};

module.exports = IntegrationMappingsTeamsCreateCommand;
32 changes: 32 additions & 0 deletions src/commands/integration-mappings/teams/delete.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
'use strict';

const { Args } = require('@oclif/core');
const BoxCommand = require('../../../box-command');

class IntegrationMappingsTeamsDeleteCommand extends BoxCommand {
async run() {
const { args } = await this.parse(IntegrationMappingsTeamsDeleteCommand);

await this.tsClient.integrationMappings.deleteTeamsIntegrationMappingById(args.id);
this.info(`Deleted Teams integration mapping ${args.id}`);
}
}

IntegrationMappingsTeamsDeleteCommand.description = 'Delete Teams integration mapping';
IntegrationMappingsTeamsDeleteCommand.examples = ['box integration-mappings:teams:delete 123'];
IntegrationMappingsTeamsDeleteCommand._endpoint = 'delete_integration_mappings_teams_id';

IntegrationMappingsTeamsDeleteCommand.flags = {
...BoxCommand.flags
};

IntegrationMappingsTeamsDeleteCommand.args = {
id: Args.string({
name: 'id',
required: true,
hidden: false,
description: 'ID of the integration mapping',
}),
};

module.exports = IntegrationMappingsTeamsDeleteCommand;
61 changes: 61 additions & 0 deletions src/commands/integration-mappings/teams/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
'use strict';

const BoxCommand = require('../../../box-command');
const { Flags } = require('@oclif/core');
const PaginationUtils = require('../../../pagination-utils');

class IntegrationMappingsTeamsListCommand extends BoxCommand {
async run() {
const { flags } = await this.parse(IntegrationMappingsTeamsListCommand);
let options = {};

if (flags['partner-item-id']) {
options.partnerItemId = flags['partner-item-id'];
}
if (flags['partner-item-type']) {
options.partnerItemType = flags['partner-item-type'];
}
if (flags['box-item-id']) {
options.boxItemId = flags['box-item-id'];
}
if (flags['box-item-type']) {
options.boxItemType = flags['box-item-type'];
}

let teamsIntegrationMappings = await this.tsClient.integrationMappings.getTeamsIntegrationMapping(options);
delete teamsIntegrationMappings.rawData;
await this.output(teamsIntegrationMappings);
}
}

IntegrationMappingsTeamsListCommand.aliases = [ 'integration-mappings:teams:list' ];

IntegrationMappingsTeamsListCommand.description = 'List Teams integration mappings';
IntegrationMappingsTeamsListCommand.examples = [
'box integration-mappings:teams --partner-item-id 123 --partner-item-type channel',
'box integration-mappings:teams --box-item-id 456 --box-item-type folder'
];
IntegrationMappingsTeamsListCommand._endpoint = 'get_integration_mappings_teams';

IntegrationMappingsTeamsListCommand.flags = {
...BoxCommand.flags,
...PaginationUtils.flags,
'partner-item-id': Flags.string({
hidden: false,
description: 'ID of the mapped item, for which the mapping should be returned',
}),
'partner-item-type': Flags.string({
hidden: false,
description: 'Mapped item type, for which the mapping should be returned, value is one of: channel, team',
}),
'box-item-id': Flags.string({
hidden: false,
description: 'Box item ID, for which the mappings should be returned',
}),
'box-item-type': Flags.string({
hidden: false,
description: 'Box item type, for which the mappings should be returned, value is one of: folder',
})
};

module.exports = IntegrationMappingsTeamsListCommand;
46 changes: 46 additions & 0 deletions src/commands/integration-mappings/teams/update.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
'use strict';

const BoxCommand = require('../../../box-command');
const { Flags, Args } = require('@oclif/core');

class IntegrationMappingsTeamsUpdateCommand extends BoxCommand {
async run() {
const { flags, args } = await this.parse(IntegrationMappingsTeamsUpdateCommand);
let body = {};

if (flags['box-item-id']) {
body.boxItem = {
id: flags['box-item-id'],
type: 'folder'
};
}

let integrationMapping = await this.tsClient.integrationMappings.updateTeamsIntegrationMappingById(args.id, {
requestBody: body
});
delete integrationMapping.rawData;
await this.output(integrationMapping);
}
}

IntegrationMappingsTeamsUpdateCommand.description = 'Update Teams integration mapping';
IntegrationMappingsTeamsUpdateCommand.examples = ['box integration-mappings:teams:update 123 --box-item-id 789'];
IntegrationMappingsTeamsUpdateCommand._endpoint = 'put_integration_mappings_teams_id';

IntegrationMappingsTeamsUpdateCommand.flags = {
...BoxCommand.flags,
'box-item-id': Flags.string({
description: 'ID of the mapped folder',
}),
};

IntegrationMappingsTeamsUpdateCommand.args = {
id: Args.string({
name: 'id',
required: true,
hidden: false,
description: 'ID of an integration mapping',
}),
};

module.exports = IntegrationMappingsTeamsUpdateCommand;
Loading