Skip to content

Commit 7eade1a

Browse files
committed
Serializing dii in the new format
1 parent 9ab7827 commit 7eade1a

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

src/main/java/com/uid2/client/IdentityMapV3Client.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ public IdentityMapV3Client(String uid2BaseUrl, String clientApiKey, String base6
1313

1414
/**
1515
* @param identityMapInput represents the input required for <a href="https://unifiedid.com/docs/endpoints/post-identity-map">/identity/map</a>
16-
* @return an IdentityMapResponse instance
16+
* @return an IdentityMapV3Response instance
1717
* @throws Uid2Exception if the response did not contain a "success" status, or the response code was not 200, or there was an error communicating with the provided UID2 Base URL
1818
*/
1919
public IdentityMapV3Response generateIdentityMap(IdentityMapV3Input identityMapInput) {
2020
EnvelopeV2 envelope = identityMapHelper.createEnvelopeForIdentityMapRequest(identityMapInput);
2121

22-
String responseString = uid2ClientHelper.makeRequest(envelope, "/v2/identity/map");
22+
String responseString = uid2ClientHelper.makeRequest(envelope, "/v3/identity/map");
2323
return identityMapHelper.createIdentityMapResponse(responseString, envelope, identityMapInput);
2424
}
2525

src/main/java/com/uid2/client/IdentityMapV3Input.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,26 +45,26 @@ private IdentityMapV3Input(IdentityType identityType, Iterable<String> emailsOrP
4545
hashedNormalizedEmails = new ArrayList<>();
4646
for (String email : emailsOrPhones) {
4747
if (alreadyHashed) {
48-
hashedNormalizedEmails.add(email);
48+
hashedNormalizedEmails.add(new Identity(email));
4949
} else {
5050
String hashedEmail = InputUtil.normalizeAndHashEmail(email);
51-
hashedNormalizedEmails.add(hashedEmail);
51+
hashedNormalizedEmails.add(new Identity(hashedEmail));
5252
addHashedToRawDiiMapping(hashedEmail, email);
5353
}
5454
}
5555
} else { //phone
5656
hashedNormalizedPhones = new ArrayList<>();
5757
for (String phone : emailsOrPhones) {
5858
if (alreadyHashed) {
59-
hashedNormalizedPhones.add(phone);
59+
hashedNormalizedPhones.add(new Identity(phone));
6060
} else {
6161
if (!InputUtil.isPhoneNumberNormalized(phone)) {
6262
throw new IllegalArgumentException("phone number is not normalized: " + phone);
6363
}
6464

6565
String hashedNormalizedPhone = InputUtil.getBase64EncodedHash(phone);
6666
addHashedToRawDiiMapping(hashedNormalizedPhone, phone);
67-
hashedNormalizedPhones.add(hashedNormalizedPhone);
67+
hashedNormalizedPhones.add(new Identity(hashedNormalizedPhone));
6868
}
6969
}
7070
}
@@ -83,9 +83,18 @@ List<String> getRawDiis(String identifier) {
8383
}
8484

8585
@SerializedName("email_hash")
86-
private List<String> hashedNormalizedEmails;
86+
private List<Identity> hashedNormalizedEmails;
8787
@SerializedName("phone_hash")
88-
private List<String> hashedNormalizedPhones;
88+
private List<Identity> hashedNormalizedPhones;
8989

9090
private final transient HashMap<String, List<String>> hashedDiiToRawDiis = new HashMap<>();
91+
92+
private static class Identity {
93+
@SerializedName("i")
94+
private final String i;
95+
96+
public Identity(String value) {
97+
this.i = value;
98+
}
99+
}
91100
}

0 commit comments

Comments
 (0)