Skip to main content

铁虎停车系统 Python SDK,提供简单易用的铁虎停车系统 API 交互功能,支持与铁虎停车系统的各种操作。

Project description

py_easy_tiehu

铁虎停车系统 Python SDK,提供简单易用的铁虎停车系统 API 交互功能,支持与铁虎停车系统的各种操作。

功能特性

  • API 客户端:提供与铁虎停车系统 API 交互的客户端
  • 签名生成:按照铁虎停车系统 API 要求生成请求签名
  • 同步/异步支持:同时支持同步和异步操作
  • 灵活配置:支持通过参数自定义客户端行为
  • 响应处理:提供 JSON 数据验证功能
  • 类型提示:完整的类型注解,提供良好的 IDE 支持

安装

使用 pip 安装

pip install py_easy_tiehu

从源码安装

git clone https://gitee.com/guolei19850528/py_easy_tiehu.git
cd py_easy_tiehu
pip install -e .

依赖

  • httpx
  • py_easy_httpx

快速开始

同步请求

from py_easy_tiehu.pklot import Pklot

# 初始化铁虎停车系统客户端
pklot_client = Pklot(
    base_url="https://example.com",
    parking_id="YOUR_PARKING_ID",
    app_key="YOUR_APP_KEY"
)

# 发送同步请求
response = pklot_client.request(
    url="/api/endpoint",
    json={
        "param1": "value1",
        "param2": "value2"
    }
)
print(f"请求结果: {response}")

异步请求

import asyncio
from py_easy_tiehu.pklot import Pklot

async def main():
    # 初始化铁虎停车系统客户端
    pklot_client = Pklot(
        base_url="https://example.com",
        parking_id="YOUR_PARKING_ID",
        app_key="YOUR_APP_KEY"
    )
    
    # 发送异步请求
    response = await pklot_client.async_request(
        url="/api/endpoint",
        json={
            "param1": "value1",
            "param2": "value2"
        }
    )
    print(f"请求结果: {response}")

asyncio.run(main())

API 文档

Pklot 类

初始化参数

  • base_url: 铁虎停车系统的基础 URL
  • parking_id: 停车场 ID
  • app_key: 应用密钥,用于签名生成
  • client_kwargs: 传递给 httpx.Client 的额外参数

方法

  • signature(data=None): 生成请求签名
  • request(client=None, **kwargs): 同步发送请求
  • async_request(client=None, **kwargs): 异步发送请求

高级用法

自定义客户端配置

from py_easy_tiehu.pklot import Pklot

# 初始化铁虎停车系统客户端,自定义客户端配置
pklot_client = Pklot(
    base_url="https://example.com",
    parking_id="YOUR_PARKING_ID",
    app_key="YOUR_APP_KEY",
    client_kwargs={
        "timeout": 60.0,  # 设置超时时间为 60 秒
        "headers": {
            "User-Agent": "py_easy_tiehu"
        }
    }
)

# 发送请求
response = pklot_client.request(
    url="/api/endpoint",
    json={
        "param1": "value1",
        "param2": "value2"
    }
)
print(f"请求结果: {response}")

项目结构

py_easy_tiehu/
├── py_easy_tiehu/              # 主包目录
│   ├── __init__.py            # 包初始化文件
│   └── pklot.py               # 铁虎停车系统API客户端模块
├── README.md                  # 项目文档
├── setup.py                   # 安装配置
├── requirements.txt           # 依赖列表
├── LICENSE                    # 许可证文件
├── deploy.sh                  # 部署脚本
├── .gitignore                 # Git 忽略文件
└── test_pklot.py              # 测试文件

测试

运行测试:

# 运行测试
python test_pklot.py

许可证

MIT License

贡献

欢迎提交 Issue 和 Pull Request!

联系方式

致谢

  • httpx - 高性能的异步 HTTP 客户端库
  • py_easy_httpx - 简化 HTTP 请求的工具包

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_easy_tiehu-1.0.1-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file py_easy_tiehu-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: py_easy_tiehu-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.6

File hashes

Hashes for py_easy_tiehu-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8b18742e6a4ff4caf8d3b9358258d7e0dc095fa298b1adf3a2ede7abda877d0b
MD5 c77f1bedc7f98d7fab169d15325b5eea
BLAKE2b-256 19c5037448411ced8de551192e917c06ed78d997b914f1677b0a1d5bcb6b9614

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page