Skip to content

Commit 9671e67

Browse files
committed
feat: add identity insights code snippets
1 parent 20d47a4 commit 9671e67

6 files changed

Lines changed: 200 additions & 0 deletions

File tree

.env.dist

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ MESSAGES_EMOJI='MESSAGES_EMOJI'
4545
WHATSAPP_STICKER_ID='WHATSAPP_STICKER_ID'
4646
WHATSAPP_STICKER_URL='WHATSAPP_STICKER_URL'
4747

48+
# Identity Insights
49+
IDENTITY_INSIGHTS_NUMBER='IDENTITY_INSIGHTS_NUMBER'
50+
IDENTITY_INSIGHTS_PURPOSE='IDENTITY_INSIGHTS_PURPOSE'
51+
IDENTITY_INSIGHTS_API_HOST='api-eu.vonage.com'
52+
4853
# NI
4954
INSIGHT_NUMBER='INSIGHT_NUMBER'
5055
INSIGHT_CALLBACK_URL='INSIGHT_CALLBACK_URL'
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import os
2+
from os.path import dirname, join
3+
from pprint import pprint
4+
5+
from dotenv import load_dotenv
6+
7+
dotenv_path = join(dirname(__file__), "../.env")
8+
load_dotenv(dotenv_path)
9+
10+
VONAGE_APPLICATION_ID = os.environ.get("VONAGE_APPLICATION_ID")
11+
VONAGE_PRIVATE_KEY = os.environ.get("VONAGE_PRIVATE_KEY")
12+
IDENTITY_INSIGHTS_NUMBER = os.environ.get("IDENTITY_INSIGHTS_NUMBER")
13+
IDENTITY_INSIGHTS_PURPOSE = os.environ.get("IDENTITY_INSIGHTS_PURPOSE")
14+
IDENTITY_INSIGHTS_API_HOST = os.environ.get("IDENTITY_INSIGHTS_API_HOST")
15+
16+
from vonage import Auth, HttpClientOptions, Vonage
17+
from vonage_identity_insights import (
18+
EmptyInsight,
19+
IdentityInsightsRequest,
20+
IdentityInsightsResponse,
21+
InsightsRequest,
22+
SimSwapInsight,
23+
)
24+
25+
client = Vonage(
26+
auth=Auth(
27+
application_id=VONAGE_APPLICATION_ID,
28+
private_key=VONAGE_PRIVATE_KEY,
29+
),
30+
http_client_options=HttpClientOptions(api_host=IDENTITY_INSIGHTS_API_HOST),
31+
)
32+
33+
request = IdentityInsightsRequest(
34+
phone_number=IDENTITY_INSIGHTS_NUMBER,
35+
purpose=IDENTITY_INSIGHTS_PURPOSE,
36+
insights=InsightsRequest(
37+
format=EmptyInsight(),
38+
sim_swap=SimSwapInsight(period=240),
39+
original_carrier=EmptyInsight(),
40+
current_carrier=EmptyInsight(),
41+
),
42+
)
43+
44+
response: IdentityInsightsResponse = client.identity_insights.requests(request)
45+
pprint(response)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import os
2+
from os.path import dirname, join
3+
from pprint import pprint
4+
5+
from dotenv import load_dotenv
6+
7+
dotenv_path = join(dirname(__file__), "../.env")
8+
load_dotenv(dotenv_path)
9+
10+
VONAGE_APPLICATION_ID = os.environ.get("VONAGE_APPLICATION_ID")
11+
VONAGE_PRIVATE_KEY = os.environ.get("VONAGE_PRIVATE_KEY")
12+
IDENTITY_INSIGHTS_NUMBER = os.environ.get("IDENTITY_INSIGHTS_NUMBER")
13+
IDENTITY_INSIGHTS_API_HOST = os.environ.get("IDENTITY_INSIGHTS_API_HOST")
14+
15+
from vonage import Auth, HttpClientOptions, Vonage
16+
from vonage_identity_insights import (
17+
EmptyInsight,
18+
IdentityInsightsRequest,
19+
IdentityInsightsResponse,
20+
InsightsRequest,
21+
)
22+
23+
client = Vonage(
24+
auth=Auth(
25+
application_id=VONAGE_APPLICATION_ID,
26+
private_key=VONAGE_PRIVATE_KEY,
27+
),
28+
http_client_options=HttpClientOptions(api_host=IDENTITY_INSIGHTS_API_HOST),
29+
)
30+
31+
request = IdentityInsightsRequest(
32+
phone_number=IDENTITY_INSIGHTS_NUMBER,
33+
insights=InsightsRequest(current_carrier=EmptyInsight()),
34+
)
35+
36+
response: IdentityInsightsResponse = client.identity_insights.requests(request)
37+
pprint(response)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import os
2+
from os.path import dirname, join
3+
from pprint import pprint
4+
5+
from dotenv import load_dotenv
6+
7+
dotenv_path = join(dirname(__file__), "../.env")
8+
load_dotenv(dotenv_path)
9+
10+
VONAGE_APPLICATION_ID = os.environ.get("VONAGE_APPLICATION_ID")
11+
VONAGE_PRIVATE_KEY = os.environ.get("VONAGE_PRIVATE_KEY")
12+
IDENTITY_INSIGHTS_NUMBER = os.environ.get("IDENTITY_INSIGHTS_NUMBER")
13+
IDENTITY_INSIGHTS_API_HOST = os.environ.get("IDENTITY_INSIGHTS_API_HOST")
14+
15+
from vonage import Auth, HttpClientOptions, Vonage
16+
from vonage_identity_insights import (
17+
EmptyInsight,
18+
IdentityInsightsRequest,
19+
IdentityInsightsResponse,
20+
InsightsRequest,
21+
)
22+
23+
client = Vonage(
24+
auth=Auth(
25+
application_id=VONAGE_APPLICATION_ID,
26+
private_key=VONAGE_PRIVATE_KEY,
27+
),
28+
http_client_options=HttpClientOptions(api_host=IDENTITY_INSIGHTS_API_HOST),
29+
)
30+
31+
request = IdentityInsightsRequest(
32+
phone_number=IDENTITY_INSIGHTS_NUMBER,
33+
insights=InsightsRequest(format=EmptyInsight()),
34+
)
35+
36+
response: IdentityInsightsResponse = client.identity_insights.requests(request)
37+
pprint(response)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import os
2+
from os.path import dirname, join
3+
from pprint import pprint
4+
5+
from dotenv import load_dotenv
6+
7+
dotenv_path = join(dirname(__file__), "../.env")
8+
load_dotenv(dotenv_path)
9+
10+
VONAGE_APPLICATION_ID = os.environ.get("VONAGE_APPLICATION_ID")
11+
VONAGE_PRIVATE_KEY = os.environ.get("VONAGE_PRIVATE_KEY")
12+
IDENTITY_INSIGHTS_NUMBER = os.environ.get("IDENTITY_INSIGHTS_NUMBER")
13+
IDENTITY_INSIGHTS_API_HOST = os.environ.get("IDENTITY_INSIGHTS_API_HOST")
14+
15+
from vonage import Auth, HttpClientOptions, Vonage
16+
from vonage_identity_insights import (
17+
EmptyInsight,
18+
IdentityInsightsRequest,
19+
IdentityInsightsResponse,
20+
InsightsRequest,
21+
)
22+
23+
client = Vonage(
24+
auth=Auth(
25+
application_id=VONAGE_APPLICATION_ID,
26+
private_key=VONAGE_PRIVATE_KEY,
27+
),
28+
http_client_options=HttpClientOptions(api_host=IDENTITY_INSIGHTS_API_HOST),
29+
)
30+
31+
request = IdentityInsightsRequest(
32+
phone_number=IDENTITY_INSIGHTS_NUMBER,
33+
insights=InsightsRequest(original_carrier=EmptyInsight()),
34+
)
35+
36+
response: IdentityInsightsResponse = client.identity_insights.requests(request)
37+
pprint(response)

identity-insights/get-sim-swap.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import os
2+
from os.path import dirname, join
3+
from pprint import pprint
4+
5+
from dotenv import load_dotenv
6+
7+
dotenv_path = join(dirname(__file__), "../.env")
8+
load_dotenv(dotenv_path)
9+
10+
VONAGE_APPLICATION_ID = os.environ.get("VONAGE_APPLICATION_ID")
11+
VONAGE_PRIVATE_KEY = os.environ.get("VONAGE_PRIVATE_KEY")
12+
IDENTITY_INSIGHTS_NUMBER = os.environ.get("IDENTITY_INSIGHTS_NUMBER")
13+
IDENTITY_INSIGHTS_PURPOSE = os.environ.get("IDENTITY_INSIGHTS_PURPOSE")
14+
IDENTITY_INSIGHTS_API_HOST = os.environ.get("IDENTITY_INSIGHTS_API_HOST")
15+
16+
from vonage import Auth, HttpClientOptions, Vonage
17+
from vonage_identity_insights import (
18+
IdentityInsightsRequest,
19+
IdentityInsightsResponse,
20+
InsightsRequest,
21+
SimSwapInsight,
22+
)
23+
24+
client = Vonage(
25+
auth=Auth(
26+
application_id=VONAGE_APPLICATION_ID,
27+
private_key=VONAGE_PRIVATE_KEY,
28+
),
29+
http_client_options=HttpClientOptions(api_host=IDENTITY_INSIGHTS_API_HOST),
30+
)
31+
32+
request = IdentityInsightsRequest(
33+
phone_number=IDENTITY_INSIGHTS_NUMBER,
34+
purpose=IDENTITY_INSIGHTS_PURPOSE,
35+
insights=InsightsRequest(sim_swap=SimSwapInsight(period=240)),
36+
)
37+
38+
response: IdentityInsightsResponse = client.identity_insights.requests(request)
39+
pprint(response)

0 commit comments

Comments
 (0)