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(
    base_url="http://localhost:3000",
    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.4.tar.gz (5.8 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.4-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for shift_chat_server_client-0.2.4.tar.gz
Algorithm Hash digest
SHA256 d7b04761db233fdd1e0d90c4ebd88ba6e7e0f7deeac2758ca4033df8f54ddce9
MD5 c633b1f483646081183a2c8d3e15936b
BLAKE2b-256 8c03974efcb6a0023f29820d32ce5ee3153e2f4b67cc57e033bf7cae66c304ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for shift_chat_server_client-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 acfec39c68f3ce651cb15661d955bf7902682b53e98bc2dd95ee784448705b86
MD5 3a8c4eba613cfee839df9ff139a1c27d
BLAKE2b-256 a9df41640a03b8f892a35b7f7cb4c6972f3fabc17fb2045bef9067f2f9e3136a

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