跳转到主要内容

用于与Kunaki.com XML API接口的Python模块

项目描述

py-kunaki

信息::

用于与Kunaki.com XML API接口的Python模块

版本::

0.1

作者::

Netlandish Inc. (http://www.netlandish.com)

依赖关系

  • Python 2.6+

安装

PIP

pip install py-kunaki

基本手册安装

$ python setup.py build
$ sudo python setup.py install

替代安装(手动)

将kunaki目录放置在您的Python路径中。可以在您的Python安装site-packages目录中,或将您的$PYTHONPATH环境变量设置为包含webutils目录的目录。

使用方法

请首先参考Kunaki XML Web服务文档:http://kunaki.com/XMLService.htm


获取潜在订单的运输选项:

from kunaki import ShippingProduct, ShippingOptions

product1 = ShippingProduct(product_id='XZZ1111111', quantity=2)
product2 = ShippingProduct(product_id='PXZZ111112', quantity=3)
shipping_opts = ShippingOptions(
    country='United States',
    state='NY',
    postal_code='10004',
    products=[product1, product2],
)
# Optionally add a product
shipping_opts.add_product(ShippingProduct(product_id='PXZZ111111', quantity=1))
# Submit the shipping options request
shipping_opts.send()

if shipping_opts.success:
    # Retrieve options list
    options = shipping_opts.get_options()
    for opt in options:
        print 'Description:', opt.description
        print 'Delivery Time:', opt.delivery_time
        print 'Price:', opt.price
else:
    print 'Error:', shipping_opts.error_msg

请求制造和履行订单:

from kunaki import ShippingProduct, Order

products = [
    ShippingProduct(product_id='XZZ1111111', quantity=2),
    ShippingProduct(product_id='PXZZ111112', quantity=3),
]
order = Order(
    username='santaclaus@northpole.com',
    password='Rednose',
    name='John Smith',
    address1='215 Maple Street',
    address2='Room 134',
    city='New York',
    postal_code='10004',
    country='United States',
    shipping_description='USPS Priority Mail',
    products=products,
    state='NY',
    company='Smith Enterprises',
)
# Optionally add a product
order.add_product(ShippingProduct(product_id='PXZZ111111', quantity=1))
# Submit the order request
order.send()

if order.success:
    print 'Order Id:', order.order_id
else:
    print 'Error:', order.error_msg

请求订单状态:

from kunaki import OrderStatus

order_status = OrderStatus(
    username='santaclaus@northpole.com',
    password='Rednose',
    order_id='567129',
)

if order_status.success:
    print 'Status:', order_status.status
    print 'Tracking Type:', order_status.tracking_type
    print 'Tracking Id:', order_status.tracking_id
else:
    print 'Error:', order_status.error_msg

商业支持

该软件以及许多类似软件已为Netlandish的许多自身项目和客户项目提供支持。我们愿意帮助您在下一个项目中取得成功,请通过给我们发送邮件至 hello@netlandish.com 联系我们。

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于 安装软件包 的信息。

源分布

py-kunaki-0.1.tar.gz (5.6 kB 查看哈希值)

上传时间

支持者