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

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for shift_chat_server_client-0.3.2.tar.gz
Algorithm Hash digest
SHA256 17b451f9ddfab4126dc56b60046bcec9496dfdc55ca29109a9e2409da0b794e4
MD5 64ed720c07565248be69d75a7911716c
BLAKE2b-256 48a9948797a1776cc2735c7612ef32845057f08c361b76817a1e6e24f18ef244

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for shift_chat_server_client-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a046b54bfc915e17e278e0dba786ac9edc1f437966dd596cf5639f5b0b394fc8
MD5 ff42c2ed62e357d45030795a9c6e0e55
BLAKE2b-256 588507901058bad012ebfa5adb4fe626da25e204e21123bbe609d8749481a707

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