Skip to content

Commit fc0a40a

Browse files
committed
Merge branch 'release-25.9' into 'main'
Release 25.9 See merge request nwac/sdk-ts!132
2 parents af4aff1 + 860042b commit fc0a40a

26 files changed

+1535
-105
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## Version 5.2.0
4+
5+
Changes:
6+
- Added support for Device Swap
7+
- Added support for KYC Match and KYC Age Verification
8+
39
## Version 5.0.0
410

511
Breaking Changes:

examples/device-swap.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { NetworkAsCodeClient } from "network-as-code";
2+
3+
const client = new NetworkAsCodeClient("<your-token>");
4+
5+
const device = client.devices.get({ phoneNumber: "+3637123456" });
6+
7+
// Device swap date can be acquired like so:
8+
const deviceSwapDate = await device.getDeviceSwapDate();
9+
10+
// Under some circumstances if no device swap has occurred, this object may be null
11+
// Otherwise the device swap date may also be the activation date of the device
12+
if (!deviceSwapDate) {
13+
console.log("Device swap date is null: No device swap has occurred");
14+
} else {
15+
console.log(
16+
`Last device swap (or activation) happened on ${deviceSwapDate.toISOString()}`
17+
);
18+
}
19+
20+
// It is also possible to check if a device swap has occurred in general
21+
if (await device.verifyDeviceSwap()) {
22+
console.log("A device swap has occurred!");
23+
}
24+
25+
// If we want to check if it happened during the past hour:
26+
if (await device.verifyDeviceSwap(2400)) {
27+
console.log("A device swap has occurred in the past hour!");
28+
}

examples/kyc-age-verification-ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { NetworkAsCodeClient } from "network-as-code";
2+
3+
4+
// Initialize the client object with your application key
5+
const client = new NetworkAsCodeClient("<your-application-key-here>");
6+
7+
8+
// Then, create a device object for the phone number */
9+
const device = client.devices.get({
10+
// The phone number accepts the "+" sign, but not spaces or "()" marks
11+
phoneNumber: "+999999991000"
12+
});
13+
14+
15+
// Add the phone number of the subscriber and the age threshold to compare to here.
16+
// Add optionally also the other information of the subscriber here, as well as if the
17+
// subscription has a content lock or parental control.
18+
const parameters =
19+
{
20+
ageThreshold: 18,
21+
phoneNumber: "+99999991000",
22+
idDocument: "66666666q",
23+
name: "Federica Sanchez Arjona",
24+
givenName: "Federica",
25+
familyName: "Sanchez Arjona",
26+
middleNames: "Sanchez",
27+
familyNameAtBirth: "YYYY",
28+
birthdate: "1978-08-22",
29+
email: "federicaSanchez.Arjona@example.com",
30+
includeContentLock: true,
31+
includeParentalControl: true
32+
}
33+
34+
const customerAgeVerifyResult = await device.verifyAge(parameters);
35+
36+
console.log(customerAgeVerifyResult)

examples/kyc-match.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { NetworkAsCodeClient } from "network-as-code";
2+
3+
4+
// Initialize the client object with your application key
5+
const client = new NetworkAsCodeClient("<your-application-key-here>");
6+
7+
8+
// Then, create a device object for the phone number. */
9+
const device = client.devices.get({
10+
// The phone number accepts the "+" sign, but not spaces or "()" marks
11+
phoneNumber: "+999999991000"
12+
});
13+
14+
15+
// Add the customer identity data here, which is to be used in matching
16+
// a customer against the account data bound to their phone number.
17+
const parameters =
18+
{
19+
phoneNumber: '+99999991000',
20+
idDocument: "66666666q",
21+
name: "Federica Sanchez Arjona",
22+
givenName: "Federica",
23+
familyName: "Sanchez Arjona",
24+
nameKanaHankaku: "federica",
25+
nameKanaZenkaku: "Federica",
26+
middleNames: "Sanchez",
27+
familyNameAtBirth: "YYYY",
28+
address: "Tokyo-to Chiyoda-ku Iidabashi 3-10-10",
29+
streetName: "Nicolas Salmeron",
30+
streetNumber: "4",
31+
postalCode: "1028460",
32+
region: "Tokyo",
33+
locality: "ZZZZ",
34+
country: "JP",
35+
houseNumberExtension: "VVVV",
36+
birthdate: "1978-08-22",
37+
email: "abc@example.com",
38+
gender: "OTHER"
39+
}
40+
41+
const customerMatchResult = await device.matchCustomer(parameters);
42+
43+
console.log(customerMatchResult)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { beforeAll, beforeEach, describe, expect } from "@jest/globals";
2+
import "dotenv/config";
3+
import { NetworkAsCodeClient } from "../src";
4+
import { Device } from "../src/models/device";
5+
import { configureClient } from "./configClient";
6+
7+
let client: NetworkAsCodeClient;
8+
9+
beforeAll((): any => {
10+
client = configureClient()
11+
});
12+
13+
describe("Device Swap retrieval and verification", () => {
14+
let device: Device;
15+
16+
beforeEach(() => {
17+
device = client.devices.get({
18+
phoneNumber: "+99999991000",
19+
});
20+
});
21+
it("should retrieve device swap of a test device", async () => {
22+
expect(await device.getDeviceSwapDate()).toBeTruthy();
23+
});
24+
25+
it("should verify device swap without max age", async () => {
26+
expect(await device.verifyDeviceSwap()).toBe(true)
27+
});
28+
29+
it("should verify device swap with max age", async () => {
30+
expect(await device.verifyDeviceSwap(250)).toBe(true)
31+
});
32+
33+
it("should verify device swap - True", async () => {
34+
device = client.devices.get({
35+
phoneNumber: "+99999991000"
36+
});
37+
38+
expect(await device.verifyDeviceSwap()).toBe(true)
39+
});
40+
41+
it("should verify device swap - False", async () => {
42+
device = client.devices.get({
43+
phoneNumber: "+99999991001"
44+
});
45+
expect(await device.verifyDeviceSwap(120)).toBe(false)
46+
});
47+
});

0 commit comments

Comments
 (0)