findDirectMessage method

Future<Space> findDirectMessage({
  1. String? name,
  2. String? $fields,
})

Returns the existing direct message with the specified user.

If no direct message space is found, returns a 404 NOT_FOUND error. For an example, see [Find a direct message](/chat/api/guides/v1/spaces/find-direct-message). With user authentication, returns the direct message space between the specified user and the authenticated user. With app authentication, returns the direct message space between the specified user and the calling Chat app. Requires user authentication or app authentication.

Request parameters:

name - Required. Resource name of the user to find direct message with. Format: users/{user}, where {user} is either the id for the person from the People API, or the id for the user in the Directory API. For example, if the People API profile ID is 123456789, you can find a direct message with that person by using users/123456789 as the name. When authenticated as a user, you can use the email as an alias for {user}. For example, users/example@gmail.com where example@gmail.com is the email of the Google Chat user.

$fields - Selector specifying which fields to include in a partial response.

Completes with a Space.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<Space> findDirectMessage({
  core.String? name,
  core.String? $fields,
}) async {
  final queryParams_ = <core.String, core.List<core.String>>{
    if (name != null) 'name': [name],
    if ($fields != null) 'fields': [$fields],
  };

  const url_ = 'v1/spaces:findDirectMessage';

  final response_ = await _requester.request(
    url_,
    'GET',
    queryParams: queryParams_,
  );
  return Space.fromJson(response_ as core.Map<core.String, core.dynamic>);
}