44from telesignenterprise .constants import SOURCE_SDK
55import telesignenterprise
66import telesign
7+ import requests , json , base64
78
89BASE_URL_VERIFY_API = "https://verify.telesign.com"
910PATH_VERIFICATION_CREATE = "/verification"
1011PATH_VERIFICATION_RETRIEVE = "/verification/{reference_id}"
12+ PATH_VERIFICATION_UPDATE = "/verification/{reference_id}/state"
1113
1214class OmniVerify (RestClient ):
1315 """
@@ -48,11 +50,51 @@ def getVerificationProcess(self, reference_id, params={}):
4850 """
4951 Retrieve details about the specified verification process.
5052
53+ See https://developer.telesign.com/enterprise/reference/getverificationprocess for detailed API documentation.
54+
5155 :param reference_id: The unique identifier of the verification process.
5256 :param params: Optional query parameters as a dictionary.
5357 :return: Response object from the GET request.
5458 """
5559 endpoint = PATH_VERIFICATION_RETRIEVE .format (reference_id = reference_id )
5660 headers = {"Content-Type" : "application/json" , "Accept" : "application/json" }
5761
58- return self .get (endpoint , json_fields = params , headers = headers )
62+ return self .get (endpoint , json_fields = params , headers = headers )
63+
64+ def updateVerificationProcess (self , reference_id , params , use_basic_auth = False ):
65+ """
66+ Update a verification process.
67+
68+ See https://developer.telesign.com/enterprise/reference/updateverificationprocess for detailed API documentation.
69+
70+ :param reference_id: The unique identifier of the verification process.
71+ :param params: Dictionary of parameters for the update (must include 'action' and 'security_factor').
72+ :param use_basic_auth: Boolean indicating whether to use manual Basic Auth.
73+ :return: Response object.
74+ """
75+ endpoint_path = PATH_VERIFICATION_UPDATE .format (reference_id = reference_id )
76+
77+ if use_basic_auth :
78+ endpoint = self .api_host .rstrip ('/' ) + endpoint_path
79+
80+ json_body = json .dumps (params )
81+
82+ auth_str = f"{ self .customer_id } :{ self .api_key } "
83+ auth_bytes = auth_str .encode ('utf-8' )
84+ auth_b64 = base64 .b64encode (auth_bytes ).decode ('utf-8' )
85+ headers = {
86+ "Authorization" : f"Basic { auth_b64 } " ,
87+ "Content-Type" : "application/json" ,
88+ "Accept" : "application/json"
89+ }
90+ response = requests .patch (endpoint , data = json_body , headers = headers )
91+ return type ('Response' , (), {
92+ 'status_code' : response .status_code ,
93+ 'headers' : response .headers ,
94+ 'body' : response .text ,
95+ 'ok' : response .ok ,
96+ 'json' : response .json
97+ })()
98+ else :
99+ headers = {"Content-Type" : "application/json" , "Accept" : "application/json" }
100+ return self .patch (endpoint_path , json_fields = params , headers = headers )
0 commit comments