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.8.tar.gz (6.2 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.8-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for shift_chat_server_client-0.2.8.tar.gz
Algorithm Hash digest
SHA256 001d3b58f72d7664c60dfa8250cc2451511f7e4d0f2ec01b8ee0ed82b55193c9
MD5 594afe15821f7168272cd9c03db734ce
BLAKE2b-256 be6994dc314f809ccfa09670cf36fa8647b621f9eef4aacaa96395a2ad435981

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for shift_chat_server_client-0.2.8-py3-none-any.whl
Algorithm Hash digest
SHA256 aa403ffdd84d7615638e4c9fcc230995f5a969481ea56ec4f6bbc3eb640f1d8a
MD5 ad092a81e468e437877614084af3a3b7
BLAKE2b-256 1712af5e0febbc6656a0ba5e4d8971cbf93c26520678a1c8ecff478390f1a45e

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