A Python client for the Shift Chat Server
Project description
Shift Chat Server Client
Python client for interacting with the Shift Chat Server.
Installation
pip install .
Usage
Initialization
from shift_chat.client import ShiftChatClient
# Initialize the client with your credentials
client = ShiftChatClient(
client_id="your-client-id",
client_secret="your-client-secret"
)
# Authenticate (optional, methods will auto-authenticate if needed)
client.authenticate()
Managing Users
You can create or update users using the set_user method. You must provide either an email address OR a phone number (or both). You can also provide a reference_id to map to your own system's user IDs.
Create/Update user with Email:
user = client.set_user(
first_name="John",
last_name="Doe",
password="securePassword123",
email="john.doe@example.com"
)
print(f"Created user: {user['id']}")
Create/Update user with Phone Number:
user = client.set_user(
first_name="Jane",
last_name="Smith",
password="securePassword123",
phone_number="+15550123456"
)
print(f"Created user: {user['id']}")
Create/Update user with Reference ID:
This is useful for mapping users from your system to Shift Chat users.
user = client.set_user(
first_name="Alice",
last_name="Wonder",
password="securePassword123",
email="alice@example.com",
reference_id="your-system-user-id-123"
)
Get User by Reference ID:
user = client.get_user_by_reference_id("your-system-user-id-123")
if user:
print(f"Found user: {user['id']}")
else:
print("User not found")
Managing Workspaces and Channels
You can add users to workspaces and channels using their IDs.
Add User to Workspace:
client.add_user_to_workspace(
user_id="user-uuid-123",
workspace_id="workspace-uuid-456"
)
Add User to Channel:
client.add_user_to_channel(
user_id="user-uuid-123",
channel_id="channel-uuid-789"
)
Acting on Behalf of a User
Once a user exists, you can perform actions on their behalf using authenticate_user.
# Get a user-specific client
user_client = client.authenticate_user(user_id="user-uuid-123")
# List workspaces the user belongs to
workspaces = user_client.get_workspaces()
for ws in workspaces:
print(f"Workspace: {ws['name']}")
# List workspaces with channels (formatted for mobile app)
workspaces_with_channels = user_client.get_workspaces_with_channels()
# Create a channel
channel = user_client.set_channel(
workspace_id="workspace-uuid-123",
name="general-discussion",
is_public=True
)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file shift_chat_server_client-0.2.6.tar.gz.
File metadata
- Download URL: shift_chat_server_client-0.2.6.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
880875b1066d9aac9979a9476916656ff5bf96862259cade0ebdb541a98e134c
|
|
| MD5 |
40eaf5bf519029f010721535add8ab86
|
|
| BLAKE2b-256 |
ec1d7f1a72932e02d427b64ca7ecbee0438d0e444a5c64bf26075dc08e71e349
|
File details
Details for the file shift_chat_server_client-0.2.6-py3-none-any.whl.
File metadata
- Download URL: shift_chat_server_client-0.2.6-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b398cf49739ac82a9fde1db71f4f835964cca3f8595516ace30ae540bb3c2ad
|
|
| MD5 |
4f815bca49f4242e7145966c630a6b15
|
|
| BLAKE2b-256 |
ef238b56467e21ebb8416712bdb0d597738e9af7c882b67eab4e0232a99779be
|