一个简单的python包,用于促进与tangier的api的交互

tangier_api的Python项目详细描述


88888888888    d8888888b    888 .d8888b. 888888888888888888888888b.                d88888888888b.8888888
    888       d888888888b   888d88P  Y88b  888  888       888   Y88b              d88888888   Y88b 888
    888      d88P88888888b  888888    888  888  888       888    888             d88P888888    888 888
    888     d88P 888888Y88b 888888         888  8888888   888   d88P            d88P 888888   d88P 888
    888    d88P  888888 Y88b888888  88888  888  888       8888888P"            d88P  8888888888P"  888
    888   d88P   888888  Y88888888    888  888  888       888 T88b            d88P   888888        888
    888  d8888888888888   Y8888Y88b  d88P  888  888       888  T88b          d8888888888888        888
    888 d88P     888888    Y888 "Y8888P8888888888888888888888   T88b88888888d88P     888888      8888888

说明

一个简单的python包,用于促进与tangier的soap api的交互。

概述

tangier api是一个客户端库,用于使用python与tangier的soap api交互。

这里,我们只讨论允许用户从api执行查询的方法。 通过api创建和更新所需的所有方法都可以在这个库中找到,但是它们不会 在这里。

有关这些方法的更多信息,可以查看api文档。

安装

要安装最新版本,只需运行

pip install tangier-api

设置

您需要有一个用于tangier的活动api帐户和一个如下所示的配置文件

[tangier]
username = api_user
password = api_password
schedule_endpoint = https://tangierweb.com/webservices/schedulerequest/schedulerequest.asmx?WSDL
provider_endpoint = https://tangierweb.com/webservices/ProviderMaintenance/ProviderMaintenance.asmx?WSDL
location_endpoint = https://tangierweb.com/webservices/LocationMaintenance/LocationMaintenance.asmx?WSDL
testing_site = TESTING-SITE-ID
testing_npi = 0000000000
log_dir =

您可以将此文件存储在任何地方,但您需要让通过 环境变量TANGIER_CONF_FILE

用法

登录

importosos.environ['TANGIER_CONF_FILE']='C:/path/to/tangier_api.conf'fromtangier_apiimportProviderConnection,LocationConnection,ScheduleConnectionpconn=ProviderConnection()lconn=LocationConnection()sconn=ScheduleConnection()

就这样。您有三个经过身份验证的客户机,每种服务一个。

原始api调用

上面的每个类,providerconnection,locationconnection,scheduleConnection,im- 直接连接到丹吉尔的soap端点。也就是说你可以用生的 如果你真的想的话。例如:

fromtangier_apiimportsettingsimportxmlmaniplconn=LocationConnection()xml="""
    <tangier version="1.0" method="location.request">
        <admin_user>{username}</admin_user>
        <admin_pwd>{password}</admin_pwd>
        <locations>
            <location action="info">
                <site_id>{site_id}</site_id>
            </location>
        </locations>
    </tangier>
""".format(username=settings.TANGIER_USERNAME,password=settings.TANGIER_PASSWORD,site_id="YOUR-SITE-ID")response_xml=lconn.MaintainLocations(xml)xmlmanip.print_xml(response_xml)

这将使您在必要时编写自己的自定义api调用变得相当简单。

获取日程

sconn=ScheduleConnection()# you can do this by emp_id or site_idresponse_xml=sconn.get_schedule(start_date='2018-01-01',end_date='2018-01-14',site_id='YOUR-SITE-ID')# returns a list of xml strings, used in other methodsresponse_xml_list=sconn.get_schedules(start_date='2018-01-01',end_date='2018-01-14',site_ids=['YOUR-SITE-ID'])# list of all of the shifts between the given dates for the given site idsscheduled_shifts=sconn.get_schedule_values_list(start_date='2018-01-01',end_date='2018-01-14',site_ids=['YOUR-SITE-ID','YOUR-SITE-ID-2'])

供应商维护

pconn=ProviderConnection()# returns xml corresponding to providers in Tangier with Primary Key in their Database of 1 and 2response_xml=pconn.get_provider_info(# do not include this variable if you want all_providersprovider_ids=[1,2],# you should just use this all the timeuse_primary_keys=True,# bug, this field shouldn't be needed to prevent fetching of all but it isall_providers=False,)# wrapper around get_provider_info that returns a list of dicts instead of raw xmlprovider_list=pconn.provider_info_values_list(# do not include this variable if you want all_providersprovider_ids=[1,2],# you should just use this all the timeuse_primary_keys=True,# bug, this field shouldn't be needed to prevent fetching of all but it isall_providers=False,)

位置维护

lconn=LocationConnection()response_xml=lconn.get_locations_info(# do not include variable if you want all sitessite_ids=['CRMC-APP'])# no arguments means all sites in a listlocation_list=lconn.location_info_values_list()

我不打算演示下面的任何内容,但您可以在 API documentation如有必要。

lconn.add_locationlconn.update_locationlconn.delete_location

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Linux的java字符串命令   java parseInt和viewflipper布局问题   java正则表达式来平衡括号   mysql与数据库的Java连接   java将JFreeChart系列名称映射到系列索引   多线程如何使用信号量在Java中对哲学家进行编码?   oop特殊变量“this”如何准确地知道在JAVA程序中引用哪个对象?   Android上的java getType   当前值/单元格POI上的java Excel公式   代码中有错误(java.awt.image.RasterFormatException)   java改造2,参数转换   未找到java JSF 2 Ajax属性   JAVArmi。服务器在OpenJDK 8中,useCodebaseOnly默认为true   java如何用final实现静态?   对付Java语法冗长的最佳IDE宏工具?   java@Transactional不回滚