Skip to content
This repository has been archived by the owner on Sep 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #36 from fullcontact/macromeasures
Browse files Browse the repository at this point in the history
Person: add macromeasures support
  • Loading branch information
ParisMi committed Jan 16, 2017
2 parents 7859165 + bd30ebf commit b0e459b
Show file tree
Hide file tree
Showing 9 changed files with 955 additions and 29 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -7,7 +7,7 @@
<groupId>com.fullcontact</groupId>
<artifactId>fullcontact4j</artifactId>
<name>FullContact Java Bindings</name>
<version>3.3.1</version>
<version>3.3.2</version>
<dependencies>

<dependency>
Expand Down
Expand Up @@ -38,6 +38,7 @@ public class FCConstants {
public static final String PARAM_PERSON_LOOKUP = "lookup";
public static final String PARAM_PERSON_PHONE = "phone";
public static final String PARAM_PERSON_PHONE_COUNTRY_CODE = "countryCode";
public static final String PARAM_PERSON_MACROMEASURES = "macromeasures";
public static final String PARAM_PERSON_CALLBACK = "callback";

public static final String PARAM_COMPANY_DOMAIN = "domain";
Expand Down
@@ -1,16 +1,10 @@
package com.fullcontact.api.libs.fullcontact4j.http.person;

import com.fullcontact.api.libs.fullcontact4j.FCConstants;
import com.fullcontact.api.libs.fullcontact4j.FullContactApi;
import com.fullcontact.api.libs.fullcontact4j.http.FCRequest;
import com.fullcontact.api.libs.fullcontact4j.http.FCResponse;
import com.fullcontact.api.libs.fullcontact4j.http.WebhookBuilder;
import com.fullcontact.api.libs.fullcontact4j.http.cardreader.CardReaderUploadConfirmResponse;
import com.fullcontact.api.libs.fullcontact4j.*;
import com.fullcontact.api.libs.fullcontact4j.http.*;
import retrofit.Callback;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.*;

public class PersonRequest extends FCRequest<PersonResponse> {

Expand Down Expand Up @@ -60,6 +54,11 @@ public Builder lookup(String lookupValue) {
return this;
}

public Builder macromeasures(boolean enabled) {
params.put(FCConstants.PARAM_PERSON_MACROMEASURES, enabled?"true":"false");
return this;
}

protected void validate() {
super.validate();
//for want of a java 8!
Expand Down
Expand Up @@ -26,6 +26,7 @@ public class PersonResponse extends FCResponse {
private List<Photo> photos = Collections.emptyList();
private double likelihood;
private List<SocialProfile> socialProfiles = Collections.emptyList();
private Macromeasures macromeasures = new Macromeasures(Collections.<Macromeasures.Interest>emptyList());
private String requestId;
private String message;

Expand Down
@@ -0,0 +1,27 @@
package com.fullcontact.api.libs.fullcontact4j.http.person.model;

import lombok.*;

import java.util.*;

@NoArgsConstructor(access = AccessLevel.PRIVATE)
@AllArgsConstructor
@ToString
@Getter
@EqualsAndHashCode
public class Macromeasures {
private List<Interest> interests = Collections.emptyList();

@Getter
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PRIVATE)
@ToString
@EqualsAndHashCode
public static class Interest {
private String name;
private String id;
private Double score;
private List<String> parents = Collections.emptyList();
private String category;
}
}
Expand Up @@ -11,6 +11,7 @@
public class Photo {
private String typeId;
private String typeName;
private String type;
private String url;
@JsonProperty("isPrimary")
private boolean isPrimary;
Expand Down
Expand Up @@ -321,6 +321,6 @@ public void failure(FullContactException exception) {
}

private PersonResponse newMockResponse(final String email) {
return new PersonResponse(null,null,null,null,null,.99,null,email,null);
return new PersonResponse(null,null,null,null,null,.99,null,null,email,null);
}
}
Expand Up @@ -3,38 +3,45 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fullcontact.api.libs.fullcontact4j.enums.CardReaderQuality;
import com.fullcontact.api.libs.fullcontact4j.http.WebhookResponse;
import com.fullcontact.api.libs.fullcontact4j.http.cardreader.CardReaderFullResponse;
import com.fullcontact.api.libs.fullcontact4j.http.cardreader.CardReaderUploadConfirmResponse;
import com.fullcontact.api.libs.fullcontact4j.http.cardreader.CardReaderViewAllResponse;
import com.fullcontact.api.libs.fullcontact4j.http.cardreader.*;
import com.fullcontact.api.libs.fullcontact4j.http.company.CompanyResponse;
import com.fullcontact.api.libs.fullcontact4j.http.company.model.KeyPerson;
import com.fullcontact.api.libs.fullcontact4j.http.email.EmailVerificationAsyncResponse;
import com.fullcontact.api.libs.fullcontact4j.http.email.EmailVerificationResponse;
import com.fullcontact.api.libs.fullcontact4j.http.location.LocationEnrichmentResponse;
import com.fullcontact.api.libs.fullcontact4j.http.location.LocationNormalizationResponse;
import com.fullcontact.api.libs.fullcontact4j.http.misc.AccountStatsResponse;
import com.fullcontact.api.libs.fullcontact4j.http.misc.DisposableEmailResponse;
import com.fullcontact.api.libs.fullcontact4j.http.name.NameParseResponse;
import com.fullcontact.api.libs.fullcontact4j.http.name.NameResponse;
import com.fullcontact.api.libs.fullcontact4j.http.name.NameSimilarityResponse;
import com.fullcontact.api.libs.fullcontact4j.http.name.NameStatsResponse;
import com.fullcontact.api.libs.fullcontact4j.http.person.PersonResponse;

import com.fullcontact.api.libs.fullcontact4j.http.email.*;
import com.fullcontact.api.libs.fullcontact4j.http.location.*;
import com.fullcontact.api.libs.fullcontact4j.http.misc.*;
import com.fullcontact.api.libs.fullcontact4j.http.name.*;
import com.fullcontact.api.libs.fullcontact4j.http.person.*;
import com.fullcontact.api.libs.fullcontact4j.http.person.model.Macromeasures;
import lombok.SneakyThrows;
import org.junit.Test;

import java.io.IOException;
import java.util.Collections;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;

public class ResponseModelTest {
public static ObjectMapper mapper = new ObjectMapper();

@Test
public void personDeserializationTest() throws IOException {
PersonResponse r = mapper.readValue(Utils.loadFile("example-person-response.json"), PersonResponse.class);
assertTrue(r.getDemographics().getGender().equals("Male"));
assertEquals( "Lorang", r.getContactInfo().getFamilyName());
assertEquals("http://fullcontact.com", r.getContactInfo().getWebsites().get(0).getUrl());
assertEquals("Male", r.getDemographics().getGender());
assertEquals(4, r.getContactInfo().getChats().size());
assertEquals("Dimension Technology Solutions", r.getOrganizations().get(2).getName());
assertEquals("Boulder, Colorado", r.getDemographics().getLocationDeduced().getNormalizedLocation());
}

@Test
public void personDeserializationMacromeasuresTest() throws IOException {
PersonResponse r = mapper.readValue(Utils.loadFile("example-person-response-macromeasures.json"), PersonResponse.class);
assertEquals(111, r.getMacromeasures().getInterests().size());

Macromeasures.Interest design = new Macromeasures.Interest("Design", "5457c85ad4ac147c798c5585",
0.2, Collections.singletonList("55afc38792cffb786d83f929"), "default");
assertEquals(design, r.getMacromeasures().getInterests().get(6));
}

@Test
Expand Down

0 comments on commit b0e459b

Please sign in to comment.