def find_jobs(client, query): zeep_client = Zeep(f"{client.base_url}{endpoint}") response = zeep_client.service.FindJobs( _soapheaders=[client.session_header], query=query) return response['Results']
def authenticate(client): login_header = { 'UserName': client.username, 'Password': client.password, 'ClientAccessKey': client.client_access_key, 'UserAccessKey': client.user_access_key, } # Log in and get session token zeep_client = Zeep(f"{client.base_url}{endpoint}") result = zeep_client.service.Authenticate(_soapheaders=login_header) client.token = result['Token'] # Create xsd ComplexType header - http://docs.python-zeep.org/en/master/headers.html header = xsd.ComplexType([ xsd.Element( '{http://www.ultimatesoftware.com/foundation/authentication/ultiprotoken}UltiProToken', xsd.String()), xsd.Element( '{http://www.ultimatesoftware.com/foundation/authentication/clientaccesskey}ClientAccessKey', xsd.String()), ]) # Add authenticated header to client object client.session_header = header(UltiProToken=client.token, ClientAccessKey=client.client_access_key)
def __init__(self, timeout=None): self.client = Zeep( wsdl=self.url, transport=Transport(cache=InMemoryCache()), ) if timeout is not None: self.client.operation_timeout = self.client.timeout = timeout
def find_terminations(client, query): logging.info("SOAP endpoint: {0}{1}".format(client.base_url, endpoint)) zeep_client = Zeep("{0}{1}".format(client.base_url, endpoint)) response = zeep_client.service.FindTerminations( _soapheaders=[client.session_header], query=query) return response['Results']
def get_person_by_employee_identifier(client, employee_identifier): zeep_client = Zeep(f"{client.base_url}{endpoint}") if 'EmployeeNumber' in employee_identifier: element = zeep_client.get_element('ns6:EmployeeNumberIdentifier') obj = element(**employee_identifier) elif 'EmailAddress' in employee_identifier: element = zeep_client.get_element('ns6:EmailAddressIdentifier') obj = element(**employee_identifier) response = zeep_client.service.GetPersonByEmployeeIdentifier( _soapheaders=[client.session_header], employeeIdentifier=obj) return response['Results']
def get_termination_by_employee_identifier(client, employee_identifier): zeep_client = Zeep("{0}{1}".format(client.base_url, endpoint)) if 'EmployeeNumber' in employee_identifier: element = zeep_client.get_element('ns6:EmployeeNumberIdentifier') obj = element(**employee_identifier) elif 'EmailAddress' in employee_identifier: element = zeep_client.get_element('ns6:EmailAddressIdentifier') obj = element(**employee_identifier) response = zeep_client.service.GetTerminationByEmployeeIdentifier( _soapheaders=[client.session_header], employeeIdentifier=obj) return response['Results']
def find_employment_informations(client, query): zeep_client = Zeep(f"{client.base_url}{endpoint}") response = zeep_client.service.FindEmploymentInformations( _soapheaders=[client.session_header], query=query) return response['Results']
def __init__(self, wsdl: str, api_key: str) -> None: self._zeep = Zeep(wsdl) self.api_key = api_key
def service(self): if not hasattr(self, "_service"): client = Zeep(wsdl=self.wsdl, transport=Transport(cache=InMemoryCache())) self._service = client.service return self._service