From 6a26cef6078b6101755443973be1350f0ea8bb21 Mon Sep 17 00:00:00 2001 From: Priyesh Jain Date: Tue, 28 Aug 2018 10:15:28 -0700 Subject: [PATCH 1/2] Adding intermediate status look up for App Verify API --- examples/app_verify/1_initiate_and_finalize.py | 6 ++++++ .../2_initiate_and_finalize_with_verify_code.py | 2 ++ telesignenterprise/appverify.py | 11 +++++++++++ 3 files changed, 19 insertions(+) diff --git a/examples/app_verify/1_initiate_and_finalize.py b/examples/app_verify/1_initiate_and_finalize.py index 4e17189..bd7a203 100644 --- a/examples/app_verify/1_initiate_and_finalize.py +++ b/examples/app_verify/1_initiate_and_finalize.py @@ -8,10 +8,16 @@ verify = AppVerifyClient(customer_id, api_key) +# Initiate App Verify Call initiate_response = verify.initiate(phone_number) print("initiate response: {}\n".format(initiate_response.json)) +# Get intermediate call status to trigger a failure or retry quickly on the mobile app reference_id = initiate_response.json['reference_id'] +status_response = verify.status(reference_id) +print("initiate response: {}\n".format(status_response.json)) + +# Finalize App Verify Transaction verify_code = raw_input("Please enter the verification code from the caller id: ") finalize_response = verify.finalize(reference_id, verify_code=verify_code) print("\nfinalize response: {}\n".format(finalize_response.json)) diff --git a/examples/app_verify/2_initiate_and_finalize_with_verify_code.py b/examples/app_verify/2_initiate_and_finalize_with_verify_code.py index 60e5cbb..03cab28 100644 --- a/examples/app_verify/2_initiate_and_finalize_with_verify_code.py +++ b/examples/app_verify/2_initiate_and_finalize_with_verify_code.py @@ -8,10 +8,12 @@ verify = AppVerifyClient(customer_id, api_key) +# Initiate App Verify Call verify_code = raw_input("Please enter the verification code for initiate: ") initiate_response = verify.initiate(phone_number, verify_code=verify_code) print("initiate response: {}\n".format(initiate_response.json)) +# Finalize App Verify transaction reference_id = initiate_response.json['reference_id'] verify_code = raw_input("Please enter the verification code from the caller id: ") finalize_response = verify.finalize(reference_id, verify_code=verify_code) diff --git a/telesignenterprise/appverify.py b/telesignenterprise/appverify.py index 437c9a6..39d05c1 100644 --- a/telesignenterprise/appverify.py +++ b/telesignenterprise/appverify.py @@ -5,6 +5,7 @@ APP_VERIFY_INITIATE_RESOURCE = '/v1/verify/auto/voice/initiate' APP_VERIFY_FINALIZE_RESOURCE = '/v1/verify/auto/voice/finalize' +APP_VERIFY_STATUS_RESOURCE = '/v1/verify/auto/voice/{}' class AppVerifyClient(_AppVerifyClient): @@ -39,3 +40,13 @@ def finalize(self, reference_id, **params): return self.post(APP_VERIFY_FINALIZE_RESOURCE, reference_id=reference_id, **params) + + def status(self, reference_id, **params): + """ + TeleSign looks up the status for the verification call in the + Initiate request to determine status of the AV call, including + intermediate call status such as call failed, or retry. + + See https://enterprise.telesign.com/docs/app-verify-api for detailed API documentation. + """ + return self.get(APP_VERIFY_STATUS_RESOURCE.format(reference_id), **params) From 19168943ed1675cfd0f801bdbc033026eb89fefe Mon Sep 17 00:00:00 2001 From: Priyesh Jain Date: Thu, 30 Aug 2018 14:31:50 -0700 Subject: [PATCH 2/2] Updating the version number and RELEASE doc --- RELEASE | 3 +++ setup.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/RELEASE b/RELEASE index cb09003..62a6b17 100644 --- a/RELEASE +++ b/RELEASE @@ -1,3 +1,6 @@ +2.1.4 +- Added status method to AppVerifyClient + 2.1.3 - Added AppVerifyClient diff --git a/setup.py b/setup.py index 96f3d43..c1fa855 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup, find_packages -version = "2.1.3" +version = "2.1.4" try: with open("README") as f: