fastbill API 的瘦 python 包装器
项目描述
由STYLIGHT开发的 Fastbill 的 HTTP API 的超薄 Python 包装器。
最新发布的:
错误修复版本。在没有有效 JSON 结构的成功 HTTP 响应的情况下,包装器会崩溃。
由于测试配置错误,未运行会捕获此错误的测试。这也是固定的。
为所有 API 调用添加可配置的超时。默认超时为 1 分钟。 这可能会导致意外的超时异常,您需要处理。
名称参数的修正版本。
警告:此版本有一个错误。'name' 参数将在 Python2 上的 str 类型上中断。请改用 0.7.1。
潜在的重大变化:将 fastbill 模块重组为包,每个组件都有自己的模块。您的导入可能会中断。
向 setup.py 添加了模拟库
重大变化:不要抛出 KeyError,而是在 FastbillResponse.currency 属性上抛出 AttributeError
添加请求前和请求后回调
在 CURRENCIES 字典中添加了 NOK。
支持对FastbillResponse对象的酸洗。不过,API 连接的链接不会被腌制。API 凭证也不会被腌制。
引入name参数以更好地区分FastbillWrapper实例。
错误修复版本。
调用像 __unicode__ 这样的潜在特殊方法会导致错误的 Fastbill API 调用。
改进的调试日志记录。
不推荐使用“FastbillHttpError”执行。现在只会引发 FastbillResponseError 。FastbillResponseError将暂时继承自FastbillHttpError ,但不推荐捕获FastbillHttpError。请改用 FastbillResponseError。
改进了测试用例以检查失败的 API 调用。
实验性:改进FastbillResponse以允许像对象遍历一样的 ORM。谨慎使用。
添加了属性currency,当响应中存在 CURRENCY_CODE 整数时,该属性会查找正确的 ISO 4217 货币缩写。不存在时将引发AttributeError 。
限制:
仅支持 JSON 有效负载
不(过度)检查响应的一致性
不将日期字符串转换为日期时间对象
依赖项:
要求
六个(用于 Python 2/3 兼容性)
安装:
点安装fastbill
用法:
from fastbill import FastbillWrapper
# Construct the api client for Fastbill's automatic API
client = FastbillWrapper('fastbill_user', 'fastbill_key')
# You can also specify a service_url, in case you need Fastbill's core API instead:
core_client = FastbillWrapper('fastbill_user', 'fastbill_key', service_url='endpoint_url')
# Make requests, e.g. service customer.create
client.customer_create(data={})
# Search for customer, subscriptions, etc...
for customer in client.customer_get(filter={'city': 'Munich'}):
print customer
# But you can also see the full result
result = client.customer_get(filter={'city': 'Munich'})
print result.keys()
# Will give you 'CUSTOMERS'