Skip to content

Commit 405a119

Browse files
authored
Merge pull request #11 from yunpian/develop
Develop
2 parents 627ba70 + f76ab6b commit 405a119

22 files changed

+200
-121
lines changed

MANIFEST.in

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
recursive-exclude tests *
2-
include LICENSE README.md tox.ini
3-
include yunpian_python_sdk/yunpian.ini
2+
include LICENSE README.rst tox.ini
43
recursive-include docs *

README.rst

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
yunpian-python-sdk
2+
==================
3+
4+
`云片 <https://www.yunpian.com/>`__ SDK
5+
6+
快速开始
7+
--------
8+
9+
- 安装SDK
10+
11+
.. code:: python
12+
13+
pip install yunpian-python-sdk
14+
15+
****:
16+
master是最新稳定版,发布版本见\ `PyPI <https://pypi.python.org/pypi>`__
17+
18+
- 使用YunpianClient
19+
20+
.. code:: python
21+
22+
from yunpian_python_sdk.model import constant as YC
23+
from yunpian_python_sdk.ypclient import YunpianClient
24+
# 初始化client,apikey作为所有请求的默认值
25+
clnt = YunpianClient('apikey')
26+
param = {YC.MOBILE:'18616020***',YC.TEXT:'【云片网】您的验证码是1234'}
27+
r = clnt.sms().single_send(param)
28+
# 获取返回结果, 返回码:r.code(),返回码描述:r.msg(),API结果:r.data(),其他说明:r.detail(),调用异常:r.exception()
29+
# 短信:clnt.sms() 账户:clnt.user() 签名:clnt.sign() 模版:clnt.tpl() 语音:clnt.voice() 流量:clnt.flow()
30+
31+
****:
32+
v1.0.0不兼容之前版本\ `0.0.8 <https://github.com/yunpian/yunpian-python-sdk/releases/tag/0.0.8>`__
33+
34+
配置说明 (默认配置就行)
35+
-----------------------
36+
- 构造器配置
37+
38+
- ``YunpianClient('apikey')``
39+
- ``YunpianClient('apikey',conf)``,
40+
conf字典key详见model.constant.YP\_\*
41+
42+
- apikey的优先级:接口的param[APIKEY] > 构造器的apikey > 构造器的conf[YP\_APIKEY]
43+
44+
源码说明
45+
--------
46+
- 接口参数的apikey可以不传,因为所有接口默认传入`YunpianClient`构造时的apikey
47+
- 接口默认使用v2版本,可以在调用时指定版本,如\ ``clnt.sms().version('v1').single_send(param)``
48+
- API单元测试目录tests,支持tox
49+
- 分支说明: master是最新发布版本,develop是待发布的分支(开源贡献可以pull request到develop分支)
50+
51+
联系我们
52+
--------
53+
54+
`云片支持
55+
QQ <https://static.meiqia.com/dist/standalone.html?eid=30951&groupid=0d20ab23ab4702939552b3f81978012f&metadata=%7B%22name%22:%22github%22%7D>`__
56+
57+
SDK开源QQ群: 106469530
58+
59+
.. image:: docs/sdk_qq.jpeg
60+
:height: 60px
61+
:width: 60px
62+
:scale: 15%
63+
64+
文档链接
65+
--------
66+
67+
- `API文档 <https://www.yunpian.com/api2.0/guide.html>`__
68+
69+
可选SDK
70+
-------
71+
72+
- https://github.com/yunpian/sms/tree/master/yunpian/python/ypclient
73+
支持py2/3

README.md renamed to docs/README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,32 @@ from yunpian_python_sdk.model import constant as YC
1616
from yunpian_python_sdk.ypclient import YunpianClient
1717

1818
#初始化client,apikey作为所有请求的默认值
19-
clnt = YunpianClient('apikey');
19+
clnt = YunpianClient('apikey')
2020

21-
param = {YC.MOBILE:'18616020***',YC.TEXT:'【云片网】您的验证码是1234'};
22-
r = clnt.sms().single_send(param);
21+
param = {YC.MOBILE:'18616020***',YC.TEXT:'【云片网】您的验证码是1234'}
22+
r = clnt.sms().single_send(param)
2323
#获取返回结果, 返回码:r.code(), 返回码描述:r.msg(),API结果:r.data(),其他说明:r.detail(),调用异常:r.exception()
2424

2525
#短信:clnt.sms() 账户:clnt.user() 签名:clnt.sign() 模版:clnt.tpl() 语音:clnt.voice() 流量:clnt.flow()
2626
```
2727
****: v1.0.0不兼容之前版本[0.0.8](https://github.com/yunpian/yunpian-python-sdk/releases/tag/0.0.8)
2828

2929
## 配置说明 (默认配置就行)
30-
- 默认配置文件 yunpian_python_sdk/yunpian.ini
3130
- 构造器配置
3231
- `YunpianClient('apikey')`
3332
- `YunpianClient('apikey',conf)`, conf字典key详见model.constant.YP_*
3433
- apikey的优先级:接口的param[APIKEY] > 构造器的apikey > 构造器的conf[YP_APIKEY]
3534

3635
## 源码说明
36+
- 接口方法参数的apikey默认传入`YunpianClient`构造时的apikey
3737
- 接口默认使用v2版本,可以在调用时指定版本,如`clnt.sms().version('v1').single_send(param)`
3838
- API单元测试目录tests,支持tox.ini
3939
- 分支说明: master是最新发布版本,develop是待发布的分支(开源贡献可以pull request到develop分支)
4040

4141
## 联系我们
4242
[云片支持 QQ](https://static.meiqia.com/dist/standalone.html?eid=30951&groupid=0d20ab23ab4702939552b3f81978012f&metadata={"name":"github"})
4343

44-
SDK开源QQ群
44+
SDK开源QQ群: 106469530
4545

4646
<img src="docs/sdk_qq.jpeg" width="15%" alt="SDK开源QQ群"/>
4747

File renamed without changes.

setup.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from setuptools import find_packages, setup
99

1010

11-
with open(path.join(path.abspath(path.dirname(__file__)), 'README.md'), encoding='utf-8') as f:
11+
with open(path.join(path.abspath(path.dirname(__file__)), 'README.rst'), encoding='utf-8') as f:
1212
LONG_DESC = f.read()
1313

1414
KWARGS = dict(
@@ -30,7 +30,6 @@
3030
'Programming Language :: Python :: 2',
3131
'Programming Language :: Python :: 2.7',
3232
'Programming Language :: Python :: 3',
33-
'Programming Language :: Python :: 3.3',
3433
'Programming Language :: Python :: 3.4',
3534
'Programming Language :: Python :: 3.5',
3635
'Programming Language :: Python :: 3.6',

tests/test_ypclient.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44
55
@author: dzh
66
'''
7-
import sys
87
import unittest
98

109
import requests
11-
1210
from yunpian_python_sdk.model.constant import YP_VERSION, HTTP_CONN_TIMEOUT
1311
from yunpian_python_sdk.ypclient import _YunpianConf
1412

@@ -29,20 +27,21 @@ def test_YunpianConf(self):
2927
self.assertEqual(conf.conf(YP_VERSION), "v2")
3028
self.assertEqual(conf.conf(HTTP_CONN_TIMEOUT), "10")
3129

32-
def _test_uri(self):
30+
def test_uri(self):
3331
url = '{}/{}/{}/{}'.format('https://test-api.yunpian.com', 'v2', 'user', 'get.json')
3432
self.assertEqual('https://test-api.yunpian.com/v2/user/get.json', url)
3533

3634

3735
def _test_name(self):
38-
print(sys.modules[__name__])
36+
import sys
37+
self.assertEqual('tests.test_ypclient', sys.modules[__name__].__name__)
3938

4039
def _test_requests(self):
4140
r = requests.get('https://github.com/dzh')
42-
print(r.status_code)
41+
self.assertEqual(r.status_code, 200)
4342

4443
r = requests.get('https://www.yunpian.com/')
45-
print(r.status_code)
44+
self.assertEqual(r.status_code, 200)
4645

4746

4847
if __name__ == "__main__":

tests/testapi/__init__.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@
1111
from yunpian_python_sdk.ypclient import YunpianClient
1212

1313

14-
# from yunpian_python_sdk.model.constant import
1514
class TestYunpianApi(unittest.TestCase):
1615

17-
APIKEY = '2daab1114c69c9c41d1172b0ad8c392d'
16+
APIKEY = '******'
1817

1918
CONF = {YP_FLOW_HOST:'https://test-api.yunpian.com', YP_SIGN_HOST:'https://test-api.yunpian.com',
2019
YP_SMS_HOST:'https://test-api.yunpian.com', YP_TPL_HOST:'https://test-api.yunpian.com',

tests/testapi/test_flow.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
class TestFlowApi(TestYunpianApi):
1515
'''Test FlowApi'''
1616

17-
def _test_get_package(self):
17+
def test_get_package(self):
1818
clnt = self._clnt
1919

2020
r = clnt.flow().get_package()
@@ -24,7 +24,7 @@ def _test_get_package(self):
2424
r = clnt.flow().version(VERSION_V1).get_package()
2525
self.show(r)
2626

27-
def _test_recharge(self):
27+
def test_recharge(self):
2828
clnt = self._clnt
2929

3030
param = {MOBILE : '18616020000', SN : '1008601'}
@@ -35,7 +35,7 @@ def _test_recharge(self):
3535
r = clnt.flow().version(VERSION_V1).recharge(param)
3636
self.show(r)
3737

38-
def _test_pull_status(self):
38+
def test_pull_status(self):
3939
clnt = self._clnt
4040

4141
r = clnt.flow().pull_status()

tests/testapi/test_sign.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@ class TestSignApi(TestYunpianApi):
1616
'''Test SignApi'''
1717

1818

19-
def _test_add(self) :
19+
def test_add(self) :
2020
clnt = self._clnt
2121

2222
param = {SIGN:'你好吗', NOTIFY:'true', APPLYVIP:'false', ISONLYGLOBAL:'false', INDUSTRYTYPE:'其他'}
2323
r = clnt.sign().add(param)
2424
self.show(r)
2525

26-
def _test_update(self):
26+
def test_update(self):
2727
clnt = self._clnt
2828

2929
param = {OLD_SIGN :'你好吗', SIGN : '我很好', NOTIFY : 'true', APPLYVIP :'false',
3030
ISONLYGLOBAL: 'false', INDUSTRYTYPE: '其他'}
3131
r = clnt.sign().update(param)
3232
self.show(r)
3333

34-
def _test_get(self) :
34+
def test_get(self) :
3535
clnt = self._clnt
3636

3737
param = {PAGE_NUM : '1', PAGE_SIZE:"3"}

tests/testapi/test_sms.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -15,44 +15,44 @@
1515
class TestSmsApi(TestYunpianApi):
1616
'''Test SmsApi'''
1717

18-
def _test_single_send(self):
18+
def test_single_send(self):
1919
clnt = self._clnt;
2020

2121
param = {MOBILE:'18616020000', TEXT:'【云片网】您的验证码是1234'}
2222
r = clnt.sms().single_send(param)
2323
self.show(r)
2424

25-
def _test_batch_send(self):
25+
def test_batch_send(self):
2626
clnt = self._clnt
2727

2828
param = {MOBILE:'18616020000', TEXT:'【云片网】您的验证码是1234'}
2929
r = clnt.sms().batch_send(param)
3030
self.show(r)
3131

32-
def _test_multi_send(self):
32+
def test_multi_send(self):
3333
clnt = self._clnt
3434
param = {MOBILE : '18616020610,18616020611',
3535
TEXT: clnt.urlEncodeAndJoin(['【哈哈哈】您的验证码,是1234', '【哈哈哈】您的验证码是1234'])}
3636
r = clnt.sms().multi_send(param)
3737
self.show(r)
3838

3939
# deprecated
40-
def _test_tpl_single_send(self):
40+
def test_tpl_single_send(self):
4141
clnt = self._clnt
4242

4343
param = {MOBILE:'18616020000', TPL_ID:'1', TPL_VALUE:'#company#=云片网'}
4444
r = clnt.sms().tpl_single_send(param)
4545
self.show(r)
4646

4747
# deprecated
48-
def _test_tpl_batch_send(self):
48+
def test_tpl_batch_send(self):
4949
clnt = self._clnt;
5050

5151
param = {MOBILE :'18616020000', TPL_ID :'1', TPL_VALUE :'#company#=云片网'}
5252
r = clnt.sms().tpl_batch_send(param)
5353
self.show(r)
5454

55-
def _test_pull_status(self):
55+
def test_pull_status(self):
5656
clnt = self._clnt;
5757

5858
param = {PAGE_SIZE :'20'}
@@ -63,7 +63,7 @@ def _test_pull_status(self):
6363
r = clnt.sms().version(VERSION_V1).pull_status(param)
6464
self.show(r)
6565

66-
def _test_pull_reply(self):
66+
def test_pull_reply(self):
6767
clnt = self._clnt;
6868

6969
param = {PAGE_SIZE :'20'}
@@ -74,7 +74,7 @@ def _test_pull_reply(self):
7474
r = clnt.sms().version(VERSION_V1).pull_reply(param)
7575
self.show(r)
7676

77-
def _test_get_record(self):
77+
def test_get_record(self):
7878
clnt = self._clnt;
7979

8080
param = {START_TIME : '2013-08-11 00:00:00', END_TIME : '2016-12-05 00:00:00', PAGE_NUM : '1',
@@ -86,7 +86,7 @@ def _test_get_record(self):
8686
r = clnt.sms().version(VERSION_V1).get_record(param)
8787
self.show(r)
8888

89-
def _test_get_black_word(self):
89+
def test_get_black_word(self):
9090
clnt = self._clnt
9191

9292
param = {TEXT: '高利贷,发票'}
@@ -99,14 +99,14 @@ def _test_get_black_word(self):
9999

100100

101101
# deprecated
102-
def _test_send(self):
102+
def test_send(self):
103103
clnt = self._clnt
104104

105105
param = {MOBILE:'18616020000', TEXT : '【云片网】您的验证码是1234'}
106106
r = clnt.sms().version(VERSION_V1).send(param)
107107
self.show(r)
108108

109-
def _test_get_reply(self):
109+
def test_get_reply(self):
110110
clnt = self._clnt
111111

112112
param = {START_TIME: '2013-08-11 00:00:00', END_TIME : '2016-12-05 00:00:00', PAGE_NUM : '1',
@@ -119,14 +119,14 @@ def _test_get_reply(self):
119119
self.show(r)
120120

121121
# deprecated
122-
def _test_tpl_send(self):
122+
def test_tpl_send(self):
123123
clnt = self._clnt
124124

125125
param = {MOBILE : '18616020000', TPL_ID : '1', TPL_VALUE :'#company#=云片网'}
126126
r = clnt.sms().version(VERSION_V1).tpl_send(param)
127127
self.show(r)
128128

129-
def _test_count(self):
129+
def test_count(self):
130130
clnt = self._clnt;
131131

132132
param = {START_TIME : '2013-08-11 00:00:00', END_TIME :'2016-12-05 00:00:00', PAGE_NUM : '1',

0 commit comments

Comments
 (0)