Skip to content

Commit f28833e

Browse files
committed
Update ipdata client to match current API
- Add Company model (name, domain, network, type) for API company object - Add regionType field to IpdataModel for API region_type - Add company field to IpdataModel for API company object - Add icloudRelay and datacenter fields to ThreatModel for API is_icloud_relay and is_datacenter threat indicators - Fix IpdataField.THREAT type from TimeZone to ThreatModel (bug) - Fix getCallingCode endpoint from /asn to /calling_code (bug) - Add missing IpdataField constants: REGION_CODE, REGION_TYPE, CONTINENT_NAME, COMPANY - Update test fixture with new API fields - Update Lombok to 1.18.34 and compiler target to Java 8 https://claude.ai/code/session_01L8wfDZ1ZCuFLzAgaecvLr1
1 parent af78129 commit f28833e

7 files changed

Lines changed: 38 additions & 6 deletions

File tree

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
</snapshotRepository>
3737
</distributionManagement>
3838
<properties>
39-
<maven.compiler.source>6</maven.compiler.source>
40-
<maven.compiler.target>6</maven.compiler.target>
39+
<maven.compiler.source>8</maven.compiler.source>
40+
<maven.compiler.target>8</maven.compiler.target>
4141
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
4242
<sonar.coverage.jacoco.xmlReportPaths>${project.build.directory}/site/code-coverage/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
4343
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
@@ -87,7 +87,7 @@
8787
<dependency>
8888
<groupId>org.projectlombok</groupId>
8989
<artifactId>lombok</artifactId>
90-
<version>1.18.10</version>
90+
<version>1.18.34</version>
9191
</dependency>
9292
<dependency>
9393
<groupId>org.hamcrest</groupId>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package io.ipdata.client.model;
2+
3+
import lombok.Getter;
4+
import lombok.ToString;
5+
import lombok.experimental.Accessors;
6+
7+
@ToString @Getter @Accessors(fluent = true)
8+
public class Company {
9+
private String name;
10+
private String domain;
11+
private String network;
12+
private String type;
13+
}

src/main/java/io/ipdata/client/model/IpdataModel.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public class IpdataModel {
2222

2323
private String region;
2424
private String regionCode;
25+
private String regionType;
2526
private String countryName;
2627
private String countryCode;
2728
private String continentName;
@@ -35,6 +36,7 @@ public class IpdataModel {
3536
private String emojiUnicode;
3637
private AsnModel asn;
3738
private Carrier carrier;
39+
private Company company;
3840
private List<Language> languages;
3941
private Currency currency;
4042
private TimeZone timeZone;

src/main/java/io/ipdata/client/model/ThreatModel.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,8 @@ public class ThreatModel {
2020
private boolean threat;
2121
@JsonProperty("is_bogon")
2222
private boolean bogon;
23+
@JsonProperty("is_icloud_relay")
24+
private boolean icloudRelay;
25+
@JsonProperty("is_datacenter")
26+
private boolean datacenter;
2327
}

src/main/java/io/ipdata/client/service/IpdataField.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ public class IpdataField<T> {
1616
public static final IpdataField<Boolean> IS_EU = new IpdataField<Boolean>("is_eu", Boolean.class);
1717
public static final IpdataField<String> CITY = new IpdataField<String>("city", String.class);
1818
public static final IpdataField<String> REGION = new IpdataField<String>("region", String.class);
19+
public static final IpdataField<String> REGION_CODE = new IpdataField<String>("region_code", String.class);
20+
public static final IpdataField<String> REGION_TYPE = new IpdataField<String>("region_type", String.class);
1921
public static final IpdataField<String> COUNTRY_NAME = new IpdataField<String>("country_name", String.class);
2022
public static final IpdataField<String> COUNTRY_CODE = new IpdataField<String>("country_code", String.class);
2123
public static final IpdataField<String> CONTINENT_CODE = new IpdataField<String>("continent_code", String.class);
24+
public static final IpdataField<String> CONTINENT_NAME = new IpdataField<String>("continent_name", String.class);
2225
public static final IpdataField<Double> LATITUDE = new IpdataField<Double>("latitude", Double.class);
2326
public static final IpdataField<Double> LONGITUDE = new IpdataField<Double>("longitude", Double.class);
2427
public static final IpdataField<AsnModel> ASN = new IpdataField<AsnModel>("asn", AsnModel.class);
@@ -29,10 +32,11 @@ public class IpdataField<T> {
2932
public static final IpdataField<String> EMOJI_FLAG = new IpdataField<String>("emoji_flag", String.class);
3033
public static final IpdataField<String> EMOJI_UNICODE = new IpdataField<String>("emoji_unicode", String.class);
3134
public static final IpdataField<Carrier> CARRIER = new IpdataField<Carrier>("carrier", Carrier.class);
35+
public static final IpdataField<Company> COMPANY = new IpdataField<Company>("company", Company.class);
3236
public static final IpdataField<Language> LANGUAGES = new IpdataField<Language>("languages", Language.class);
3337
public static final IpdataField<Currency> CURRENCY = new IpdataField<Currency>("currency", Currency.class);
3438
public static final IpdataField<TimeZone> TIME_ZONE = new IpdataField<TimeZone>("time_zone", TimeZone.class);
35-
public static final IpdataField<TimeZone> THREAT = new IpdataField<TimeZone>("threat", TimeZone.class);
39+
public static final IpdataField<ThreatModel> THREAT = new IpdataField<ThreatModel>("threat", ThreatModel.class);
3640
public static final IpdataField<Integer> COUNT = new IpdataField<Integer>("count", Integer.class);
3741
private final String name;
3842
private final Class<T> type;

src/main/java/io/ipdata/client/service/IpdataInternalSingleFieldClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ interface IpdataInternalSingleFieldClient {
4040
@RequestLine("GET /{ip}/postal")
4141
String getPostal(@Param(value = "ip", encoded = true) String ip) throws IpdataException;
4242

43-
@RequestLine("GET /{ip}/asn")
43+
@RequestLine("GET /{ip}/calling_code")
4444
String getCallingCode(@Param(value = "ip", encoded = true) String ip) throws IpdataException;
4545

4646
@RequestLine("GET /{ip}/flag")

src/test/resources/io/ipdata/client/fixture.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"city": "test-city",
55
"region": "Illinois",
66
"region_code": "IL",
7+
"region_type": "state",
78
"country_name": "United States",
89
"country_code": "US",
910
"continent_name": "North America",
@@ -27,6 +28,12 @@
2728
"mcc": "310",
2829
"mnc": "004"
2930
},
31+
"company": {
32+
"name": "Verizon Wireless",
33+
"domain": "verizonwireless.com",
34+
"network": "69.78.0.0/16",
35+
"type": "business"
36+
},
3037
"languages": [
3138
{
3239
"name": "English",
@@ -54,7 +61,9 @@
5461
"is_known_attacker": false,
5562
"is_known_abuser": false,
5663
"is_threat": false,
57-
"is_bogon": false
64+
"is_bogon": false,
65+
"is_icloud_relay": false,
66+
"is_datacenter": false
5867
},
5968
"count": "236"
6069
}

0 commit comments

Comments
 (0)