{"action":"created","comment":{"url":"https://api.github.com/repos/clearbit/clearbit-java/pulls/comments/45430595","id":45430595,"diff_hunk":"@@ -35,21 +44,23 @@ public WebhookResponseParser(String apiKey) {\n     } catch (NoSuchAlgorithmException e) {\n       throw new IllegalStateException(\"this can't ever happen\", e);\n     }\n-    \n+\n     JsonNode node = json.deserialize(body);\n-    WebhookResponse<T> response = new WebhookResponse<T>();\n-    if (node.has(\"body\")) {\n-      response.setBody(json.deserialize(node.get(\"body\"), returnType));\n-    }\n-    if (node.has(\"id\")) {\n-      response.setId(node.get(\"id\").asText());\n-    }\n-    if (node.has(\"status\")) {\n-      response.setStatus(node.get(\"status\").asInt());\n-    }\n-    if (node.has(\"type\")) {\n-      response.setType(node.get(\"type\").asText());\n+    WebhookResponse response = new WebhookResponse();\n+    Type type = Type.valueOf(node.get(\"type\").asText().toUpperCase());\n+    response.setType(type);\n+    switch (type) {\n+      case PERSON:\n+        response.setBody(json.deserialize(node.get(\"body\"), Person.class));\n+        break;\n+      case COMPANY:\n+        response.setBody(json.deserialize(node.get(\"body\"), Company.class));\n+        break;","path":"src/main/java/com/clearbit/client/api/WebhookResponseParser.java","position":55,"original_position":55,"commit_id":"af309d9b44c1e1ab8ff2f7f4bfbbdfeed6fbe838","original_commit_id":"af309d9b44c1e1ab8ff2f7f4bfbbdfeed6fbe838","user":{"login":"harlow","id":739782,"avatar_url":"https://avatars.githubusercontent.com/u/739782?v=3","gravatar_id":"","url":"https://api.github.com/users/harlow","html_url":"https://github.com/harlow","followers_url":"https://api.github.com/users/harlow/followers","following_url":"https://api.github.com/users/harlow/following{/other_user}","gists_url":"https://api.github.com/users/harlow/gists{/gist_id}","starred_url":"https://api.github.com/users/harlow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harlow/subscriptions","organizations_url":"https://api.github.com/users/harlow/orgs","repos_url":"https://api.github.com/users/harlow/repos","events_url":"https://api.github.com/users/harlow/events{/privacy}","received_events_url":"https://api.github.com/users/harlow/received_events","type":"User","site_admin":false},"body":"There is actually a 3rd type `PERSON_COMPANY` which looks like this:\r\n```json\r\n{\r\n  \"person\": {},\r\n  \"company\": {}\r\n}\r\n```\r\n\r\nthis comes back from the Combined API:\r\nhttps://clearbit.com/docs?shell#enrichment-api-combined-api","created_at":"2015-11-20T02:39:43Z","updated_at":"2015-11-20T02:39:43Z","html_url":"https://github.com/clearbit/clearbit-java/pull/8#discussion_r45430595","pull_request_url":"https://api.github.com/repos/clearbit/clearbit-java/pulls/8","_links":{"self":{"href":"https://api.github.com/repos/clearbit/clearbit-java/pulls/comments/45430595"},"html":{"href":"https://github.com/clearbit/clearbit-java/pull/8#discussion_r45430595"},"pull_request":{"href":"https://api.github.com/repos/clearbit/clearbit-java/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/clearbit/clearbit-java/pulls/8","id":51308520,"html_url":"https://github.com/clearbit/clearbit-java/pull/8","diff_url":"https://github.com/clearbit/clearbit-java/pull/8.diff","patch_url":"https://github.com/clearbit/clearbit-java/pull/8.patch","issue_url":"https://api.github.com/repos/clearbit/clearbit-java/issues/8","number":8,"state":"open","locked":false,"title":"The type should not be a required parameter to WebhookResponseParser","user":{"login":"chadworth","id":2290733,"avatar_url":"https://avatars.githubusercontent.com/u/2290733?v=3","gravatar_id":"","url":"https://api.github.com/users/chadworth","html_url":"https://github.com/chadworth","followers_url":"https://api.github.com/users/chadworth/followers","following_url":"https://api.github.com/users/chadworth/following{/other_user}","gists_url":"https://api.github.com/users/chadworth/gists{/gist_id}","starred_url":"https://api.github.com/users/chadworth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chadworth/subscriptions","organizations_url":"https://api.github.com/users/chadworth/orgs","repos_url":"https://api.github.com/users/chadworth/repos","events_url":"https://api.github.com/users/chadworth/events{/privacy}","received_events_url":"https://api.github.com/users/chadworth/received_events","type":"User","site_admin":false},"body":"We don't know what the type will be until the response is parsed so it was very difficult to call this API. This change fixes that making it much easier to use","created_at":"2015-11-20T01:54:37Z","updated_at":"2015-11-20T02:39:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"76ddb767f2260e93020dc1e98e08645c3da6be94","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/clearbit/clearbit-java/pulls/8/commits","review_comments_url":"https://api.github.com/repos/clearbit/clearbit-java/pulls/8/comments","review_comment_url":"https://api.github.com/repos/clearbit/clearbit-java/pulls/comments{/number}","comments_url":"https://api.github.com/repos/clearbit/clearbit-java/issues/8/comments","statuses_url":"https://api.github.com/repos/clearbit/clearbit-java/statuses/af309d9b44c1e1ab8ff2f7f4bfbbdfeed6fbe838","head":{"label":"chadworth:type","ref":"type","sha":"af309d9b44c1e1ab8ff2f7f4bfbbdfeed6fbe838","user":{"login":"chadworth","id":2290733,"avatar_url":"https://avatars.githubusercontent.com/u/2290733?v=3","gravatar_id":"","url":"https://api.github.com/users/chadworth","html_url":"https://github.com/chadworth","followers_url":"https://api.github.com/users/chadworth/followers","following_url":"https://api.github.com/users/chadworth/following{/other_user}","gists_url":"https://api.github.com/users/chadworth/gists{/gist_id}","starred_url":"https://api.github.com/users/chadworth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chadworth/subscriptions","organizations_url":"https://api.github.com/users/chadworth/orgs","repos_url":"https://api.github.com/users/chadworth/repos","events_url":"https://api.github.com/users/chadworth/events{/privacy}","received_events_url":"https://api.github.com/users/chadworth/received_events","type":"User","site_admin":false},"repo":{"id":45134859,"name":"clearbit-java","full_name":"chadworth/clearbit-java","owner":{"login":"chadworth","id":2290733,"avatar_url":"https://avatars.githubusercontent.com/u/2290733?v=3","gravatar_id":"","url":"https://api.github.com/users/chadworth","html_url":"https://github.com/chadworth","followers_url":"https://api.github.com/users/chadworth/followers","following_url":"https://api.github.com/users/chadworth/following{/other_user}","gists_url":"https://api.github.com/users/chadworth/gists{/gist_id}","starred_url":"https://api.github.com/users/chadworth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chadworth/subscriptions","organizations_url":"https://api.github.com/users/chadworth/orgs","repos_url":"https://api.github.com/users/chadworth/repos","events_url":"https://api.github.com/users/chadworth/events{/privacy}","received_events_url":"https://api.github.com/users/chadworth/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/chadworth/clearbit-java","description":"A Java API client to https://clearbit.com","fork":true,"url":"https://api.github.com/repos/chadworth/clearbit-java","forks_url":"https://api.github.com/repos/chadworth/clearbit-java/forks","keys_url":"https://api.github.com/repos/chadworth/clearbit-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chadworth/clearbit-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chadworth/clearbit-java/teams","hooks_url":"https://api.github.com/repos/chadworth/clearbit-java/hooks","issue_events_url":"https://api.github.com/repos/chadworth/clearbit-java/issues/events{/number}","events_url":"https://api.github.com/repos/chadworth/clearbit-java/events","assignees_url":"https://api.github.com/repos/chadworth/clearbit-java/assignees{/user}","branches_url":"https://api.github.com/repos/chadworth/clearbit-java/branches{/branch}","tags_url":"https://api.github.com/repos/chadworth/clearbit-java/tags","blobs_url":"https://api.github.com/repos/chadworth/clearbit-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chadworth/clearbit-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chadworth/clearbit-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/chadworth/clearbit-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chadworth/clearbit-java/statuses/{sha}","languages_url":"https://api.github.com/repos/chadworth/clearbit-java/languages","stargazers_url":"https://api.github.com/repos/chadworth/clearbit-java/stargazers","contributors_url":"https://api.github.com/repos/chadworth/clearbit-java/contributors","subscribers_url":"https://api.github.com/repos/chadworth/clearbit-java/subscribers","subscription_url":"https://api.github.com/repos/chadworth/clearbit-java/subscription","commits_url":"https://api.github.com/repos/chadworth/clearbit-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/chadworth/clearbit-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/chadworth/clearbit-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/chadworth/clearbit-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/chadworth/clearbit-java/contents/{+path}","compare_url":"https://api.github.com/repos/chadworth/clearbit-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chadworth/clearbit-java/merges","archive_url":"https://api.github.com/repos/chadworth/clearbit-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chadworth/clearbit-java/downloads","issues_url":"https://api.github.com/repos/chadworth/clearbit-java/issues{/number}","pulls_url":"https://api.github.com/repos/chadworth/clearbit-java/pulls{/number}","milestones_url":"https://api.github.com/repos/chadworth/clearbit-java/milestones{/number}","notifications_url":"https://api.github.com/repos/chadworth/clearbit-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chadworth/clearbit-java/labels{/name}","releases_url":"https://api.github.com/repos/chadworth/clearbit-java/releases{/id}","created_at":"2015-10-28T18:52:36Z","updated_at":"2015-10-28T18:52:37Z","pushed_at":"2015-11-20T01:53:24Z","git_url":"git://github.com/chadworth/clearbit-java.git","ssh_url":"git@github.com:chadworth/clearbit-java.git","clone_url":"https://github.com/chadworth/clearbit-java.git","svn_url":"https://github.com/chadworth/clearbit-java","homepage":"","size":24,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"clearbit:master","ref":"master","sha":"d431fa2fe5cc84ae1d2f7871257aa70d1fe164f3","user":{"login":"clearbit","id":9300813,"avatar_url":"https://avatars.githubusercontent.com/u/9300813?v=3","gravatar_id":"","url":"https://api.github.com/users/clearbit","html_url":"https://github.com/clearbit","followers_url":"https://api.github.com/users/clearbit/followers","following_url":"https://api.github.com/users/clearbit/following{/other_user}","gists_url":"https://api.github.com/users/clearbit/gists{/gist_id}","starred_url":"https://api.github.com/users/clearbit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clearbit/subscriptions","organizations_url":"https://api.github.com/users/clearbit/orgs","repos_url":"https://api.github.com/users/clearbit/repos","events_url":"https://api.github.com/users/clearbit/events{/privacy}","received_events_url":"https://api.github.com/users/clearbit/received_events","type":"Organization","site_admin":false},"repo":{"id":45073523,"name":"clearbit-java","full_name":"clearbit/clearbit-java","owner":{"login":"clearbit","id":9300813,"avatar_url":"https://avatars.githubusercontent.com/u/9300813?v=3","gravatar_id":"","url":"https://api.github.com/users/clearbit","html_url":"https://github.com/clearbit","followers_url":"https://api.github.com/users/clearbit/followers","following_url":"https://api.github.com/users/clearbit/following{/other_user}","gists_url":"https://api.github.com/users/clearbit/gists{/gist_id}","starred_url":"https://api.github.com/users/clearbit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clearbit/subscriptions","organizations_url":"https://api.github.com/users/clearbit/orgs","repos_url":"https://api.github.com/users/clearbit/repos","events_url":"https://api.github.com/users/clearbit/events{/privacy}","received_events_url":"https://api.github.com/users/clearbit/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/clearbit/clearbit-java","description":"A Java API client to https://clearbit.com","fork":false,"url":"https://api.github.com/repos/clearbit/clearbit-java","forks_url":"https://api.github.com/repos/clearbit/clearbit-java/forks","keys_url":"https://api.github.com/repos/clearbit/clearbit-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/clearbit/clearbit-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/clearbit/clearbit-java/teams","hooks_url":"https://api.github.com/repos/clearbit/clearbit-java/hooks","issue_events_url":"https://api.github.com/repos/clearbit/clearbit-java/issues/events{/number}","events_url":"https://api.github.com/repos/clearbit/clearbit-java/events","assignees_url":"https://api.github.com/repos/clearbit/clearbit-java/assignees{/user}","branches_url":"https://api.github.com/repos/clearbit/clearbit-java/branches{/branch}","tags_url":"https://api.github.com/repos/clearbit/clearbit-java/tags","blobs_url":"https://api.github.com/repos/clearbit/clearbit-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/clearbit/clearbit-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/clearbit/clearbit-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/clearbit/clearbit-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/clearbit/clearbit-java/statuses/{sha}","languages_url":"https://api.github.com/repos/clearbit/clearbit-java/languages","stargazers_url":"https://api.github.com/repos/clearbit/clearbit-java/stargazers","contributors_url":"https://api.github.com/repos/clearbit/clearbit-java/contributors","subscribers_url":"https://api.github.com/repos/clearbit/clearbit-java/subscribers","subscription_url":"https://api.github.com/repos/clearbit/clearbit-java/subscription","commits_url":"https://api.github.com/repos/clearbit/clearbit-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/clearbit/clearbit-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/clearbit/clearbit-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/clearbit/clearbit-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/clearbit/clearbit-java/contents/{+path}","compare_url":"https://api.github.com/repos/clearbit/clearbit-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/clearbit/clearbit-java/merges","archive_url":"https://api.github.com/repos/clearbit/clearbit-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/clearbit/clearbit-java/downloads","issues_url":"https://api.github.com/repos/clearbit/clearbit-java/issues{/number}","pulls_url":"https://api.github.com/repos/clearbit/clearbit-java/pulls{/number}","milestones_url":"https://api.github.com/repos/clearbit/clearbit-java/milestones{/number}","notifications_url":"https://api.github.com/repos/clearbit/clearbit-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/clearbit/clearbit-java/labels{/name}","releases_url":"https://api.github.com/repos/clearbit/clearbit-java/releases{/id}","created_at":"2015-10-27T22:17:31Z","updated_at":"2015-10-27T23:33:25Z","pushed_at":"2015-11-20T01:54:37Z","git_url":"git://github.com/clearbit/clearbit-java.git","ssh_url":"git@github.com:clearbit/clearbit-java.git","clone_url":"https://github.com/clearbit/clearbit-java.git","svn_url":"https://github.com/clearbit/clearbit-java","homepage":"","size":23,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/clearbit/clearbit-java/pulls/8"},"html":{"href":"https://github.com/clearbit/clearbit-java/pull/8"},"issue":{"href":"https://api.github.com/repos/clearbit/clearbit-java/issues/8"},"comments":{"href":"https://api.github.com/repos/clearbit/clearbit-java/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/clearbit/clearbit-java/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/clearbit/clearbit-java/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/clearbit/clearbit-java/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/clearbit/clearbit-java/statuses/af309d9b44c1e1ab8ff2f7f4bfbbdfeed6fbe838"}}}}