Metadata-Version: 2.4
Name: mnrq-sdk
Version: 1.1.1
Summary: Official MNRQ (Menuraq) Python SDK
Author: Menuraq
Project-URL: Homepage, https://menuraq.com
Project-URL: Documentation, https://menuraq.com/docs/developer-api
Keywords: mnrq,menuraq,sdk,api,menu,restaurant
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: requests>=2.31.0

# MNRQ Python SDK (`mnrq-sdk`)

Official Python SDK for the Menuraq Developer API.

## Version

`1.1.1`

## Install

```bash
pip install mnrq-sdk
```

## Quick Start

```python
from mnrq_sdk import MnrqClient

client = MnrqClient(
    api_key="<YOUR_API_KEY>",
    base_url="https://menuraq.com",
)

business = client.get_business()
print(business["data"]["business"]["name"])
```

## Client Configuration

```python
client = MnrqClient(
    api_key="mnrq_live_xxx",
    base_url="https://menuraq.com",
    timeout=20.0,  # optional
)
```

- `api_key` required
- `base_url` required
- `timeout` optional (seconds, default `20.0`)

Auth headers sent automatically:

- `Authorization: Bearer <api_key>`
- `x-api-key: <api_key>`

## API Coverage

### System

- `get_api_info()` -> `GET /api/v1`

### Business and Branches

- `get_business()` -> `GET /api/v1/business`
- `get_branches(include_inactive=False)` -> `GET /api/v1/branches`

### Menus

- `get_menus(limit=20, offset=0, status=None, include_items=False)` -> `GET /api/v1/menus`
- `get_menu(menu_id, include_analytics=False)` -> `GET /api/v1/menus/:menuId`
- `get_menu_items(menu_id=None, category_id=None, available=None, limit=50, offset=0)` -> `GET /api/v1/menu-items`

### Analytics

- `get_analytics(menu_id=None, date_from=None, date_to=None, include_daily=True)` -> `GET /api/v1/analytics`

### Promotions

- `get_promotions(menu_id=None, active_only=True, limit=25, offset=0)` -> `GET /api/v1/promotions`
- `get_promotion(promotion_id)` -> `GET /api/v1/promotions/:promotionId`

### Templates

- `get_template_render(menu_id=None, menu_slug=None, mode='iframe', hide_header=None)` -> `GET /api/v1/templates/render`
- `get_template_iframe(menu_id=None, menu_slug=None, hide_header=None)` convenience wrapper
- `get_template_html(menu_id=None, menu_slug=None, hide_header=None)` convenience wrapper

`hide_header=True` makes the returned public/iframe URL use embed mode so `/m/[slug]` header is hidden.

### Menu Item Writes

- `update_menu_item(item_id, patch)` -> `PATCH /api/v1/menu-items/:itemId`

## Examples

### Read menus

```python
menus = client.get_menus(limit=20, status="live")
print(menus["data"])
```

### Get template iframe response

```python
render = client.get_template_iframe(menu_slug="main-menu", hide_header=True)
print(render["data"]["public_url"])
print(render["data"]["embed_code"])
```

### Update a menu item

```python
client.update_menu_item(
    "item_uuid_here",
    {
        "title": "Spicy Chicken Deluxe",
        "price": 18.5,
        "available": True,
    },
)
```

## Error Handling

The SDK raises `MnrqApiError` for non-2xx or `ok: false` responses.

```python
from mnrq_sdk import MnrqApiError

try:
    client.get_business()
except MnrqApiError as error:
    print(error.status_code, error.code, error.request_id, error.details)
```

## Backward Compatibility

Legacy aliases are preserved:

- `MenuraqClient` alias for `MnrqClient`
- `MenuraqApiError` alias for `MnrqApiError`

## Test

```bash
cd sdk/python
python -m unittest discover -s tests -p "*_test.py" -v
```

The suite validates constructor behavior, every SDK method mapping, payload/params, and error translation.

## Build and Publish

```bash
cd sdk/python
python -m pip install --upgrade build twine
python -m build
twine upload dist/*
```

Package name on PyPI is `mnrq-sdk`, import module name is `mnrq_sdk`.
