Skip to content

Commit

Permalink
0.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
jellyfrank committed Dec 13, 2019
1 parent a03f15a commit 4e97ebb
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 9 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,8 @@ sf.order.create_order(clientid,..)

## changelog

* [0.0.6] 新增路由查询接口
* [0.0.3] 新增确定/取消订单接口

python2 的同学请使用0.0.5 版本

2 changes: 1 addition & 1 deletion sf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
# @Time : 2019-08-21
# @Author : Kevin Kong ([email protected])

__version__ = "0.0.4"
__version__ = "0.0.6"
__author__ = "Kevin Kong"
2 changes: 0 additions & 2 deletions sf/comm/comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,5 @@ def post(self, data):
"verifyCode": self.gen_verifycode(xml)
}

print(post_data)
response = requests.post(URL, post_data)
print(response.content.decode('utf-8'))
return self.parse_response(response.content)
27 changes: 27 additions & 0 deletions sf/order/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,30 @@ def get_order(self, orderid, search_type="1"):
}

return self.post(data)

def get_route_info(self, tracking_number, tracking_type=1, method_type=1, reference_number=None, check_phoneNo=None):
"""
路由信息查询接口
param tracking_number: 查询号,根据type不同,含义不同,多个单号以,分割
param tracking_type: 查询号类别,1 顺丰运单号 2 客户订单号 3 逆向单
param method_type: 路由查询类别 1:标准路由查询
param reference_number: 参考编码(目前针对亚马逊客户,由客户传)
param check_phoneNo: 校验电话号码后四位值;
"""

data = {
"service": "RouteService",
"data": {
"RouteRequest": {
"tracking_number": tracking_number
}
}
}

frame = inspect.currentframe()
args, _, _, values = inspect.getargvalues(frame)
for i in args:
if values[i] and i != 'self':
data["data"]["RouteRequest"][i] = str(values[i])

return self.post(data)
Empty file added tests/__init__.py
Empty file.
19 changes: 13 additions & 6 deletions tests/test_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,25 @@ def test_order(self):
"""测试下单"""
# 顺丰接口不允许重复下单,因此拿到结果就算通过
res = self.sf.order.create_order("SFKD-20160219000021", "测试公司",
"张三", "18512345678", "丰县", "北京市昌平区", "15112345678")
self.assertIn(res["result"],[1,0])
"张三", "18512345678", "丰县", "北京市昌平区", "15112345678")
self.assertIn(res["result"], [1, 0])

def test_cancel_order(self):
"""测试取消订单"""

res = self.sf.order.confirm_order("SFKD-20160219000021","444017832497","2")
self.assertIn(res["result"],[1,0])

res = self.sf.order.confirm_order(
"SFKD-20160219000021", "444017832497", "2")
self.assertIn(res["result"], [1, 0])

def test_get_order(self):
"""测试订单查询接口"""
self.assertEquals(self.sf.order.get_order("SFKD-20160219000021"),1)
res = self.sf.order.get_order("SFKD-20160219000021")
self.assertIn(res["result"], [1, 0])

def test_get_router(self):
"""测试路由信息"""
res = self.sf.order.get_route_info("SFKD-20160219000021")
self.assertEqual(res["result"], 0)


if __name__ == "__main__":
Expand Down

0 comments on commit 4e97ebb

Please sign in to comment.