Metadata-Version: 2.4
Name: py-easy-wwtl
Version: 2.0.0
Summary: 微网通联短信发送 Python SDK，提供简单易用的微网通联短信平台 API 交互功能，支持短信发送、签名生成等操作。   
Home-page: https://gitee.com/guolei19850528/py_easy_wwtl
Author: guolei
Author-email: 174000902@qq.com
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx
Requires-Dist: jsonschema
Requires-Dist: jsonpath-ng
Requires-Dist: py-easy-httpx
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# py_easy_wwtl

微网通联短信发送 Python SDK，提供简单易用的微网通联短信平台 API 交互功能，支持短信发送、签名生成等操作。

## 功能特性

- **短信发送**：支持同步和异步发送短信
- **签名生成**：按照微网通联 API 要求生成 SHA256 签名
- **灵活配置**：支持通过参数自定义客户端行为
- **响应处理**：提供 JSON 数据验证功能
- **同步/异步支持**：同时支持同步和异步操作
- **类型提示**：完整的类型注解，提供良好的 IDE 支持

## 安装

### 使用 pip 安装

```bash
pip install py_easy_wwtl
```

### 从源码安装

```bash
git clone https://gitee.com/guolei19850528/py_easy_wwtl.git
cd py_easy_wwtl
pip install -e .
```

## 依赖

- httpx
- py_easy_httpx

## 快速开始

### 同步发送短信

```python
from py_easy_wwtl.sms import Sms

# 初始化短信客户端
sms_client = Sms(
    account_id="YOUR_ACCOUNT_ID",
    password="YOUR_PASSWORD",
    product_id="YOUR_PRODUCT_ID"
)

# 发送短信
response = sms_client.send(
    phone_nos="13800138000",
    content="【测试】这是一条测试短信"
)
print(f"发送结果: {response}")
```

### 异步发送短信

```python
import asyncio
from py_easy_wwtl.sms import Sms

async def main():
    # 初始化短信客户端
    sms_client = Sms(
        account_id="YOUR_ACCOUNT_ID",
        password="YOUR_PASSWORD",
        product_id="YOUR_PRODUCT_ID"
    )
    
    # 异步发送短信
    response = await sms_client.async_send(
        phone_nos="13800138000",
        content="【测试】这是一条测试短信"
    )
    print(f"发送结果: {response}")

asyncio.run(main())
```

## API 文档

### 函数

#### `sha256_signature(account_id, password, phone_nos, random_digits, timestamp, smms_encrypt_key)`
生成 SHA256 签名

- **参数**:
  - `account_id`: 账号 ID
  - `password`: 密码
  - `phone_nos`: 手机号，多个手机号用逗号分隔
  - `random_digits`: 随机数字
  - `timestamp`: 时间戳
  - `smms_encrypt_key`: 加密密钥
- **返回**:
  - `str`: SHA256 签名结果

### Sms 类

#### 初始化参数
- `base_url`: API 基础 URL，默认为 "https://api.51welink.com/"
- `account_id`: 微网通联账号 ID
- `password`: 微网通联账号密码
- `product_id`: 产品 ID
- `smms_encrypt_key`: 加密密钥，默认为 "SMmsEncryptKey"
- `client_kwargs`: 传递给 httpx.Client 的额外参数

#### 方法
- `send(client=None, phone_nos="", content="", **kwargs)`: 同步发送短信
- `async_send(client=None, phone_nos="", content="", **kwargs)`: 异步发送短信

## 高级用法

### 自定义客户端配置

```python
from py_easy_wwtl.sms import Sms

# 初始化短信客户端，自定义客户端配置
sms_client = Sms(
    account_id="YOUR_ACCOUNT_ID",
    password="YOUR_PASSWORD",
    product_id="YOUR_PRODUCT_ID",
    client_kwargs={
        "timeout": 30.0,  # 设置超时时间为 30 秒
        "headers": {
            "User-Agent": "py_easy_wwtl"
        }
    }
)

# 发送短信
response = sms_client.send(
    phone_nos="13800138000",
    content="【测试】这是一条测试短信"
)
print(f"发送结果: {response}")
```

## 项目结构

```
py_easy_wwtl/
├── py_easy_wwtl/              # 主包目录
│   ├── __init__.py            # 包初始化文件
│   └── sms.py                 # 短信发送模块
├── README.md                  # 项目文档
├── setup.py                   # 安装配置
├── requirements.txt           # 依赖列表
├── LICENSE                    # 许可证文件
└── .gitignore                 # Git 忽略文件
```

## 测试

运行测试：

```bash
# 运行测试
python -m pytest
```

## 许可证

MIT License

## 贡献

欢迎提交 Issue 和 Pull Request！

## 联系方式

- 作者：guolei
- 邮箱：174000902@qq.com
- 项目地址：https://gitee.com/guolei19850528/py_easy_wwtl

## 致谢

- [httpx](https://www.python-httpx.org/) - 高性能的异步 HTTP 客户端库
- [py_easy_httpx](https://gitee.com/guolei19850528/py_easy_httpx) - 简化 HTTP 请求的工具包
