HubSpot/clearbit-java

Name: clearbit-java

Owner: HubSpot

Description: A Java API client to https://clearbit.com

Forked from: clearbit/clearbit-java

Created: 2017-01-23 23:25:13.0

Updated: 2018-03-19 19:05:07.0

Pushed: 2018-03-19 19:05:06.0

Homepage:

Size: 51

Language: Java

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Clearbit

A Java API client to https://clearbit.com.

Installation

The client library can be imported from Maven Central, or users can download source and build locally.

Usage

Authorize requests by setting the API key found on your account's settings page.

rt com.clearbit.ApiException;
rt com.clearbit.client.api.CombinedApi;
rt com.clearbit.client.model.PersonCompany;
rt com.fasterxml.jackson.core.JsonProcessingException;
rt com.fasterxml.jackson.databind.ObjectMapper;

ic class ClearbitExample {
public static void main(String[] args) {
    final String clearbit_key = System.getenv("CLEARBIT_KEY");
    CombinedApi api = new CombinedApi();
    api.getApiClient().setUsername(clearbit_key);

    try {
        ObjectMapper mapper = new ObjectMapper();
        PersonCompany personCompany = api.streamingLookup("harlow@clearbit.com");

        // access attrs form response
        System.out.println(personCompany.getPerson().getEmail());

        // print full JSON payload
        String jsonBody = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(personCompany);
        System.out.println(jsonBody);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    } catch (ApiException e) {
        e.printStackTrace();
    }
}

This API is blocking by default - it holds a streaming connection open (this can take 3~5 seconds if we haven't seen the email before). We recommend using the webhook API for higher throughput.

To parse the response received from a webhook call, use the WebhookResponseParser:

l String clearbit_key = System.getenv("CLEARBIT_KEY");
ookResponseParser parser = new WebhookResponseParser(clearbit_key);
ookResponse response = parser.parse(responseBody, xRequestSignatureHeader);

ch (response.getType()) {
se PERSON:
Person person = (Person) response.getBody();
break;
se COMPANY:
Company company = (Company) response.getBody();
break;
se PERSON_COMPANY:
PersonCompany personCompany = (PersonCompany) response.getBody();
break;
fault:
throw new IllegalStateException("Unexpected type: " + response.getType());

Supported APIs

Currently streaming for the following APIs is supported:

Implementation Notes

Lombok is used in the model classes to efficiently represent the models without boilerplate for getters, setters, toStrings, etc. The code is delomboked during compilation so that the final output does not include any dependency on Lombok.

Download and install the Lombok plugin: https://projectlombok.org/setup/eclipse

Release
release:prepare
release:perform

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.