-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding number insight v2 sample (#144)
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
require('dotenv').config({ path: __dirname + '/../.env' }); | ||
|
||
const VONAGE_API_KEY = process.env.VONAGE_API_KEY; | ||
const VONAGE_API_SECRET = process.env.VONAGE_API_SECRET; | ||
|
||
// By default use the command line argument. Otherwise use the environment variable. | ||
const INSIGHT_NUMBER = process.argv[2] || process.env.INSIGHT_NUMBER; | ||
|
||
const { NumberInsightV2, Insight } = require('@vonage/number-insight-v2'); | ||
|
||
const insight = new NumberInsightV2({ | ||
apiKey: VONAGE_API_KEY, | ||
apiSecret: VONAGE_API_SECRET, | ||
}); | ||
|
||
async function run() { | ||
const resp = await insight.checkForFraud({ | ||
// This is requried for future proofing | ||
type: 'phone', | ||
phone: INSIGHT_NUMBER, | ||
insights: [ | ||
Insight.SIM_SWAP, | ||
Insight.FRAUD_SCORE, | ||
], | ||
}); | ||
|
||
console.log(resp); | ||
} | ||
|
||
run(); |