Metadata-Version: 2.4
Name: peepstick
Version: 0.1.0
Summary: Drop-in ticket form + Slack routing for Django apps, powered by PeepsTick
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: requests>=2.25
Provides-Extra: django
Requires-Dist: django>=4.0; extra == "django"
Provides-Extra: fastapi
Requires-Dist: fastapi>=0.100; extra == "fastapi"
Requires-Dist: pydantic>=2.0; extra == "fastapi"

# peepstick

Drop this into a Python app to get ticket routing that goes straight to
your team's Slack channel — configured entirely from the PeepsTick dashboard.

This package never talks to Slack. It only ever calls your PeepsTick
project's API (`/api/form-schema`, `/api/tickets`). PeepsTick owns the
Slack webhook and does the actual posting server-side.

## Install

```bash
# FastAPI apps
pip install "peepstick[fastapi]"

# Django apps
pip install "peepstick[django]"
```

## FastAPI setup

```python
from fastapi import FastAPI
from peepstick.fastapi import create_ticket_router

app = FastAPI()
app.include_router(
    create_ticket_router(
        api_key="tk_...",             # from your project's page in the PeepsTick dashboard
        base_url="https://peepstick.yourcompany.com",
    ),
    prefix="/peepstick",
)
```

This gives your app two routes your frontend can call — the API key
never reaches the browser:

- `GET /peepstick/form-schema` — the live fields configured for your project
- `POST /peepstick/tickets` — submits `{"fields": {...}}`, validated and
  routed to Slack server-side

Add or rename fields in the PeepsTick dashboard and `/peepstick/form-schema`
updates automatically — no code changes or redeploys needed.

## Django setup

1. In `settings.py`, add the app and your project's credentials
   (find the API key on your project's page in the PeepsTick dashboard):

   ```python
   INSTALLED_APPS = [
       ...,
       "peepstick.django",
   ]

   PEEPSTICK_API_KEY = "tk_..."
   PEEPSTICK_BASE_URL = "https://peepstick.yourcompany.com"
   ```

2. In your project's `urls.py`:

   ```python
   from django.urls import include, path

   urlpatterns = [
       ...,
       path("tickets/", include("peepstick.django.urls")),
   ]
   ```

3. Visit `/tickets/`. The form renders whatever fields are configured
   for your project in the PeepsTick dashboard — add or rename fields
   there and the form updates automatically, no code changes needed.

## Using the client directly

If you'd rather build your own view or call PeepsTick from a script:

```python
from peepstick import PeepsTickClient

client = PeepsTickClient(api_key="tk_...", base_url="https://peepstick.yourcompany.com")

fields = client.get_form_schema()
ticket = client.submit_ticket({"title": "Login broken", "priority": "High"})
```

Both methods raise `peepstick.PeepsTickError` on failure (network
issues, invalid API key, missing required fields, etc).
