teamwire_api.users

User

class User(object)

Class representing a single user of the Teamwire platform

Attributes

  • uid: unicode. The user id
  • first_name: unicode. The first name of the user
  • last_name: unicode. The last name of the user
  • org_name: unicode. The name of the organization the user belongs to (deprecated since v1.0 of the SDK)
  • organisation: Organisation object. The the organization the user belongs to
  • is_bot: boolean. Whether a user is a normal user or a bot (API integration). For normal Teamwire users this property is set to False

full_name

 | full_name()

get the full name of the user in the form 'first last'

has_avatar

 | async has_avatar()

Coroutine to check if the user has an avatar set.

Returns True if the avatar is set, False otherwise

Raises

exceptions.TWImageLoadError if no avatar has been set for the user exceptions.TWConnectionError in case of network error or timeout exceptions.TWServerError in case of backend-related problems

load_avatar

 | async load_avatar()

Coroutine to load the avatar image of the user.

Returns a bytes array representation of the loaded image

Raises

exceptions.TWImageLoadError if no avatar has been set for the user exceptions.TWConnectionError in case of network error or timeout exceptions.TWServerError in case of backend-related problems

get_profile

 | async get_profile()

Coroutine to get the user profile

Returns a Profile object

Raises

exceptions.TWAuthError if the operation is not allowed exceptions.TWConnectionError in case of network error or timeout exceptions.TWServerError in case of backend-related problems

Bot

class Bot(User)

This class represents a bot user in the Teamwire platform. It inherits attributes and methods from the User class, exposing a bot-specific profile. The is_bot attribute for bot users is set to True.

LoggedInUser

class LoggedInUser(Bot)

This class represents the bot's own user in the Teamwire platform. It inherits attributes and methods from the User class, and it additionally exposes methods to set and remove the bot's avatar image

set_avatar

 | async set_avatar(image_path)

coroutine to set the bot's avatar image

Arguments

  • image_path: unicode. The full path to the image to be uploaded as an avatar for the bot

Raises

exceptions.TWAuthError if the bot is not authorized to upload an avatar image exceptions.TWConnectionError in case of network error or timeout exceptions.TWServerError in case of backend-related problems

remove_avatar

 | async remove_avatar()

coroutine to remove the bot's avatar image

Raises

exceptions.TWImageRemoveError if the the avatar could not be removed exceptions.TWAuthError if the bot is not authorized to remove its avatar exceptions.TWConnectionError in case of network error or timeout exceptions.TWServerError in case of backend-related problems

update_profile

 | async update_profile(*args)

coroutine to update the bot's profile

Arguments

variable number of arguments of `FieldUpdate` type

Raises

exceptions.TWAuthError if the operation is not allowed exceptions.TWConnectionError in case of network error or timeout exceptions.TWServerError in case of backend-related problems

Users

class Users(object)

An accessor to the all the users visible to the bot

get_user

 | async get_user(uid)

get a user by its user id

Arguments

  • uid: unicode. The User ID

Returns

a User object

Raises

exceptions.TWNotFoundError if no user exists with the provided User ID exceptions.TWConnectionError in case of network error or timeout exceptions.TWServerError in case of backend-related problems

full_query

 | async full_query(query_string: str, max_results: int = User.MAX_RESULTS) -> list

Lookup user by part of their names. The search for the usernames are done from a list consisting of the remote backend query and the local user store.

Arguments

  • query_string: unicode. Part of a user name (e.g. Jo for querying all users named John)
  • max_results: integer (default 100). Maximum number of results to be returned

Returns

a list of `User` objects matching the query string

query

 | async query(query_string: str, max_results: int = User.MAX_RESULTS) -> list

Query users by their names.

Arguments

  • query_string: unicode. User name as query
  • max_results: integer (default 100). Maximum number of results to be returned

Returns

a list of `User` objects matching the query string

get_list

 | async get_list()

Get list of all users immediately visible to the bot These generally include users in the same organisation of the bot and members of chats involving the bot

Returns

a list of User objects

Raises

exceptions.TWConnectionError in case of network error or timeout exceptions.TWServerError in case of backend-related problems