用于访问Freshsales的Python SDK
freshsalessdk的Python项目详细描述
freshsales sdk副本
用于访问Freshsales的非官方Python SDK。在
Warning:这项工作正在积极发展中,一旦情况稍有稳定,我们将接受捐款。在
安装
- 下载并使用此项目(复制到您的项目中,等等)。在
- 从pip安装它。在
pip install freshsalessdk
使用
要使用这个SDK,您需要这些Freshsales凭据和您的Freshsales域(https://domain.freshsales.io)。有关步骤,请参见official documentation。我们假设这些可以通过环境变量获得:
^{pr2}$下面的代码片段向您展示了如何初始化和使用SDK。在
fromfreshsalessdkimportFreshsalesSDKimportosfs=FreshsalesSDK(domain=os.getenv('FS_DOMAIN'),api_key=os.getenv('FS_API_KEY'))# get contact viewsviews=fs.contacts.get_views()# get contacts in a viewview_id=123contacts=fs.contacts.get_all(view_id=view_id)contacts=list(fs.contacts.get_all_generator(view_id=view_id))# get specific contactcontact_id=1232contact=fs.contacts.get(id=contact_id)# get contact activitiesactivities=fs.contacts.get_activities(id=contact_id)# get account viewsviews=fs.accounts.get_views()# get accounts in a viewview_id=123accounts=fs.accounts.get_all(view_id=view_id)accounts=list(fs.accounts.get_all_generator(view_id=view_id))# get one accountaccount_id=1221account=fs.accounts.get(id=account_id)# get deal viewsviews=fs.deals.get_views()# get deals in a viewview_id=1212deals=fs.deals.get_all(view_id=view_id)deals=list(fs.deals.get_all_generator(view_id=view_id))# get single dealdeal_id=12121deal=fs.deals.get(id=deal_id)
代码卫生、测试和代码覆盖率
要确保遵循编码样式,请运行以下命令:
pylint --rcfile=.pylintrc freshsalessdk test
要运行集成测试,您需要设置FS_DOMAIN和FS_API_KEY环境变量。另外,你应该 一个视图,其中包含联系人的所有对象“all Contacts”,类似地“all Accounts”用于Accounts,以及“all Deals”用于Deals。然后简单地运行:
python -m pytest
要获得代码覆盖率,请立即运行测试。在
python -m pytest --cov=freshsalessdk
产生如下输出:
---------- coverage: platform darwin, python 3.7.4-final-0 -----------
Name Stmts Miss Cover
----------------------------------------------------
freshsalessdk/__init__.py 3 0 100%
freshsalessdk/freshsalessdk.py 130 6 95%
----------------------------------------------------
TOTAL 133 6 95%
我们希望保持90%以上的代码覆盖率。要在测试期间获取大量调试数据,请编辑pytest.ini文件文件。在
要获取HTML格式的代码覆盖率报告,请运行以下命令:
python -m pytest --cov=freshsalessdk --cov-report html:cov_html
许可证
这个项目是在麻省理工学院许可下授权的-有关详细信息,请参阅LICENSE文件
- 项目
标签: