From 9671e67fb0fc259cbca488da13f66c211aab8902 Mon Sep 17 00:00:00 2001 From: Alvaro Navarro Date: Fri, 20 Mar 2026 15:31:15 +0100 Subject: [PATCH] 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)