Skip to main content

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

shift_chat_server_client-0.2.5.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shift_chat_server_client-0.2.5-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file shift_chat_server_client-0.2.5.tar.gz.

File metadata

File hashes

Hashes for shift_chat_server_client-0.2.5.tar.gz
Algorithm Hash digest
SHA256 ee2476de3fbfd6c502ae3ea1d3929ff04b1d22217229b9adfdea07b149bd3882
MD5 05ecc6ef977c2267ff6fdfb7eee0fabf
BLAKE2b-256 c3007c43c88c37c1401a1ee9a7e4423b1bc3e196109949691c68cb35d57790b0

See more details on using hashes here.

File details

Details for the file shift_chat_server_client-0.2.5-py3-none-any.whl.

File metadata

File hashes

Hashes for shift_chat_server_client-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 957048af45319ef17b249dc266a83b280aec2bbd0c728019f479c411bf636083
MD5 29b00560b3e1dac03ea43146046fc44b
BLAKE2b-256 cb1ac8b76130c272275735d1ced688598d1e86f84e63b1d77c82cba8a7192709

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page