Skip to content

Commit 2618360

Browse files
authored
feat: adding number insight v2 sample (#144)
1 parent 8961317 commit 2618360

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

number_insight_v2/check-for-fraud.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
require('dotenv').config({ path: __dirname + '/../.env' });
2+
3+
const VONAGE_API_KEY = process.env.VONAGE_API_KEY;
4+
const VONAGE_API_SECRET = process.env.VONAGE_API_SECRET;
5+
6+
// By default use the command line argument. Otherwise use the environment variable.
7+
const INSIGHT_NUMBER = process.argv[2] || process.env.INSIGHT_NUMBER;
8+
9+
const { NumberInsightV2, Insight } = require('@vonage/number-insight-v2');
10+
11+
const insight = new NumberInsightV2({
12+
apiKey: VONAGE_API_KEY,
13+
apiSecret: VONAGE_API_SECRET,
14+
});
15+
16+
async function run() {
17+
const resp = await insight.checkForFraud({
18+
// This is requried for future proofing
19+
type: 'phone',
20+
phone: INSIGHT_NUMBER,
21+
insights: [
22+
Insight.SIM_SWAP,
23+
Insight.FRAUD_SCORE,
24+
],
25+
});
26+
27+
console.log(resp);
28+
}
29+
30+
run();

0 commit comments

Comments
 (0)