NAME

WebService::Mattermost::V4::API::Resource::Users - Wrapped API methods for the users API endpoints.

VERSION

version 0.29

DESCRIPTION

USAGE

use WebService::Mattermost;

my $mm = WebService::Mattermost->new({
    authenticate => 1,
    username     => 'me@somewhere.com',
    password     => 'hunter2',
    base_url     => 'https://my.mattermost.server.com/api/v4/',
});

my $resource = $mm->api->users;

METHODS

login()

Authentication

Log into the Mattermost server using a username and password.

my $response = $resource->login({
    username => 'USERNAME-HERE',
    password => 'PASSWORD-HERE',
});
create()

Create a user

Create a new user on the server.

my $response = $resource->create({
    # Required parameters:
    email    => '...',
    username => '...',
    password => '...',

    # Optional parameters:
    first_name   => '...',
    last_name    => '...',
    nickname     => '...',
    locale       => '...',
    props        => {
        # ...
    },
    notify_props => {
        # ...
    },
});
list()

Get users

my $response = $resource->list({
    # Optional parameters:
    page           => 0,
    per_page       => 60,
    in_team        => 'TEAM-ID-HERE',
    not_in_team    => 'TEAM-ID-HERE',
    in_channel     => 'CHANNEL-ID-HERE',
    not_in_channel => 'CHANNEL-ID-HERE',
    without_team   => \1,
    sort           => 'STRING',
});
list_by_ids()

Get users by IDs

Takes an ArrayRef of IDs as its only argument.

my $users = $resource->list_by_ids([ qw(
    USER-ID-1
    USER-ID-2
    USER-ID-3
) ]);
list_by_usernames()

Get by usernames

Takes an ArrayRef of usernames.

my $users = $resource->list_by_usernames([ qw(
    USERNAME-1
    USERNAME-2
    USERNAME-3
) ]);
search()

Search users

my $response = $resource->search({
    # Required parameters:
    term => 'SEARCH-TERM-HERE',

    # Optional parameters:
    team_id           => 'TEAM-ID-HERE',
    not_in_team_id    => 'TEAM-ID-HERE',
    in_channel_id     => 'CHANNEL-ID-HERE',
    not_in_channel_id => 'CHANNEL-ID-HERE',
    allow_inactive    => \1, # or \0 - true/false
    without_team      => \1,
    sort              => 'STRING',
});
autocomplete()

Autocomplete users

my $response = $resource->autocomplete({
    # Required parameters:
    name => 'USERNAME-HERE',

    # Optional parameters:
    team_id    => 'TEAM-ID-HERE',
    channel_id => 'CHANNEL-ID-HERE',
});
get_by_username()

Get a user by username

Get a user by their username (exact match only).

my $response = $resource->get_by_username('mike');
reset_password_by_id()

Reset password

Reset a user's password. Requires a recovery code.

my $response = $resource->reset_password({
    new_password => 'hunter2',
    code         => 1234
});
check_mfa_by_username()

Check MFA

Check whether a user requires multi-factor auth by username or email.

my $response = $resource->check_mfa_by_username('USERNAME-HERE');
send_password_reset_email()

Send password reset email

Send a password reset email.

my $response = $resource->send_password_reset_email('me@somewhere.com');
get_by_email()

Get a user by email

Get a user by email address.

my $response = $resource->get_by_email('me@somewhere.com');

AUTHOR

Mike Jones <mike@netsplit.org.uk>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2020 by Mike Jones.

This is free software, licensed under:

The MIT (X11) License