Skip to content

Commit f2ae608

Browse files
Add types for new Company field
1 parent e0ae024 commit f2ae608

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

integration_test/ipregistry.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ const API_KEY = process.env.IPREGISTRY_API_KEY || 'tryou';
3131
const API_KEY_THROTTLED = process.env.IPREGISTRY_API_KEY_THROTTLED || 'tryout';
3232

3333
describe('lookup', () => {
34+
it('should throw ApiError when input IP is reserved', async () => {
35+
try {
36+
const client = new IpregistryClient(API_KEY);
37+
await client.lookup('0.1.2.3');
38+
expect.fail();
39+
} catch (error: any) {
40+
expect(error).to.be.instanceOf(ApiError);
41+
expect(error.code).equal('RESERVED_IP_ADDRESS');
42+
}
43+
});
44+
3445
it('should return valid information when IPv4 address is known', async () => {
3546
const client = new IpregistryClient(API_KEY);
3647
const response = await client.lookup('8.8.8.8');
@@ -69,6 +80,9 @@ describe('lookup', () => {
6980
const response = await client.lookup('8.8.8.8', IpregistryOptions.hostname(true));
7081
const ipInfo = response.data;
7182
expect(ipInfo.type).equal('IPv4');
83+
expect(ipInfo.company.domain).not.null;
84+
expect(ipInfo.company.name).not.null;
85+
expect(ipInfo.company.type).not.null;
7286
expect(ipInfo.location.country.code).equal('US');
7387
expect(ipInfo.hostname).not.null;
7488
});

src/model.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ export interface IpInfo {
2424

2525
carrier: Carrier;
2626

27+
company: Company;
28+
2729
connection: Connection;
2830

2931
currency: Currency;
@@ -104,6 +106,16 @@ export interface Carrier {
104106

105107
}
106108

109+
export interface Company {
110+
111+
domain: string | null;
112+
113+
name: string | null;
114+
115+
type: 'business' | 'education' | 'government' | 'isp' | 'hosting' | null;
116+
117+
}
118+
107119
export interface Connection {
108120

109121
asn: number | null;
@@ -114,7 +126,7 @@ export interface Connection {
114126

115127
route: string | null;
116128

117-
type: 'business' | 'education' | 'government' | 'isp' | 'hosting' | null;
129+
type: 'business' | 'education' | 'government' | 'inactive' | 'isp' | 'hosting' | null;
118130

119131
}
120132

0 commit comments

Comments
 (0)