0.31.0 (latest) 0.30.0 0.29.0 0.28.0 0.27.0 0.23.0 0.20.0 0.19.0 0.18.0 0.17.1 0.16.1 0.15.0 0.14.0 0.13.1 0.12.1 0.11.2 0.10.0 0.9.0 0.8.1 0.7.2 0.6.1 0.5.0 0.4.0 0.3.0 0.2.0 0.1.4 Reference documentation and code samples for the Google Apps Chat V1 Client class User.

If your Chat app [authenticates as a
user](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user),
the output for a `User` resource (such as in the Messages and Memberships
APIs) only populates the `name` and `type` fields for both internal and
external users, unless they are members of the space or have prior affinity
with the calling user.

Generated from protobuf message `google.chat.v1.User`

## Namespace

Google \\ Apps \\ Chat \\ V1

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ name` | `string` Resource name for a Google Chat [user](https://docs.cloud.google.com/php/docs/reference/apps-chat/latest/Chat.V1.User.md.txt). Format: `users/{user}`. `users/app` can be used as an alias for the calling app [bot](https://docs.cloud.google.com/php/docs/reference/apps-chat/latest/Chat.V1.User.Type.md.txt#_Google_Apps_Chat_V1_User_Type__BOT) user. For [human users](https://docs.cloud.google.com/php/docs/reference/apps-chat/latest/Chat.V1.User.Type.md.txt#_Google_Apps_Chat_V1_User_Type__HUMAN), `{user}` is the same user identifier as: - the `id` for the [Person](https://developers.google.com/people/api/rest/v1/people) in the People API. For example, `users/123456789` in Chat API represents the same person as the `123456789` Person profile ID in People API. - the `id` for a [user](https://developers.google.com/admin-sdk/directory/reference/rest/v1/users) in the Admin SDK Directory API. - the user's email address can be used as an alias for `{user}` in API requests. For example, if the People API Person profile ID for `user\@example.com` is `123456789`, you can use `users/user\@example.com` as an alias to reference `users/123456789`. Only the canonical resource name (for example `users/123456789`) will be returned from the API. |
| `↳ display_name` | `string` Output only. The user's display name. Populated for both app authentication and user authentication. This field is always populated for requests made with [app authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app). When calling the Messages and Memberships APIs with [user authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user), this field is populated for both internal and external users for the `sender` of a message, users within `annotations` (such as user mentions), and within `Membership` resources, provided the user is a member of the space or has prior affinity with the calling user. |
| `↳ avatar_url` | `string` Output only. The user's avatar image URL. When calling the Messages and Memberships APIs with [user authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user), this field is populated for both internal and external users for the `sender` of a message, users within `annotations` (such as user mentions), and within `Membership` resources, provided the user is a member of the space or has prior affinity with the calling user. |
| `↳ email` | `string` Output only. The user's email address. When calling the Messages and Memberships APIs with [user authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user), this field is populated for both internal and external users for the `sender` of a message, users within `annotations` (such as user mentions), and within `Membership` resources, provided the user is a member of the space or has prior affinity with the calling user. |
| `↳ domain_id` | `string` Unique identifier of the user's Google Workspace domain. |
| `↳ type` | `int` User type. |
| `↳ is_anonymous` | `bool` Output only. When `true`, the user is deleted or their profile is not visible, such as when a user is mentioned in a space without being a member and without prior affinity with the calling user. |

### getName

Resource name for a Google Chat [user](https://docs.cloud.google.com/php/docs/reference/apps-chat/latest/Chat.V1.User.md.txt).

Format: `users/{user}`. `users/app` can be used as an alias for the calling
app [bot](https://docs.cloud.google.com/php/docs/reference/apps-chat/latest/Chat.V1.User.Type.md.txt#_Google_Apps_Chat_V1_User_Type__BOT) user.
For [human users](https://docs.cloud.google.com/php/docs/reference/apps-chat/latest/Chat.V1.User.Type.md.txt#_Google_Apps_Chat_V1_User_Type__HUMAN), `{user}` is the same
user identifier as:

- the `id` for the [Person](https://developers.google.com/people/api/rest/v1/people) in the People API. For example, `users/123456789` in Chat API represents the same person as the `123456789` Person profile ID in People API.
- the `id` for a [user](https://developers.google.com/admin-sdk/directory/reference/rest/v1/users) in the Admin SDK Directory API.
- the user's email address can be used as an alias for `{user}` in API requests. For example, if the People API Person profile ID for `user\@example.com` is `123456789`, you can use `users/user\@example.com` as an alias to reference `users/123456789`. Only the canonical resource name (for example `users/123456789`) will be returned from the API.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setName

Resource name for a Google Chat [user](https://docs.cloud.google.com/php/docs/reference/apps-chat/latest/Chat.V1.User.md.txt).

Format: `users/{user}`. `users/app` can be used as an alias for the calling
app [bot](https://docs.cloud.google.com/php/docs/reference/apps-chat/latest/Chat.V1.User.Type.md.txt#_Google_Apps_Chat_V1_User_Type__BOT) user.
For [human users](https://docs.cloud.google.com/php/docs/reference/apps-chat/latest/Chat.V1.User.Type.md.txt#_Google_Apps_Chat_V1_User_Type__HUMAN), `{user}` is the same
user identifier as:

- the `id` for the [Person](https://developers.google.com/people/api/rest/v1/people) in the People API. For example, `users/123456789` in Chat API represents the same person as the `123456789` Person profile ID in People API.
- the `id` for a [user](https://developers.google.com/admin-sdk/directory/reference/rest/v1/users) in the Admin SDK Directory API.
- the user's email address can be used as an alias for `{user}` in API requests. For example, if the People API Person profile ID for `user\@example.com` is `123456789`, you can use `users/user\@example.com` as an alias to reference `users/123456789`. Only the canonical resource name (for example `users/123456789`) will be returned from the API.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getDisplayName

Output only. The user's display name.

Populated for both app authentication and user authentication.
This field is always populated for requests made with [app
authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app).
When calling the Messages and Memberships APIs with [user
authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user),
this field is populated for both internal and external users for the
`sender` of a message, users within `annotations` (such as user
mentions), and within `Membership` resources, provided the user is a
member of the space or has prior affinity with the calling user.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setDisplayName

Output only. The user's display name.

Populated for both app authentication and user authentication.
This field is always populated for requests made with [app
authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app).
When calling the Messages and Memberships APIs with [user
authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user),
this field is populated for both internal and external users for the
`sender` of a message, users within `annotations` (such as user
mentions), and within `Membership` resources, provided the user is a
member of the space or has prior affinity with the calling user.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getAvatarUrl

Output only. The user's avatar image URL.

When calling the Messages and Memberships APIs with [user
authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user),
this field is populated for both internal and external users for the
`sender` of a message, users within `annotations` (such as user
mentions), and within `Membership` resources, provided the user is a
member of the space or has prior affinity with the calling user.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setAvatarUrl

Output only. The user's avatar image URL.

When calling the Messages and Memberships APIs with [user
authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user),
this field is populated for both internal and external users for the
`sender` of a message, users within `annotations` (such as user
mentions), and within `Membership` resources, provided the user is a
member of the space or has prior affinity with the calling user.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getEmail

Output only. The user's email address.

When calling the Messages and Memberships APIs with [user
authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user),
this field is populated for both internal and external users for the
`sender` of a message, users within `annotations` (such as user
mentions), and within `Membership` resources, provided the user is a
member of the space or has prior affinity with the calling user.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setEmail

Output only. The user's email address.

When calling the Messages and Memberships APIs with [user
authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user),
this field is populated for both internal and external users for the
`sender` of a message, users within `annotations` (such as user
mentions), and within `Membership` resources, provided the user is a
member of the space or has prior affinity with the calling user.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getDomainId

Unique identifier of the user's Google Workspace domain.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setDomainId

Unique identifier of the user's Google Workspace domain.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getType

User type.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` | Enum of type [Type](https://docs.cloud.google.com/php/docs/reference/apps-chat/latest/Chat.V1.User.Type.md.txt). |

### setType

User type.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int` Enum of type [Type](https://docs.cloud.google.com/php/docs/reference/apps-chat/latest/Chat.V1.User.Type.md.txt). |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getIsAnonymous

Output only. When `true`, the user is deleted or their profile is not
visible, such as when a user is mentioned in a space without being a member
and without prior affinity with the calling user.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `bool` |   |

### setIsAnonymous

Output only. When `true`, the user is deleted or their profile is not
visible, such as when a user is mentioned in a space without being a member
and without prior affinity with the calling user.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `bool` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |