Metadata-Version: 2.4
Name: orvelt-business
Version: 0.1.0
Summary: Python SDK for the Orvelt Business REST API.
Author: Orvelt
License: Apache-2.0
Project-URL: homepage, https://github.com/orveltinc/python-sdk
Project-URL: repository, https://github.com/orveltinc/python-sdk
Project-URL: documentation, https://resource.orvelt.com/docs
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpcore>=1.0.9
Requires-Dist: httpx>=0.28.1
Requires-Dist: jsonpath-python>=1.0.6
Requires-Dist: pydantic>=2.11.2
Dynamic: license-file

# Orvelt Business Python SDK

Python 3.10+ client for the Orvelt Business API, generated with Speakeasy from the same curated OpenAPI document as `@orvelt/business`.

The SDK repository is [`orveltinc/python-sdk`](https://github.com/orveltinc/python-sdk), separate from [`orveltinc/typescript-sdk`](https://github.com/orveltinc/typescript-sdk). The SDK uses the [Apache-2.0 license](https://github.com/orveltinc/python-sdk/blob/main/LICENSE).

## Installation

```sh
pip install orvelt-business
```

## Usage

Create a Business API key in Orvelt Business and keep it server-side. The Speakeasy key is only for generating this SDK; it is not a Business API credential.

```python
import os
from orvelt_business import Orvelt

with Orvelt(business_api_key=os.environ["ORVELT_BUSINESS_API_KEY"]) as client:
    page = client.opinions.list(
        project_id="PROJECT_UUID",
        page=1,
        limit=20,
        external_user_id="customer-42",
    )
    print(page.result.opinions)
```

Every operation has an async equivalent with an `_async` suffix:

```python
async with Orvelt(business_api_key=os.environ["ORVELT_BUSINESS_API_KEY"]) as client:
    page = await client.opinions.list_async(project_id="PROJECT_UUID")
    print(page.result.opinions)
```

Use separate clients for separate tenants. Pass `server_url="https://your-staging-api.example/v1"` to override the default `https://api.orvelt.com/v1`, and `timeout_ms=10_000` to set a request timeout.

## Operations

| Resource | Methods |
| --- | --- |
| `questions` | `list`, `create`, `update`, `delete` |
| `link` | `list`, `create`, `resend` |
| `qr` | `display` |
| `opinions` | `list` |
| `answers` | `list` |
| `subscribers` | `count`, `invite` |

These are the same 12 REST operations exposed by the TypeScript SDK, not the full first-party Business API. Browser iframe and modal helpers remain JavaScript-only.

Python parameters use snake_case; requests retain the API's camelCase field names. Pass `project_id` to each operation. Responses are typed Pydantic models, not the TypeScript SDK's `{ data, error }` envelope. See [generated operation documentation](https://github.com/orveltinc/python-sdk/blob/main/docs/sdks/questions/README.md) and [usage examples](https://github.com/orveltinc/python-sdk/blob/main/USAGE.md).

`link.list`, `opinions.list`, and `answers.list` return a page with the typed response in `.result`. Call `.next()` (or `await page.next()` for async calls) to fetch the next page; it returns `None` after `pagination.totalPages`. Pagination keeps the original filters, credentials, and page size.

HTTP failures raise subclasses of `orvelt_business.errors.OrveltError`, with `status_code`, `headers`, `body`, and `raw_response`. Malformed responses raise `ResponseValidationError`; transport failures raise HTTPX errors. GET requests retry connection failures and HTTP 429, 500, 502, 503, and 504 with bounded backoff. Pass `retries=None` to disable read retries. Mutations never retry by default; this includes invitations, link issuance, and rotating QR display.

## Development

Open Speakeasy Studio from the monorepo root:

```sh
moon run business-sdk-python:studio
```

Keep the terminal open and use the Studio tab opened by the CLI. This watches the committed `openapi.json` without bumping versions or publishing a package. Press Ctrl+C to stop.

From this directory:

```sh
uv sync --locked
uv run --locked pytest test/unit
uv run --locked mypy src
uv run --locked ruff check scripts/sync_openapi.py test
uv build
```

Regenerate both the source spec and Python client from the monorepo root:

```sh
moon run business-sdk-python:generate
```

This first runs the shared contract-to-OpenAPI generation, then adds Python grouping, read retries, and pagination metadata. No endpoint or validation schema is maintained separately.

To regenerate from the committed Python spec without the monorepo:

```sh
uv run --locked speakeasy run --target python --output console --skip-versioning --skip-upload-spec --auto-yes
```

Speakeasy CLI 1.805.0 is pinned in `.speakeasy/workflow.yaml`. Authenticate your CLI or supply `SPEAKEASY_API_KEY` through the environment; never commit it. `--skip-versioning` keeps regeneration separate from releases. PyPI publishing uses Trusted Publishing in the dedicated repository's release workflow, not the local generation task.

`python scripts/sync_openapi.py --check` detects spec drift in the monorepo. Unit tests exercise all 12 sync and async methods with an offline HTTP transport, including authentication, request serialization, filters, errors, and default retry behavior.

Do not edit generated files under `src/orvelt_business/` or `docs/`. Change contracts or generator configuration and regenerate.

Generation runs compilation using the SDK's locked Python environment. Speakeasy may still advise that the question-update body is optional and that the boolean-tagged error unions cannot infer a string discriminator. These reflect the current API and generator; do not invent required fields, weaken error validation, or suppress warnings to hide them.

## Repository ownership

The standalone SDK repository's `.github/workflows/business-python-sdk.yml` verifies checkouts, builds distributions, and tests the installed wheel. It runs only in `orveltinc/python-sdk` and does not require private monorepo packages or secrets. Spec-parity checks against the TypeScript source remain local monorepo tasks.

SDK releases are independent of the monorepo's branches and deployment pipeline. `.github/workflows/sdk_publish.yaml` verifies and publishes releases from this repository's `main` using Speakeasy and PyPI Trusted Publishing.
