Metadata-Version: 2.4
Name: pytjbrhk
Version: 1.0.0
Summary: 天津博瑞晧科 机器人 API 的 Python SDK，同时提供同步和异步两种调用方式。
Home-page: https://gitee.com/guolei19850528/pytjbrhk
Author: guolei
Author-email: 174000902@qq.com
License: MIT
Keywords: 天津博瑞晧科 机器人 消息推送 智能音箱
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx
Requires-Dist: jsonschema
Requires-Dist: decorator
Requires-Dist: jsonpath-ng
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license
Dynamic: license-file
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# pytjbrhk

天津博瑞晧科 机器人 API 的 Python SDK，提供同步和异步两种调用方式。

## 功能特性

- 支持同步和异步两种调用模式
- 提供语音通知功能
- 内置 JSON Schema 数据校验
- 支持自定义 HTTP 客户端配置

## 安装

```bash
pip install pytjbrhk
```

或者从源码安装：

```bash
git clone https://gitee.com/guolei19850528/pytjbrhk.git
cd pytjbrhk
pip install .
```

## 依赖

- Python >= 3.10
- httpx
- jsonschema
- decorator
- jsonpath-ng

## 快速开始

### 同步方式

```python
from pytjbrhk import Speaker

# 创建客户端
speaker = Speaker(
    token="your_token",
    id="your_device_id"
)

# 发送通知
response = speaker.notify(message="Hello, World!")
print(response.json())
```

### 异步方式

```python
import asyncio
from pytjbrhk import Speaker

# 创建异步客户端
speaker = Speaker(
    token="your_token",
    id="your_device_id",
    use_async_client=True
)

# 发送异步通知
async def send_notification():
    response = await speaker.async_notify(message="Hello, World!")
    print(response.json())

asyncio.run(send_notification())
```

## API 文档

### Speaker 类

#### 初始化参数

| 参数 | 类型 | 默认值 | 说明 |
|------|------|--------|------|
| base_url | str | https://speaker.17laimai.cn | 语音通知服务的基础 URL |
| token | str | "" | 服务认证令牌 |
| id | str | "" | 设备或用户标识 ID |
| version | str | "1" | API 版本号 |
| client_kwargs | dict | None | httpx 客户端的额外配置参数 |
| use_async_client | bool | False | 是否使用异步客户端 |

#### 方法

##### notify(client=None, message="", **kwargs)

发送同步通知请求。

| 参数 | 类型 | 说明 |
|------|------|------|
| client | httpx.Client | 自定义的同步客户端，可选 |
| message | str | 通知消息内容 |
| **kwargs | dict | 额外的请求参数 |

**返回值**: `httpx.Response` - 请求响应对象

##### async_notify(client=None, message="", **kwargs)

发送异步通知请求。

| 参数 | 类型 | 说明 |
|------|------|------|
| client | httpx.AsyncClient | 自定义的异步客户端，可选 |
| message | str | 通知消息内容 |
| **kwargs | dict | 额外的请求参数 |

**返回值**: `httpx.Response` - 请求响应对象

### 工具函数

#### json_find_first(expression, data)

使用 JSONPath 表达式从数据中查找第一个匹配项。

#### json_is_valid(schema, data)

校验 JSON 数据是否符合指定的 JSON Schema。

#### get_notify_result(response)

判断消息通知是否成功。

## 许可证

MIT License

## 作者

guolei <174000902@qq.com>

## 项目地址

https://gitee.com/guolei19850528/pytjbrhk
