Package: tangier_api
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      8888888DescriptionA simple Python package to facilitate interactions with Tangier’s SOAP API.OverviewTangier API is a client library for using Python to interact with the Tangier’s SOAP API.Here, we will only be discussing methods that allow the user to perform queries from the API.
All of the necessary methods to Create and Update via the API are also available in this library, but they will not be
covered here.You can check the API documentation for more information on those methods.Installationto install the latest version, you can just runpipinstalltangier-apiSetupYou will need to have an active API account for Tangier and a config file that looks like the below[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 =You can store this file anywhere, but you need to make its location known to the interpreter that calls the API via the
environment variableTANGIER_CONF_FILE.UsageLogging Inimportosos.environ['TANGIER_CONF_FILE']='C:/path/to/tangier_api.conf'fromtangier_apiimportProviderConnection,LocationConnection,ScheduleConnectionpconn=ProviderConnection()lconn=LocationConnection()sconn=ScheduleConnection()That’s it. You have three authenticated clients, one for each of these services.Raw API CallsEach of the above classes, ProviderConnection, LocationConnection, ScheduleConnection, im-
plement a direct connection to Tangier’s SOAP endpoints. That means you could just use raw
XML if you really wanted to. For example: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)This should make it fairly simple for you to write your own custom API calls if necessary.Get Schedulesconn=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'])Provider Maintenancepconn=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,)Location Maintenancelconn=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()I am not going to demonstrate any of the below, but you can see them in theAPI documentationif necessary.lconn.add_locationlconn.update_locationlconn.delete_location