roboto.domain.orgs.org_invite#
Module Contents#
- class roboto.domain.orgs.org_invite.OrgInvite(record, roboto_client=None)#
An invitation to join an organization from one user to another.
Organization invitations allow existing members to invite new users to join their organization. Invitations are created by calling
Org.invite_user()
and can be accepted or declined by the invited user.Invitations cannot be created directly through the constructor - they must be created through the organization’s invite_user method.
- Parameters:
roboto_client (Optional[roboto.http.RobotoClient])
- accept()#
Accept this invitation and join the organization.
The invited user becomes a member of the organization with default user role permissions.
- Raises:
RobotoUnauthorizedException – The caller is not the invited user.
RobotoInvalidRequestException – The invitation has already been accepted or declined.
- Return type:
None
Examples
Accept an invitation:
>>> from roboto import OrgInvite >>> invite = OrgInvite.from_id("invite_12345") >>> invite.accept() # Join the organization
- classmethod create(invited_user_id, org_id, roboto_client=None)#
Create a new organization invitation.
Creates an invitation for the specified user to join the organization. This method is typically called internally by
Org.invite_user()
.- Parameters:
invited_user_id (str) – Unique identifier for the user to invite.
org_id (str) – Unique identifier for the organization.
roboto_client (Optional[roboto.http.RobotoClient]) – Optional Roboto client instance. If not provided, uses the default client.
- Returns:
A new OrgInvite instance representing the created invitation.
- Raises:
RobotoNotFoundException – The user or organization does not exist.
RobotoInvalidRequestException – The user is already a member or has a pending invite.
RobotoUnauthorizedException – The caller lacks permission to invite users.
- Return type:
Examples
Create an invitation (typically done via Org.invite_user):
>>> from roboto import OrgInvite >>> invite = OrgInvite.create("alice@example.com", "org_12345")
- decline()#
Decline this invitation and do not join the organization.
The invitation is marked as declined and cannot be accepted later.
- Raises:
RobotoUnauthorizedException – The caller is not the invited user.
RobotoInvalidRequestException – The invitation has already been accepted or declined.
- Return type:
None
Examples
Decline an invitation:
>>> from roboto import OrgInvite >>> invite = OrgInvite.from_id("invite_12345") >>> invite.decline() # Do not join the organization
- classmethod for_org(org_id, roboto_client=None)#
Retrieve all pending invitations for an organization.
- Parameters:
org_id (str) – Unique identifier for the organization.
roboto_client (Optional[roboto.http.RobotoClient]) – Optional Roboto client instance. If not provided, uses the default client.
- Returns:
Collection of OrgInvite instances for pending invitations.
- Raises:
RobotoNotFoundException – The organization does not exist.
RobotoUnauthorizedException – The caller lacks permission to view invitations.
- Return type:
collections.abc.Collection[OrgInvite]
Examples
List all invitations for an organization:
>>> from roboto import OrgInvite >>> invites = OrgInvite.for_org("org_12345") >>> for invite in invites: ... print(f"Pending invite for: {invite.invited_user_id}")
- classmethod from_id(invite_id, roboto_client=None)#
Load an existing invitation by its unique ID.
- Parameters:
invite_id (str) – Unique identifier for the invitation to retrieve.
roboto_client (Optional[roboto.http.RobotoClient]) – Optional Roboto client instance. If not provided, uses the default client.
- Returns:
OrgInvite instance for the specified invitation ID.
- Raises:
RobotoNotFoundException – No invitation exists with the specified ID.
RobotoUnauthorizedException – The caller is not authorized to access this invitation.
- Return type:
Examples
Load an invitation by ID:
>>> from roboto import OrgInvite >>> invite = OrgInvite.from_id("invite_12345") >>> print(f"Invited user: {invite.invited_user_id}")
- property invite_id: str#
Unique identifier for this invitation.
- Returns:
The invitation’s unique ID.
- Return type:
str
- property invited_by_user_id: str#
User ID of the person who created this invitation.
- Returns:
The unique identifier of the user who sent the invitation.
- Return type:
str
- property invited_user_id: str#
User ID of the person who was invited.
- Returns:
The unique identifier of the invited user.
- Return type:
str
- property org_id: str#
Organization ID for the organization this invitation is for.
- Returns:
The unique identifier of the organization.
- Return type:
str
- to_dict()#
Convert this invitation to a dictionary representation.
Returns a JSON-serializable dictionary containing all invitation data.
- Returns:
Dictionary representation of the invitation.
- Return type:
dict[str, Any]
Examples
Export invitation data:
>>> from roboto import OrgInvite >>> invite = OrgInvite.from_id("invite_12345") >>> invite_data = invite.to_dict() >>> print(f"Invited user: {invite_data.get('user_id')}")