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"
@@ -49,7 +50,7 @@ def getVerificationProcess(self, reference_id, params={}):
4950 """
5051 Retrieve details about the specified verification process.
5152
52- See https://developer.telesign.com/enterprise/reference/getverificationprocess or detailed API documentation.
53+ See https://developer.telesign.com/enterprise/reference/getverificationprocess for detailed API documentation.
5354
5455 :param reference_id: The unique identifier of the verification process.
5556 :param params: Optional query parameters as a dictionary.
@@ -60,16 +61,40 @@ def getVerificationProcess(self, reference_id, params={}):
6061
6162 return self .get (endpoint , json_fields = params , headers = headers )
6263
63- def updateVerificationProcess (self , reference_id , params ):
64+ def updateVerificationProcess (self , reference_id , params , use_basic_auth = False ):
6465 """
65- Update a verification process
66+ Update a verification process.
6667
6768 See https://developer.telesign.com/enterprise/reference/updateverificationprocess for detailed API documentation.
6869
6970 :param reference_id: The unique identifier of the verification process.
7071 :param params: Dictionary of parameters for the update (must include 'action' and 'security_factor').
71- :return: Response object from the PATCH request.
72+ :param use_basic_auth: Boolean indicating whether to use manual Basic Auth.
73+ :return: Response object.
7274 """
73- endpoint = PATH_VERIFICATION_UPDATE .format (reference_id = reference_id )
74- headers = {"Content-Type" : "application/json" , "Accept" : "application/json" }
75- return self .patch (endpoint , json_fields = params , headers = headers )
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