Data Models¶
-
class
pyryver.objects.
Object
(ryver: pyryver.ryver.Ryver, obj_type: str, data: dict)¶ Base class for all Ryver objects.
Parameters: - ryver – The parent
pyryver.pyryver.Ryver
instance. - obj_type – The object’s type, a constant beginning with
TYPE_
in pyryver.util.
-
get_entity_type
() → str¶ Get the entity type of this object.
-
get_id
() → Any¶ Get the ID of this object.
This is usually an integer, however for messages it is a string instead.
-
get_raw_data
() → dict¶ Get the raw data of this object.
The raw data is a dictionary directly obtained from parsing the JSON response.
-
get_ryver
() → pyryver.ryver.Ryver¶ Get the Ryver session this object was retrieved from.
-
get_type
() → str¶ Get the type of this object.
- ryver – The parent
Chats¶
-
class
pyryver.objects.
Chat
(ryver: pyryver.ryver.Ryver, obj_type: str, data: dict)¶ Bases:
pyryver.objects.Object
Any Ryver chat you can send messages to.
E.g. Teams, forums, user DMs, etc.
-
await
create_topic
(subject: str, body: str, creator: pyryver.objects.Creator = None) → pyryver.objects.Topic¶ Create a topic in this chat.
This method sends requests.
Returns the topic created.
Parameters: - subject – The subject (or title) of the new topic.
- body – The contents of the new topic.
- creator – The overriden creator; optional, if unset uses the logged-in user’s profile.
-
get_jid
() → str¶ Get the JID (JabberID) of this chat.
The JID is used in the websockets interface.
-
await
get_message_from_id
(id: str, before: int = 0, after: int = 0) → List[pyryver.objects.Message]¶ Get a message from an ID, optionally also messages before and after it too.
Warning
Before and after cannot exceed 25 messages, otherwise an HTTPError will be raised with the error code 400 Bad Request.
This method sends requests.
This method does not support top/skip.
Parameters: - id – The ID of the message to retrieve, and the reference point for the
before
andafter
parameters. - before – How many extra messages to retrieve before the specified one.
- after – How many extra messages to retrieve after the specified one.
- id – The ID of the message to retrieve, and the reference point for the
-
await
get_messages
(count: int) → List[pyryver.objects.ChatMessage]¶ Get a number of messages (most recent first) in this chat.
This method sends requests.
Parameters: count – Maximum number of results.
-
abstractmethod
get_name
() → str¶ Get the name of this chat.
-
async for ... in
get_topics
(archived: bool = False, top: int = -1, skip: int = 0) → AsyncIterator[pyryver.objects.Topic]¶ Get all the topics in this chat.
This method sends requests.
Parameters: - archived – If True, only include archived topics in the results, otherwise, only include non-archived topics.
- top – Maximum number of results; optional, if unspecified return all results.
- skip – Skip this many results.
-
await
send_message
(message: str, creator: pyryver.objects.Creator = None) → str¶ Send a message to this chat.
Specify a creator to override the username and profile of the message creator.
This method sends requests.
Returns the ID of the chat message sent. Note that message IDs are strings.
Parameters: - message – The message contents.
- creator – The overriden creator; optional, if unset uses the logged-in user’s profile.
-
await
-
class
pyryver.objects.
GroupChat
(ryver: pyryver.ryver.Ryver, obj_type: str, data: dict)¶ Bases:
pyryver.objects.Chat
A Ryver team or forum.
-
await
get_member
(id: int) → pyryver.objects.GroupChatMember¶ Get a member by user ID.
This method sends requests.
If the user is not found, this method will return None.
-
async for ... in
get_members
(top: int = -1, skip: int = 0) → AsyncIterator[pyryver.objects.GroupChatMember]¶ Get all the members of this chat.
This method sends requests.
Parameters: - top – Maximum number of results; optional, if unspecified return all results.
- skip – Skip this many results.
-
get_name
() → str¶ Get the name of this chat.
-
get_nickname
() → str¶ Get the nickname of this chat.
-
await
-
class
pyryver.objects.
Forum
(ryver: pyryver.ryver.Ryver, obj_type: str, data: dict)¶ Bases:
pyryver.objects.GroupChat
A Ryver forum.
-
class
pyryver.objects.
Team
(ryver: pyryver.ryver.Ryver, obj_type: str, data: dict)¶ Bases:
pyryver.objects.GroupChat
A Ryver team.
User¶
-
class
pyryver.objects.
User
(ryver: pyryver.ryver.Ryver, obj_type: str, data: dict)¶ Bases:
pyryver.objects.Chat
A Ryver user.
-
ROLE_ADMIN
= 'ROLE_ADMIN'¶
-
ROLE_GUEST
= 'ROLE_GUEST'¶
-
ROLE_USER
= 'ROLE_USER'¶
-
await
create_topic
(from_user: pyryver.objects.User, subject: str, body: str, creator: pyryver.objects.Creator = None) → pyryver.objects.Topic¶ Create a topic in this user’s DMs.
This method sends requests.
Returns the topic created.
Parameters: - from_user – The user that will create the topic; must be the same as the logged-in user.
- subject – The subject (or title) of the created topic.
- body – The contents of the created topic.
-
get_about
() → str¶ Get this user’s About.
-
get_activated
() → bool¶ Get whether this user’s account is activated.
-
get_display_name
() → str¶ Get the display name of this user.
-
get_email_address
() → str¶ Get this user’s Email Address.
-
get_name
() → str¶ Get the display name of this user.
-
get_role
() → str¶ Get this user’s role in their profile.
Note
This is different from
get_roles()
. While this one gets the “Role” of the user from the profile,get_roles()
gets the user’s roles in the organization (user, guest, admin).
-
get_roles
() → List[str]¶ Get this user’s role in the organization.
Note
This is different from
get_role()
. While this one gets the user’s roles in the organization (user, guest, admin),get_role()
gets the user’s role from their profile.
-
get_time_zone
() → str¶ Get this user’s Time Zone.
-
get_username
() → str¶ Get the username of this user.
-
is_admin
() → bool¶ Get whether this user is an org admin.
-
await
set_activated
(activated: bool) → None¶ Activate or deactivate the user. Requires admin.
This method sends requests.
Note
This also updates these properties in this object.
-
await
set_org_role
(role: str) → None¶ Set a user’s role in this organization, as described in
get_roles()
.This can be either ROLE_USER, ROLE_ADMIN or ROLE_GUEST.
This method sends requests.
Note
This also updates these properties in this object.
-
await
set_profile
(display_name: str = None, role: str = None, about: str = None) → None¶ Update this user’s profile.
If any of the arguments are None, they will not be changed.
This method sends requests.
Note
This also updates these properties in this object.
Parameters: - display_name – The user’s new display_name.
- role – The user’s new role, as described in
get_role()
. - about – The user’s new “about me” blurb.
-
Group Chat Member¶
-
class
pyryver.objects.
GroupChatMember
(ryver: pyryver.ryver.Ryver, obj_type: str, data: dict)¶ Bases:
pyryver.objects.Object
A member in a forum or team.
-
ROLE_ADMIN
= 'ROLE_TEAM_ADMIN'¶
-
ROLE_MEMBER
= 'ROLE_TEAM_MEMBER'¶
-
get_role
() → str¶ Get the role of this member.
-
is_admin
() → bool¶ Get whether this member is an admin of their forum.
Warning
This method does not check for org admins.
-
Messages¶
-
class
pyryver.objects.
Message
(ryver: pyryver.ryver.Ryver, obj_type: str, data: dict)¶ Bases:
pyryver.objects.Object
Any generic Ryver message, with an author, body, and reactions.
-
get_attached_file
() → pyryver.objects.File¶ Get the file attached to this message, if there is one.
Note that files obtained from this only have a limited amount of information, including the ID, name, URL, size and type. Attempting to get any other info will result in a KeyError. To obtain the full file info, use
Ryver.get_object()
withTYPE_FILE
and the ID.Returns None otherwise.
Get the author of this message, as a
User
object.This method sends requests.
Get the ID of the author of this message.
-
abstractmethod
get_body
() → str¶ Get the body of this message.
-
get_creator
() → pyryver.objects.Creator¶ Get the Creator of this message.
Note that this is different from the author. Creators are used to override the display name and avatar of a user. If the username and avatar were not overridden, this will return None.
-
get_reaction_counts
() → dict¶ Count the number of reactions for each emoji on a message.
Returns a dict of {emoji: number_of_reacts}.
-
get_reactions
() → dict¶ Get the reactions on this message.
Returns a dict of {emoji: [users]}.
-
await
react
(emoji: str) → None¶ React to a message with an emoji.
This method sends requests.
Parameters: emoji – The string name of the reacji (e.g. “thumbsup”).
-
-
class
pyryver.objects.
ChatMessage
(ryver: pyryver.ryver.Ryver, obj_type: str, data: dict)¶ Bases:
pyryver.objects.Message
A Ryver chat message.
-
await
delete
() → None¶ Deletes the message.
-
await
edit
(body: str, creator: pyryver.objects.Creator = None) → None¶ Edit the message.
Parameters: - body – The new message content.
- creator – The new message creator; optional, if unset left as-is.
Get the ID of the author of this message.
-
get_body
() → str¶ Get the message body.
-
await
get_chat
() → pyryver.objects.Chat¶ Get the chat that this message was sent to, as a
Chat
object.This method sends requests.
-
get_chat_id
() → int¶ Get the id of the chat that this message was sent to, as an integer.
Note that this is different from
get_chat()
as the id is stored in the message data and is good for most API purposes whileget_chat()
returns an entire Chat object, which might not be necessary depending on what you’re trying to do.
-
get_chat_type
() → str¶ Gets the type of chat that this message was sent to, as a string.
This string will be one of the ENTITY_TYPES values
-
await
react
(emoji: str) → None¶ React to a message with an emoji.
This method sends requests.
Parameters: emoji – The string name of the reacji (e.g. “thumbsup”).
-
await
-
class
pyryver.objects.
Topic
(ryver: pyryver.ryver.Ryver, obj_type: str, data: dict)¶ Bases:
pyryver.objects.Message
A Ryver topic in a chat.
Get the ID of the author of this topic.
-
get_body
() → str¶ Get the body of this topic.
-
async for ... in
get_replies
(top: int = -1, skip: int = 0) → AsyncIterator[pyryver.objects.TopicReply]¶ Get all the replies to this topic.
This method sends requests.
Parameters: - top – Maximum number of results; optional, if unspecified return all results.
- skip – Skip this many results.
-
get_subject
() → str¶ Get the subject of this topic.
-
await
reply
(message: str, creator: pyryver.objects.Creator = None) → pyryver.objects.TopicReply¶ Reply to the topic.
This method sends requests.
For unknown reasons, overriding the creator does not work for this method.
Parameters: message – The reply content
-
class
pyryver.objects.
TopicReply
(ryver: pyryver.ryver.Ryver, obj_type: str, data: dict)¶ Bases:
pyryver.objects.Message
A reply on a topic.
Get the author of this reply, as a
User
object.Unlike the other implementations, this does not send any requests.
Get the ID of the author of this reply.
-
get_body
() → str¶ Get the body of this message.
-
get_topic
() → pyryver.objects.Topic¶ Get the topic this reply was sent to.
Files¶
-
class
pyryver.objects.
Storage
(ryver: pyryver.ryver.Ryver, obj_type: str, data: dict)¶ Bases:
pyryver.objects.Object
Generic storage, e.g. uploaded files.
Note that while storage objects contain files, the File class does not inherit from this class.
-
get_file
() → pyryver.objects.File¶ Get the file stored.
-
-
class
pyryver.objects.
File
(ryver: pyryver.ryver.Ryver, obj_type: str, data: dict)¶ Bases:
pyryver.objects.Object
An uploaded file.
This class also contains constants for some common MIME types.
-
await
delete
() → None¶ Delete this file.
This method sends requests.
-
await
download_data
() → bytes¶ Download the file data.
This method sends requests.
-
get_MIME_type
() → str¶ Get the MIME type of this file.
-
get_name
() → str¶ Get the name of this file.
-
get_size
() → int¶ Get the size of this file in bytes.
-
get_title
() → str¶ Get the title of this file.
-
get_url
() → str¶ Get the URL of this file.
-
request_data
() → aiohttp.client_reqrep.ClientResponse¶ Get the file data.
Returns an aiohttp request response to the file URL.
-
await
Notification¶
-
class
pyryver.objects.
Notification
(ryver: pyryver.ryver.Ryver, obj_type: str, data: dict)¶ Bases:
pyryver.objects.Object
A Ryver user notification.
-
PREDICATE_COMMENT
= 'commented_on'¶
-
PREDICATE_GROUP_MENTION
= 'group_mention'¶
-
PREDICATE_MENTION
= 'chat_mention'¶
-
PREDICATE_TASK_COMPLETED
= 'completed'¶
-
get_new
() → bool¶ Get whether this notification is new.
-
get_object
() → dict¶ Get the “object” of this notification.
The exact nature of this field is not yet known, but it seems to be the target of an @mention for mentions, the topic for topic comments, or the task for task activities.
-
get_object_entity_type
() → str¶ Get entity type of the “object” of this notification.
The exact nature of this field is not yet known, but it seems to be the target of an @mention for mentions, the topic for topic comments, or the task for task activities.
-
get_object_id
() → int¶ Get the ID of the “object” of this notification.
The exact nature of this field is not yet known, but it seems to be the target of an @mention for mentions, the topic for topic comments, or the task for task activities.
-
get_predicate
() → str¶ Get the “predicate”, or type, of this notification.
- E.g.
- chat_mention - User was @mentioned
- group_mention - User was mentioned through @team or @here
- commented_on - A topic was commented on
- completed - A task was completed
-
get_subject_entity_type
() → str¶ Get the entity type of the “subject” of this notification.
The exact nature of this field is not yet known, but it seems to be the user that did the action which caused this notification.
-
get_subject_id
() → int¶ Get the ID of the “subject” of this notification.
The exact nature of this field is not yet known, but it seems to be the user that did the action which caused this notification.
-
get_subjects
() → List[dict]¶ Get the “subjects” of this notification.
The exact nature of this field is not yet known, but it seems to be the user that did the action which caused this notification. It is also unknown why this is an array, as it seems to only ever contain one element.
-
get_unread
() → bool¶ Get whether this notification is unread.
-
get_via
() → dict¶ Get the “via” of this notification.
The exact nature of this field is not yet known, but it seems to contain information about whatever caused this notification. For example, the chat message of an @mention, the topic reply for a reply, etc. For task completions, there is NO via.
-
get_via_entity_type
() → str¶ Get the entity type of the “via” of this notification.
The exact nature of this field is not yet known, but it seems to contain information about whatever caused this notification. For example, the chat message of an @mention, the topic reply for a reply, etc. For task completions, there is NO via.
-
get_via_id
() → int¶ Get the ID of the “via” of this notification.
The exact nature of this field is not yet known, but it seems to contain information about whatever caused this notification. For example, the chat message of an @mention, the topic reply for a reply, etc. For task completions, there is NO via.
-
await
set_status
(unread: bool, new: bool) → None¶ Set the read/unread and seen/unseen (new) status of this notification.
This method sends requests.
Note
This also updates these properties in this object.
-
Creator¶
-
class
pyryver.objects.
Creator
(name: str, avatar: str)¶ A message creator, with a name and an avatar.
This can be used to override the sender’s display name and avatar.
Parameters: - name – The overriden display name
- avatar – The overriden avatar (a url to an image)
-
to_dict
() → dict¶ Convert this Creator object to a dictionary to be used in a request.
Intended for internal use.