mattermost-redux
Version:
Common code (API client, Redux stores, logic, utility functions) for building a Mattermost client
82 lines (81 loc) • 2.45 kB
JavaScript
;
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.createBot = createBot;
exports.patchBot = patchBot;
exports.loadBot = loadBot;
exports.loadBots = loadBots;
exports.disableBot = disableBot;
exports.enableBot = enableBot;
exports.assignBot = assignBot;
const action_types_1 = require("mattermost-redux/action_types");
const client_1 = require("mattermost-redux/client");
const helpers_1 = require("./helpers");
const BOTS_PER_PAGE_DEFAULT = 20;
function createBot(bot) {
return (0, helpers_1.bindClientFunc)({
clientFunc: client_1.Client4.createBot,
onSuccess: action_types_1.BotTypes.RECEIVED_BOT_ACCOUNT,
params: [
bot,
],
});
}
function patchBot(botUserId, botPatch) {
return (0, helpers_1.bindClientFunc)({
clientFunc: client_1.Client4.patchBot,
onSuccess: action_types_1.BotTypes.RECEIVED_BOT_ACCOUNT,
params: [
botUserId,
botPatch,
],
});
}
function loadBot(botUserId) {
return (0, helpers_1.bindClientFunc)({
clientFunc: client_1.Client4.getBot,
onSuccess: action_types_1.BotTypes.RECEIVED_BOT_ACCOUNT,
params: [
botUserId,
],
});
}
function loadBots(page = 0, perPage = BOTS_PER_PAGE_DEFAULT) {
return (0, helpers_1.bindClientFunc)({
clientFunc: client_1.Client4.getBotsIncludeDeleted,
onSuccess: action_types_1.BotTypes.RECEIVED_BOT_ACCOUNTS,
params: [
page,
perPage,
],
});
}
function disableBot(botUserId) {
return (0, helpers_1.bindClientFunc)({
clientFunc: client_1.Client4.disableBot,
onSuccess: action_types_1.BotTypes.RECEIVED_BOT_ACCOUNT,
params: [
botUserId,
],
});
}
function enableBot(botUserId) {
return (0, helpers_1.bindClientFunc)({
clientFunc: client_1.Client4.enableBot,
onSuccess: action_types_1.BotTypes.RECEIVED_BOT_ACCOUNT,
params: [
botUserId,
],
});
}
function assignBot(botUserId, newOwnerId) {
return (0, helpers_1.bindClientFunc)({
clientFunc: client_1.Client4.assignBot,
onSuccess: action_types_1.BotTypes.RECEIVED_BOT_ACCOUNT,
params: [
botUserId,
newOwnerId,
],
});
}