getUsers method
Future<Response<BuiltList<User> > >
getUsers({
- int? page = 0,
- int? perPage = 60,
- String? inTeam,
- String? notInTeam,
- String? inChannel,
- String? notInChannel,
- String? inGroup,
- bool? groupConstrained,
- bool? withoutTeam,
- bool? active,
- bool? inactive,
- String? role,
- String? sort,
- String? roles,
- String? channelRoles,
- String? teamRoles,
- CancelToken? cancelToken,
- Map<
String, dynamic> ? headers, - Map<
String, dynamic> ? extra, - ValidateStatus? validateStatus,
- ProgressCallback? onSendProgress,
- ProgressCallback? onReceiveProgress,
Get users Get a page of a list of users. Based on query string parameters, select users from a team, channel, or select users not in a specific channel. Since server version 4.0, some basic sorting is available using the `sort` query parameter. Sorting is currently only supported when selecting users on a team. ##### Permissions Requires an active session and (if specified) membership to the channel or team being selected from.
Parameters:
page
- The page to select.perPage
- The number of users per page. There is a maximum limit of 200 users per page.inTeam
- The ID of the team to get users for.notInTeam
- The ID of the team to exclude users for. Must not be used with "in_team" query parameter.inChannel
- The ID of the channel to get users for.notInChannel
- The ID of the channel to exclude users for. Must be used with "in_channel" query parameter.inGroup
- The ID of the group to get users for. Must havemanage_system
permission.groupConstrained
- When used withnot_in_channel
ornot_in_team
, returns only the users that are allowed to join the channel or team based on its group constrains.withoutTeam
- Whether or not to list users that are not on any team. This option takes precendence overin_team
,in_channel
, andnot_in_channel
.active
- Whether or not to list only users that are active. This option cannot be used along with theinactive
option.inactive
- Whether or not to list only users that are deactivated. This option cannot be used along with theactive
option.role
- Returns users that have this role.sort
- Sort is only available in conjunction with certain options below. The paging parameter is also always available. #####in_team
Can be "", "last_activity_at" or "create_at". When left blank, sorting is done by username. Minimum server version: 4.0 #####in_channel
Can be "", "status". When left blank, sorting is done by username.status
will sort by User's current status (Online, Away, DND, Offline), then by Username. Minimum server version: 4.7roles
- Comma separated string used to filter users based on any of the specified system roles Example:?roles=system_admin,system_user
will return users that are either system admins or system users Minimum server version: 5.26channelRoles
- Comma separated string used to filter users based on any of the specified channel roles, can only be used in conjunction within_channel
Example:?in_channel=4eb6axxw7fg3je5iyasnfudc5y&channel_roles=channel_user
will return users that are only channel users and not admins or guests Minimum server version: 5.26teamRoles
- Comma separated string used to filter users based on any of the specified team roles, can only be used in conjunction within_team
Example:?in_team=4eb6axxw7fg3je5iyasnfudc5y&team_roles=team_user
will return users that are only team users and not admins or guests Minimum server version: 5.26cancelToken
- ACancelToken
that can be used to cancel the operationheaders
- Can be used to add additional headers to the requestextras
- Can be used to add flags to the requestvalidateStatus
- AValidateStatus
callback that can be used to determine request success based on the HTTP status of the responseonSendProgress
- AProgressCallback
that can be used to get the send progressonReceiveProgress
- AProgressCallback
that can be used to get the receive progress
Returns a Future containing a Response
with a BuiltList<User>
as data
Throws DioError
if API call or serialization fails
Implementation
Future<Response<BuiltList<User>>> getUsers({
int? page = 0,
int? perPage = 60,
String? inTeam,
String? notInTeam,
String? inChannel,
String? notInChannel,
String? inGroup,
bool? groupConstrained,
bool? withoutTeam,
bool? active,
bool? inactive,
String? role,
String? sort,
String? roles,
String? channelRoles,
String? teamRoles,
CancelToken? cancelToken,
Map<String, dynamic>? headers,
Map<String, dynamic>? extra,
ValidateStatus? validateStatus,
ProgressCallback? onSendProgress,
ProgressCallback? onReceiveProgress,
}) async {
final _path = r'/users';
final _options = Options(
method: r'GET',
headers: <String, dynamic>{
...?headers,
},
extra: <String, dynamic>{
'secure': <Map<String, String>>[
{
'type': 'http',
'scheme': 'bearer',
'name': 'bearerAuth',
},
],
...?extra,
},
validateStatus: validateStatus,
);
final _queryParameters = <String, dynamic>{
if (page != null) r'page': encodeQueryParameter(_serializers, page, const FullType(int)),
if (perPage != null) r'per_page': encodeQueryParameter(_serializers, perPage, const FullType(int)),
if (inTeam != null) r'in_team': encodeQueryParameter(_serializers, inTeam, const FullType(String)),
if (notInTeam != null) r'not_in_team': encodeQueryParameter(_serializers, notInTeam, const FullType(String)),
if (inChannel != null) r'in_channel': encodeQueryParameter(_serializers, inChannel, const FullType(String)),
if (notInChannel != null) r'not_in_channel': encodeQueryParameter(_serializers, notInChannel, const FullType(String)),
if (inGroup != null) r'in_group': encodeQueryParameter(_serializers, inGroup, const FullType(String)),
if (groupConstrained != null) r'group_constrained': encodeQueryParameter(_serializers, groupConstrained, const FullType(bool)),
if (withoutTeam != null) r'without_team': encodeQueryParameter(_serializers, withoutTeam, const FullType(bool)),
if (active != null) r'active': encodeQueryParameter(_serializers, active, const FullType(bool)),
if (inactive != null) r'inactive': encodeQueryParameter(_serializers, inactive, const FullType(bool)),
if (role != null) r'role': encodeQueryParameter(_serializers, role, const FullType(String)),
if (sort != null) r'sort': encodeQueryParameter(_serializers, sort, const FullType(String)),
if (roles != null) r'roles': encodeQueryParameter(_serializers, roles, const FullType(String)),
if (channelRoles != null) r'channel_roles': encodeQueryParameter(_serializers, channelRoles, const FullType(String)),
if (teamRoles != null) r'team_roles': encodeQueryParameter(_serializers, teamRoles, const FullType(String)),
};
final _response = await _dio.request<Object>(
_path,
options: _options,
queryParameters: _queryParameters,
cancelToken: cancelToken,
onSendProgress: onSendProgress,
onReceiveProgress: onReceiveProgress,
);
BuiltList<User> _responseData;
try {
const _responseType = FullType(BuiltList, [FullType(User)]);
_responseData = _serializers.deserialize(
_response.data!,
specifiedType: _responseType,
) as BuiltList<User>;
} catch (error, stackTrace) {
throw DioError(
requestOptions: _response.requestOptions,
response: _response,
type: DioErrorType.other,
error: error,
)..stackTrace = stackTrace;
}
return Response<BuiltList<User>>(
data: _responseData,
headers: _response.headers,
isRedirect: _response.isRedirect,
requestOptions: _response.requestOptions,
redirects: _response.redirects,
statusCode: _response.statusCode,
statusMessage: _response.statusMessage,
extra: _response.extra,
);
}