From 9671e67fb0fc259cbca488da13f66c211aab8902 Mon Sep 17 00:00:00 2001 From: Alvaro Navarro Date: Fri, 20 Mar 2026 15:31:15 +0100 Subject: [PATCH 1/3] feat: add identity insights code snippets --- .env.dist | 5 +++ identity-insights/get-all-insights.py | 45 +++++++++++++++++++++++ identity-insights/get-current-carrier.py | 37 +++++++++++++++++++ identity-insights/get-format-insight.py | 37 +++++++++++++++++++ identity-insights/get-original-carrier.py | 37 +++++++++++++++++++ identity-insights/get-sim-swap.py | 39 ++++++++++++++++++++ 6 files changed, 200 insertions(+) create mode 100644 identity-insights/get-all-insights.py create mode 100644 identity-insights/get-current-carrier.py create mode 100644 identity-insights/get-format-insight.py create mode 100644 identity-insights/get-original-carrier.py create mode 100644 identity-insights/get-sim-swap.py diff --git a/.env.dist b/.env.dist index 5c60548..0116c4e 100644 --- a/.env.dist +++ b/.env.dist @@ -45,6 +45,11 @@ MESSAGES_EMOJI='MESSAGES_EMOJI' WHATSAPP_STICKER_ID='WHATSAPP_STICKER_ID' WHATSAPP_STICKER_URL='WHATSAPP_STICKER_URL' +# Identity Insights +IDENTITY_INSIGHTS_NUMBER='IDENTITY_INSIGHTS_NUMBER' +IDENTITY_INSIGHTS_PURPOSE='IDENTITY_INSIGHTS_PURPOSE' +IDENTITY_INSIGHTS_API_HOST='api-eu.vonage.com' + # NI INSIGHT_NUMBER='INSIGHT_NUMBER' INSIGHT_CALLBACK_URL='INSIGHT_CALLBACK_URL' diff --git a/identity-insights/get-all-insights.py b/identity-insights/get-all-insights.py new file mode 100644 index 0000000..aba9789 --- /dev/null +++ b/identity-insights/get-all-insights.py @@ -0,0 +1,45 @@ +import os +from os.path import dirname, join +from pprint import pprint + +from dotenv import load_dotenv + +dotenv_path = join(dirname(__file__), "../.env") +load_dotenv(dotenv_path) + +VONAGE_APPLICATION_ID = os.environ.get("VONAGE_APPLICATION_ID") +VONAGE_PRIVATE_KEY = os.environ.get("VONAGE_PRIVATE_KEY") +IDENTITY_INSIGHTS_NUMBER = os.environ.get("IDENTITY_INSIGHTS_NUMBER") +IDENTITY_INSIGHTS_PURPOSE = os.environ.get("IDENTITY_INSIGHTS_PURPOSE") +IDENTITY_INSIGHTS_API_HOST = os.environ.get("IDENTITY_INSIGHTS_API_HOST") + +from vonage import Auth, HttpClientOptions, Vonage +from vonage_identity_insights import ( + EmptyInsight, + IdentityInsightsRequest, + IdentityInsightsResponse, + InsightsRequest, + SimSwapInsight, +) + +client = Vonage( + auth=Auth( + application_id=VONAGE_APPLICATION_ID, + private_key=VONAGE_PRIVATE_KEY, + ), + http_client_options=HttpClientOptions(api_host=IDENTITY_INSIGHTS_API_HOST), +) + +request = IdentityInsightsRequest( + phone_number=IDENTITY_INSIGHTS_NUMBER, + purpose=IDENTITY_INSIGHTS_PURPOSE, + insights=InsightsRequest( + format=EmptyInsight(), + sim_swap=SimSwapInsight(period=240), + original_carrier=EmptyInsight(), + current_carrier=EmptyInsight(), + ), +) + +response: IdentityInsightsResponse = client.identity_insights.requests(request) +pprint(response) diff --git a/identity-insights/get-current-carrier.py b/identity-insights/get-current-carrier.py new file mode 100644 index 0000000..891d496 --- /dev/null +++ b/identity-insights/get-current-carrier.py @@ -0,0 +1,37 @@ +import os +from os.path import dirname, join +from pprint import pprint + +from dotenv import load_dotenv + +dotenv_path = join(dirname(__file__), "../.env") +load_dotenv(dotenv_path) + +VONAGE_APPLICATION_ID = os.environ.get("VONAGE_APPLICATION_ID") +VONAGE_PRIVATE_KEY = os.environ.get("VONAGE_PRIVATE_KEY") +IDENTITY_INSIGHTS_NUMBER = os.environ.get("IDENTITY_INSIGHTS_NUMBER") +IDENTITY_INSIGHTS_API_HOST = os.environ.get("IDENTITY_INSIGHTS_API_HOST") + +from vonage import Auth, HttpClientOptions, Vonage +from vonage_identity_insights import ( + EmptyInsight, + IdentityInsightsRequest, + IdentityInsightsResponse, + InsightsRequest, +) + +client = Vonage( + auth=Auth( + application_id=VONAGE_APPLICATION_ID, + private_key=VONAGE_PRIVATE_KEY, + ), + http_client_options=HttpClientOptions(api_host=IDENTITY_INSIGHTS_API_HOST), +) + +request = IdentityInsightsRequest( + phone_number=IDENTITY_INSIGHTS_NUMBER, + insights=InsightsRequest(current_carrier=EmptyInsight()), +) + +response: IdentityInsightsResponse = client.identity_insights.requests(request) +pprint(response) diff --git a/identity-insights/get-format-insight.py b/identity-insights/get-format-insight.py new file mode 100644 index 0000000..cfac28c --- /dev/null +++ b/identity-insights/get-format-insight.py @@ -0,0 +1,37 @@ +import os +from os.path import dirname, join +from pprint import pprint + +from dotenv import load_dotenv + +dotenv_path = join(dirname(__file__), "../.env") +load_dotenv(dotenv_path) + +VONAGE_APPLICATION_ID = os.environ.get("VONAGE_APPLICATION_ID") +VONAGE_PRIVATE_KEY = os.environ.get("VONAGE_PRIVATE_KEY") +IDENTITY_INSIGHTS_NUMBER = os.environ.get("IDENTITY_INSIGHTS_NUMBER") +IDENTITY_INSIGHTS_API_HOST = os.environ.get("IDENTITY_INSIGHTS_API_HOST") + +from vonage import Auth, HttpClientOptions, Vonage +from vonage_identity_insights import ( + EmptyInsight, + IdentityInsightsRequest, + IdentityInsightsResponse, + InsightsRequest, +) + +client = Vonage( + auth=Auth( + application_id=VONAGE_APPLICATION_ID, + private_key=VONAGE_PRIVATE_KEY, + ), + http_client_options=HttpClientOptions(api_host=IDENTITY_INSIGHTS_API_HOST), +) + +request = IdentityInsightsRequest( + phone_number=IDENTITY_INSIGHTS_NUMBER, + insights=InsightsRequest(format=EmptyInsight()), +) + +response: IdentityInsightsResponse = client.identity_insights.requests(request) +pprint(response) diff --git a/identity-insights/get-original-carrier.py b/identity-insights/get-original-carrier.py new file mode 100644 index 0000000..2099050 --- /dev/null +++ b/identity-insights/get-original-carrier.py @@ -0,0 +1,37 @@ +import os +from os.path import dirname, join +from pprint import pprint + +from dotenv import load_dotenv + +dotenv_path = join(dirname(__file__), "../.env") +load_dotenv(dotenv_path) + +VONAGE_APPLICATION_ID = os.environ.get("VONAGE_APPLICATION_ID") +VONAGE_PRIVATE_KEY = os.environ.get("VONAGE_PRIVATE_KEY") +IDENTITY_INSIGHTS_NUMBER = os.environ.get("IDENTITY_INSIGHTS_NUMBER") +IDENTITY_INSIGHTS_API_HOST = os.environ.get("IDENTITY_INSIGHTS_API_HOST") + +from vonage import Auth, HttpClientOptions, Vonage +from vonage_identity_insights import ( + EmptyInsight, + IdentityInsightsRequest, + IdentityInsightsResponse, + InsightsRequest, +) + +client = Vonage( + auth=Auth( + application_id=VONAGE_APPLICATION_ID, + private_key=VONAGE_PRIVATE_KEY, + ), + http_client_options=HttpClientOptions(api_host=IDENTITY_INSIGHTS_API_HOST), +) + +request = IdentityInsightsRequest( + phone_number=IDENTITY_INSIGHTS_NUMBER, + insights=InsightsRequest(original_carrier=EmptyInsight()), +) + +response: IdentityInsightsResponse = client.identity_insights.requests(request) +pprint(response) diff --git a/identity-insights/get-sim-swap.py b/identity-insights/get-sim-swap.py new file mode 100644 index 0000000..89b7cc4 --- /dev/null +++ b/identity-insights/get-sim-swap.py @@ -0,0 +1,39 @@ +import os +from os.path import dirname, join +from pprint import pprint + +from dotenv import load_dotenv + +dotenv_path = join(dirname(__file__), "../.env") +load_dotenv(dotenv_path) + +VONAGE_APPLICATION_ID = os.environ.get("VONAGE_APPLICATION_ID") +VONAGE_PRIVATE_KEY = os.environ.get("VONAGE_PRIVATE_KEY") +IDENTITY_INSIGHTS_NUMBER = os.environ.get("IDENTITY_INSIGHTS_NUMBER") +IDENTITY_INSIGHTS_PURPOSE = os.environ.get("IDENTITY_INSIGHTS_PURPOSE") +IDENTITY_INSIGHTS_API_HOST = os.environ.get("IDENTITY_INSIGHTS_API_HOST") + +from vonage import Auth, HttpClientOptions, Vonage +from vonage_identity_insights import ( + IdentityInsightsRequest, + IdentityInsightsResponse, + InsightsRequest, + SimSwapInsight, +) + +client = Vonage( + auth=Auth( + application_id=VONAGE_APPLICATION_ID, + private_key=VONAGE_PRIVATE_KEY, + ), + http_client_options=HttpClientOptions(api_host=IDENTITY_INSIGHTS_API_HOST), +) + +request = IdentityInsightsRequest( + phone_number=IDENTITY_INSIGHTS_NUMBER, + purpose=IDENTITY_INSIGHTS_PURPOSE, + insights=InsightsRequest(sim_swap=SimSwapInsight(period=240)), +) + +response: IdentityInsightsResponse = client.identity_insights.requests(request) +pprint(response) From bdcdffa902eaa4b9abca0799df363153a9ebd0fc Mon Sep 17 00:00:00 2001 From: superchilled Date: Thu, 25 Jun 2026 12:14:38 +0100 Subject: [PATCH 2/3] Updating INSIGHT_NUMBER var name in line with snippet specs --- .env.dist | 2 +- identity-insights/get-all-insights.py | 4 ++-- identity-insights/get-current-carrier.py | 4 ++-- identity-insights/get-format-insight.py | 4 ++-- identity-insights/get-original-carrier.py | 4 ++-- identity-insights/get-sim-swap.py | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.env.dist b/.env.dist index 0116c4e..80d96df 100644 --- a/.env.dist +++ b/.env.dist @@ -46,7 +46,7 @@ WHATSAPP_STICKER_ID='WHATSAPP_STICKER_ID' WHATSAPP_STICKER_URL='WHATSAPP_STICKER_URL' # Identity Insights -IDENTITY_INSIGHTS_NUMBER='IDENTITY_INSIGHTS_NUMBER' +INSIGHT_NUMBER='INSIGHT_NUMBER' IDENTITY_INSIGHTS_PURPOSE='IDENTITY_INSIGHTS_PURPOSE' IDENTITY_INSIGHTS_API_HOST='api-eu.vonage.com' diff --git a/identity-insights/get-all-insights.py b/identity-insights/get-all-insights.py index aba9789..33ad878 100644 --- a/identity-insights/get-all-insights.py +++ b/identity-insights/get-all-insights.py @@ -9,7 +9,7 @@ VONAGE_APPLICATION_ID = os.environ.get("VONAGE_APPLICATION_ID") VONAGE_PRIVATE_KEY = os.environ.get("VONAGE_PRIVATE_KEY") -IDENTITY_INSIGHTS_NUMBER = os.environ.get("IDENTITY_INSIGHTS_NUMBER") +INSIGHT_NUMBER = os.environ.get("INSIGHT_NUMBER") IDENTITY_INSIGHTS_PURPOSE = os.environ.get("IDENTITY_INSIGHTS_PURPOSE") IDENTITY_INSIGHTS_API_HOST = os.environ.get("IDENTITY_INSIGHTS_API_HOST") @@ -31,7 +31,7 @@ ) request = IdentityInsightsRequest( - phone_number=IDENTITY_INSIGHTS_NUMBER, + phone_number=INSIGHT_NUMBER, purpose=IDENTITY_INSIGHTS_PURPOSE, insights=InsightsRequest( format=EmptyInsight(), diff --git a/identity-insights/get-current-carrier.py b/identity-insights/get-current-carrier.py index 891d496..76c4f44 100644 --- a/identity-insights/get-current-carrier.py +++ b/identity-insights/get-current-carrier.py @@ -9,7 +9,7 @@ VONAGE_APPLICATION_ID = os.environ.get("VONAGE_APPLICATION_ID") VONAGE_PRIVATE_KEY = os.environ.get("VONAGE_PRIVATE_KEY") -IDENTITY_INSIGHTS_NUMBER = os.environ.get("IDENTITY_INSIGHTS_NUMBER") +INSIGHT_NUMBER = os.environ.get("INSIGHT_NUMBER") IDENTITY_INSIGHTS_API_HOST = os.environ.get("IDENTITY_INSIGHTS_API_HOST") from vonage import Auth, HttpClientOptions, Vonage @@ -29,7 +29,7 @@ ) request = IdentityInsightsRequest( - phone_number=IDENTITY_INSIGHTS_NUMBER, + phone_number=INSIGHT_NUMBER, insights=InsightsRequest(current_carrier=EmptyInsight()), ) diff --git a/identity-insights/get-format-insight.py b/identity-insights/get-format-insight.py index cfac28c..60f717d 100644 --- a/identity-insights/get-format-insight.py +++ b/identity-insights/get-format-insight.py @@ -9,7 +9,7 @@ VONAGE_APPLICATION_ID = os.environ.get("VONAGE_APPLICATION_ID") VONAGE_PRIVATE_KEY = os.environ.get("VONAGE_PRIVATE_KEY") -IDENTITY_INSIGHTS_NUMBER = os.environ.get("IDENTITY_INSIGHTS_NUMBER") +INSIGHT_NUMBER = os.environ.get("INSIGHT_NUMBER") IDENTITY_INSIGHTS_API_HOST = os.environ.get("IDENTITY_INSIGHTS_API_HOST") from vonage import Auth, HttpClientOptions, Vonage @@ -29,7 +29,7 @@ ) request = IdentityInsightsRequest( - phone_number=IDENTITY_INSIGHTS_NUMBER, + phone_number=INSIGHT_NUMBER, insights=InsightsRequest(format=EmptyInsight()), ) diff --git a/identity-insights/get-original-carrier.py b/identity-insights/get-original-carrier.py index 2099050..db271fb 100644 --- a/identity-insights/get-original-carrier.py +++ b/identity-insights/get-original-carrier.py @@ -9,7 +9,7 @@ VONAGE_APPLICATION_ID = os.environ.get("VONAGE_APPLICATION_ID") VONAGE_PRIVATE_KEY = os.environ.get("VONAGE_PRIVATE_KEY") -IDENTITY_INSIGHTS_NUMBER = os.environ.get("IDENTITY_INSIGHTS_NUMBER") +INSIGHT_NUMBER = os.environ.get("INSIGHT_NUMBER") IDENTITY_INSIGHTS_API_HOST = os.environ.get("IDENTITY_INSIGHTS_API_HOST") from vonage import Auth, HttpClientOptions, Vonage @@ -29,7 +29,7 @@ ) request = IdentityInsightsRequest( - phone_number=IDENTITY_INSIGHTS_NUMBER, + phone_number=INSIGHT_NUMBER, insights=InsightsRequest(original_carrier=EmptyInsight()), ) diff --git a/identity-insights/get-sim-swap.py b/identity-insights/get-sim-swap.py index 89b7cc4..1ba4eca 100644 --- a/identity-insights/get-sim-swap.py +++ b/identity-insights/get-sim-swap.py @@ -9,7 +9,7 @@ VONAGE_APPLICATION_ID = os.environ.get("VONAGE_APPLICATION_ID") VONAGE_PRIVATE_KEY = os.environ.get("VONAGE_PRIVATE_KEY") -IDENTITY_INSIGHTS_NUMBER = os.environ.get("IDENTITY_INSIGHTS_NUMBER") +INSIGHT_NUMBER = os.environ.get("INSIGHT_NUMBER") IDENTITY_INSIGHTS_PURPOSE = os.environ.get("IDENTITY_INSIGHTS_PURPOSE") IDENTITY_INSIGHTS_API_HOST = os.environ.get("IDENTITY_INSIGHTS_API_HOST") @@ -30,7 +30,7 @@ ) request = IdentityInsightsRequest( - phone_number=IDENTITY_INSIGHTS_NUMBER, + phone_number=INSIGHT_NUMBER, purpose=IDENTITY_INSIGHTS_PURPOSE, insights=InsightsRequest(sim_swap=SimSwapInsight(period=240)), ) From 08bef735b49a9237648a613ade722e3f24bc48c2 Mon Sep 17 00:00:00 2001 From: superchilled Date: Thu, 25 Jun 2026 12:20:15 +0100 Subject: [PATCH 3/3] Updating SIM Swap snippet vars in line with snippet spec --- .env.dist | 2 +- identity-insights/get-sim-swap.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.env.dist b/.env.dist index 80d96df..91e43ee 100644 --- a/.env.dist +++ b/.env.dist @@ -47,7 +47,7 @@ WHATSAPP_STICKER_URL='WHATSAPP_STICKER_URL' # Identity Insights INSIGHT_NUMBER='INSIGHT_NUMBER' -IDENTITY_INSIGHTS_PURPOSE='IDENTITY_INSIGHTS_PURPOSE' +SIM_SWAP_PERIOD='SIM_SWAP_PERIOD' IDENTITY_INSIGHTS_API_HOST='api-eu.vonage.com' # NI diff --git a/identity-insights/get-sim-swap.py b/identity-insights/get-sim-swap.py index 1ba4eca..718263d 100644 --- a/identity-insights/get-sim-swap.py +++ b/identity-insights/get-sim-swap.py @@ -10,7 +10,7 @@ VONAGE_APPLICATION_ID = os.environ.get("VONAGE_APPLICATION_ID") VONAGE_PRIVATE_KEY = os.environ.get("VONAGE_PRIVATE_KEY") INSIGHT_NUMBER = os.environ.get("INSIGHT_NUMBER") -IDENTITY_INSIGHTS_PURPOSE = os.environ.get("IDENTITY_INSIGHTS_PURPOSE") +SIM_SWAP_PERIOD = os.environ.get("SIM_SWAP_PERIOD") IDENTITY_INSIGHTS_API_HOST = os.environ.get("IDENTITY_INSIGHTS_API_HOST") from vonage import Auth, HttpClientOptions, Vonage @@ -31,8 +31,8 @@ request = IdentityInsightsRequest( phone_number=INSIGHT_NUMBER, - purpose=IDENTITY_INSIGHTS_PURPOSE, - insights=InsightsRequest(sim_swap=SimSwapInsight(period=240)), + purpose='FraudPreventionAndDetection', + insights=InsightsRequest(sim_swap=SimSwapInsight(period=SIM_SWAP_PERIOD)), ) response: IdentityInsightsResponse = client.identity_insights.requests(request)