All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fullcontact.apilib.enrich.Example Maven / Gradle / Ivy

There is a newer version: 4.0.0
Show newest version
package com.fullcontact.apilib.enrich;

import com.fullcontact.apilib.FCConstants;
import com.fullcontact.apilib.FullContactException;
import com.fullcontact.apilib.auth.CredentialsProvider;
import com.fullcontact.apilib.auth.StaticApiKeyCredentialProvider;
import com.fullcontact.apilib.models.Location;
import com.fullcontact.apilib.models.PersonName;
import com.fullcontact.apilib.models.Profile;
import com.fullcontact.apilib.models.Request.*;
import com.fullcontact.apilib.models.Response.*;
import com.fullcontact.apilib.models.Tag;
import com.fullcontact.apilib.models.enums.Confidence;
import com.google.gson.Gson;

import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

public class Example {

  public static void main(String[] args) {
    try {
      final Gson gson = new Gson();

      CredentialsProvider staticCredentialsProvider =
          new StaticApiKeyCredentialProvider("PrK0MBAm6s3RQGo6Yq4SuPiknpM4n14z");
      System.out.println(FCConstants.VERSION);
      // Building FullContact client
      FullContact fcClient =
          FullContact.builder()
              .credentialsProvider(staticCredentialsProvider)
              .connectTimeoutMillis(10000)
              .build();
      /*      List datafilter = new LinkedList<>();
      //      datafilter.add("social");
      datafilter.add("employment_history");*/
      /*PersonRequest pr =
          FullContact.buildPersonRequest()
              .email("[email protected]")
              .name(PersonName.builder().full("Ken michie").build())
              .build();
      pr = pr.toBuilder().email("[email protected]").build();
      System.out.println(gson.toJson(pr));*/
      /*PersonResponse prsp = fcClient.enrich(pr).get();
      System.out.println(prsp.isSuccessful());
      System.out.println(prsp.getDetails().get().getProfiles().getTwitter().getUrl());*/
      /*AudienceRequest audienceRequest =
          FullContact.buildAudienceRequest()
              .tag(Tag.builder().key("gender").value("male").build())
              .webhookUrl("https://webhook.site/f5a3539f-92e7-45dd-bdee-fd3028f02cbb")
              .build();
      String requestId = "72e53890-17b5-4d88-a651-54ae0c7920cc";
      CompletableFuture audienceResponseCompletableFuture =
          fcClient.audienceDownload(requestId);
      audienceResponseCompletableFuture.thenAccept(
          audienceResponse -> {
            System.out.println(audienceResponse.getRequestId());
            try {
              audienceResponse.getFileFromBytes(requestId);
            } catch (IOException e) {
              e.printStackTrace();
            }
          });*/
      /*TagsRequest tagsRequest =
          FullContact.buildTagsRequest()
              .recordId("k2")
              .tag(Tag.builder().key("gender").value("something").build())
              .build();
      //      CompletableFuture tagsResponseCompletableFuture =
      //          fcClient.tagsDelete(tagsRequest);
      CompletableFuture tagsResponseCompletableFuture = fcClient.tagsGet("k2");
      tagsResponseCompletableFuture.thenAccept(
          tagsResponse -> {
            System.out.println(tagsResponse.getRecordId());
            System.out.println(tagsResponse.getPartnerId());
            System.out.println(tagsResponse.getTags());
            System.out.println(tagsResponse.isSuccessful);
            System.out.println(tagsResponse.getMessage());
            System.out.println(tagsResponse.statusCode);
          });*/

      /*ResolveRequest resolveRequest =
          FullContact.buildResolveRequest()
              .recordId("k3")
              .email("[email protected]")
              .tag(Tag.builder().key("client").value("test").build())
              .build();
      CompletableFuture resolveResponse =
          fcClient.identityResolveWithTags(resolveRequest);
      resolveResponse.thenAccept(
          response -> {
            System.out.println(response.getRecordIds());
            System.out.println(response.getPersonIds());
            System.out.println(response.getTags());
          });
      resolveResponse.join();*/
      /*EmailVerificationResponse resp = fcClient.emailVerification("[email protected]").get();
      System.out.println(resp);*/

      /* ResolveRequest resolveRequest =
          FullContact.buildResolveRequest()
              .email("[email protected]")
              .recordId("customer123")
              .build();

      CompletableFuture mapResponse = fcClient.identityMap(resolveRequest);
      mapResponse.thenAccept(
          response -> {
            System.out.println("map " + response.toString());
          });
      mapResponse.join();
      CompletableFuture resolveResponse = fcClient.identityResolve(resolveRequest);
      resolveResponse.thenAccept(
          response -> {
            System.out.println("resolve " + response.toString());
          });
      resolveResponse.join();
      CompletableFuture deleteResponse = fcClient.identityDelete(resolveRequest);
      deleteResponse.thenAccept(
          response -> {
            System.out.println("delete " + response.toString());
            System.out.println(response.isSuccessful);
          });
      deleteResponse.join();*/
      //      tagsResponseCompletableFuture.join();
      //      Thread.sleep(10000);
      //      fcClient.close();

      /*} catch (FullContactException e) {
        e.printStackTrace();
        System.out.println(e.getMessage());
      } catch (InterruptedException e) {
        e.printStackTrace();
      } catch (ExecutionException e) {
        e.printStackTrace();
      }*/
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy