Skip to content
This repository has been archived by the owner on Aug 20, 2019. It is now read-only.

Commit

Permalink
client: Added support for Company API
Browse files Browse the repository at this point in the history
  • Loading branch information
Xorlev committed Apr 14, 2015
1 parent 2c73ff1 commit fb2fd99
Show file tree
Hide file tree
Showing 7 changed files with 248 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -9,6 +9,7 @@ A Ruby wrapper for the [FullContact API](http://www.fullcontact.com/)

Changes
-------
- 0.10.0 - Support for FullContact Company API
- 0.9.0 - Removed Rash gem and replaced with Mashify + Plisskin
- 0.8.2 - Fix for 0.8.0 constant resolution issue.
- 0.8.0
Expand Down Expand Up @@ -54,6 +55,9 @@ Usage Examples

# Get information from a phone number
person6 = FullContact.person(phone:13037170414)

# Get information about a company
company1 = FullContact.company(domain: 'fullcontact.com')

# Get information about a twitter and ensure a 30s socket open timeout and a 15s socket read timeout
# Can throw a Faraday::Error::TimeoutError if timeouts are exceeded
Expand Down
2 changes: 2 additions & 0 deletions lib/fullcontact/client.rb
Expand Up @@ -6,9 +6,11 @@ class Client < API
# order to avoid a superclass mismatch error, allowing those modules to be
# Client-namespaced.
require 'fullcontact/client/person'
require 'fullcontact/client/company'

alias :api_endpoint :endpoint

include FullContact::Client::Person
include FullContact::Client::Company
end
end
12 changes: 12 additions & 0 deletions lib/fullcontact/client/company.rb
@@ -0,0 +1,12 @@
module FullContact
class Client
module Company
# Returns extended information for a given person (email, phone, twitter or facebook)
#
def company(options={}, faraday_options={})
response = get('company/lookup', options, false, faraday_options)
format.to_s.downcase == 'xml' ? response['person'] : response
end
end
end
end
2 changes: 1 addition & 1 deletion lib/fullcontact/version.rb
@@ -1,3 +1,3 @@
module FullContact
VERSION = '0.9.0'
VERSION = '0.10.0'
end
191 changes: 191 additions & 0 deletions spec/fixtures/company.json
@@ -0,0 +1,191 @@

{
"status" : 200,
"requestId" : "92d5908a-8de4-4294-85d2-774051c33ef3",
"category" : [ {
"name" : "Other",
"code" : "OTHER"
} ],
"logo" : "https://d2ojpxxtu63wzl.cloudfront.net/static/e9f3aeb8965684906efa7ae514988ffb_0837a93ef09a70f8b9ff73efac18176225fd0b9cb8bf84a60c5926701b4c5033",
"website" : "https://www.fullcontact.com",
"languageLocale" : "en",
"organization" : {
"name" : "FullContact Inc.",
"approxEmployees" : 50,
"founded" : "2010",
"overview" : "Solving the world's contact information problem!",
"contactInfo" : {
"emailAddresses" : [ {
"value" : "support@fullcontact.com",
"label" : "support"
}, {
"value" : "sales@fullcontact.com",
"label" : "sales"
} ],
"phoneNumbers" : [ {
"number" : "+1 (888) 330-6943",
"label" : "other"
} ],
"addresses" : [ {
"addressLine1" : "1755 Blake Street",
"addressLine2" : "Suite 450",
"locality" : "Denver",
"region" : {
"name" : "Colorado",
"code" : "CO"
},
"country" : {
"name" : "United States",
"code" : "US"
},
"postalCode" : "80202",
"label" : "work"
} ]
},
"links" : [ {
"url" : "https://www.fullcontact.com/comments/feed",
"label" : "rss"
}, {
"url" : "https://www.fullcontact.com/home/feed",
"label" : "rss"
}, {
"url" : "https://www.fullcontact.com/developer",
"label" : "other"
}, {
"url" : "https://www.fullcontact.com/feed",
"label" : "rss"
}, {
"url" : "https://fullcontact.com/blog",
"label" : "blog"
}, {
"url" : "https://www.youtube.com/watch?v=koFtyUDbYak",
"label" : "youtube"
} ],
"images" : [ {
"url" : "https://d2ojpxxtu63wzl.cloudfront.net/static/1c390465c39c998a59c8717034982dfc_ff8af9a9f14da29ee687053e65d2ed103b8ab6f95b1f4d0147b9077ea04a3d6c",
"label" : "facebook"
}, {
"url" : "https://d2ojpxxtu63wzl.cloudfront.net/static/edaa53d9a080aea37ddfb85d775620a9_98a2d7beef6a5b4a53f43da4dd1a90bda21dc18f755394fdbf9b6cf3283853a0",
"label" : "twitter"
}, {
"url" : "https://d2ojpxxtu63wzl.cloudfront.net/static/1bacd7306731a30d2a9f024eeb1dcff1_94d77dcdedbfe40707ac4a75ca4f4d2978bffc20b2e33a3288ea9e4d47f5af6c",
"label" : "twitter"
}, {
"url" : "https://d2ojpxxtu63wzl.cloudfront.net/static/3f64db7ba9331fbd1e4cc11655e2d3d4_a2477a83cafc8a98d5533f3617f0b1db2796ad0826482e2eabdc8d3345d70c17",
"label" : "twitter"
}, {
"url" : "https://d2ojpxxtu63wzl.cloudfront.net/static/ee07ac81180408fde663426d3b0afb3f_3a1154347631c037b9bd2b2f33d4cbc8511d58f5c11ad3cbbc319957d1a5149b",
"label" : "pinterest"
}, {
"url" : "https://d2ojpxxtu63wzl.cloudfront.net/static/80885c5e8b570e69bdc55d29aad115cd_a1ce9fb51ea43971d861e452034056d807422a391ac8e27f76ee4a9e803698d1",
"label" : "googleplus"
}, {
"url" : "https://d2ojpxxtu63wzl.cloudfront.net/static/4be5211e4b0129d1c8d41e84f257f343_3d84b3de68d6060243972af12a8ca67c4a595fd86a4419d50bf429e6d778ce2d",
"label" : "other"
}, {
"url" : "https://d2ojpxxtu63wzl.cloudfront.net/static/7e9aa6402ff2975e297a01243c358619_c0b8d4a63a52f4a47106494561c0332b79f848b40fcbe92336a0a17b843f44f8",
"label" : "other"
} ],
"keywords" : [ "APIs", "Boulder", "Business", "Colorado", "Contact Management", "Denver", "Developer APIs", "Marketing", "Social Media", "Software", "Techstars", "Venture Capital" ]
},
"socialProfiles" : [ {
"bio" : "FullContact automatically cleans your contacts, enriches them with social profile data, and continually syncs them with all your contact sources.\n\nFor developers, we offer a suite of contact management APIs to normalize, de-duplicate, and enrich contact data with social profiles.\n\nAs Dropbox did for files and Evernote did for notes, FullContact is doing for contacts. And we’re providing it to individuals, businesses, and developers.",
"typeId" : "facebook",
"typeName" : "Facebook",
"url" : "https://www.facebook.com/FullContactAPI",
"username" : "FullContactAPI",
"id" : "159926450745554"
}, {
"bio" : "We're solving the world's contact information problem. Get your contacts under control with @FullContactApp & check out @FullContactAPI for our APIs.",
"followers" : 6279,
"following" : 1756,
"typeId" : "twitter",
"typeName" : "Twitter",
"url" : "https://twitter.com/FullContactInc",
"username" : "FullContactInc",
"id" : "142954090"
}, {
"bio" : "The API that turns partial contact information into full contact information. We provide data enrichment, de-duplication, normalization, and much more.",
"followers" : 5032,
"following" : 2444,
"typeId" : "twitter",
"typeName" : "Twitter",
"url" : "https://twitter.com/FullContactAPI",
"username" : "FullContactAPI",
"id" : "340611236"
}, {
"bio" : "Keep your contact information clean, complete & current across all your address books.",
"followers" : 3395,
"following" : 1561,
"typeId" : "twitter",
"typeName" : "Twitter",
"url" : "https://twitter.com/FullContactApp",
"username" : "FullContactApp",
"id" : "451688048"
}, {
"bio" : "FullContact's address book brings all of your contacts into one place and keeps them automatically up to date on the web, as well as on your iPhone and iPad. \n\nAdd photos to your contacts. Find them on social networks like Twitter, Facebook, LinkedIn and of course AngelList. It's the address book that busy professionals from any walk of life can appreciate, and best of all it's free. \n\nFor developers, the suite of FullContact APIs builds powerful, complete profiles of contacts that can be included in any application.",
"followers" : 259,
"typeId" : "angellist",
"typeName" : "AngelList",
"url" : "https://angel.co/fullcontact",
"username" : "fullcontact"
}, {
"bio" : "FullContact provides a suite of cloud-based contact management solutions for businesses, developers, and individuals.",
"typeId" : "crunchbasecompany",
"typeName" : "CrunchBase",
"url" : "http://www.crunchbase.com/organization/fullcontact",
"username" : "fullcontact"
}, {
"bio" : "FullContact is the API that keeps contact information current. We build APIs that developers can integrate into their applications using any language.",
"followers" : 28,
"following" : 55,
"typeId" : "pinterest",
"typeName" : "Pinterest",
"url" : "http://www.pinterest.com/fullcontact/",
"username" : "fullcontact"
}, {
"bio" : "All your contacts in one place and automatically up-to-date. Learn more about how we're solving the world's contact information problem at https://www.fullcontact.com.",
"typeId" : "google",
"typeName" : "GooglePlus",
"url" : "https://plus.google.com/u/0/107620035082673219790",
"id" : "107620035082673219790"
}, {
"typeId" : "klout",
"typeName" : "Klout",
"url" : "http://klout.com/FullContactApp",
"username" : "FullContactApp",
"id" : "85568398087860504"
}, {
"typeId" : "klout",
"typeName" : "Klout",
"url" : "http://klout.com/FullContactAPI",
"username" : "FullContactAPI",
"id" : "33777001971317895"
}, {
"bio" : "FullContact is solving the world's contact information problem by providing APIs to software developers to keep contact information clean, complete and current. FullContact provides identity resolution for all of the disparate pieces of contact information out there on the web. We do this by aggregating billions of contact records, all with numerous attributes, including quality, freshness and frequency. Our patent pending algorithms process all of this data and automatically produce clean, accurate full contact records. As a final step, we then check each data element to make sure that it's publicly available before providing it to our customers. FullContact is a TechStars Boulder 2011 Company.",
"typeId" : "linkedincompany",
"typeName" : "LinkedIn",
"url" : "https://www.linkedin.com/company/fullcontact-inc-",
"username" : "fullcontact-inc-",
"id" : "2431118"
} ],
"traffic" : {
"topCountryRanking" : [ {
"rank" : 7914,
"locale" : "us"
}, {
"rank" : 14756,
"locale" : "in"
}, {
"rank" : 10628,
"locale" : "gb"
} ],
"ranking" : [ {
"rank" : 19254,
"locale" : "global"
}, {
"rank" : 7914,
"locale" : "us"
} ]
}
}
37 changes: 37 additions & 0 deletions spec/ruby_fullcontact/client/company_spec.rb
@@ -0,0 +1,37 @@
require 'helper'

describe FullContact::Client::Company do
FullContact::Configuration::VALID_FORMATS.each do |format|
context ".new(:format => '#{format}')" do
before do
@client = FullContact::Client.new(:format => format, :api_key => 'api_key')
end

end
end

context "when parsing a response" do

before do
FullContact.configure do |config|
config.api_key = "api_key"
end

stub_get("company/lookup.json").
with(:query => {:apiKey => "api_key", :domain => "fullcontact.com"}).
to_return(:body => fixture("company.json"), :headers => {:content_type => "application/json; charset=utf-8"})

stub_get("company/lookup.json").
with(:query => {:apiKey => "api_key", :domain => "fullcontact.com"}).
to_return(:body => fixture("company.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end

it 'should rubyize keys' do
expect(FullContact.company(domain: "fullcontact.com").organization.name).to(eq("FullContact Inc."))

expect(FullContact.company(domain: "fullcontact.com")).to satisfy do |v|
v.keys.all? { |k| !k.match(/[A-Z]/) }
end
end
end
end
2 changes: 1 addition & 1 deletion spec/ruby_fullcontact/client/person_spec.rb
@@ -1,6 +1,6 @@
require 'helper'

describe FullContact::Client do
describe FullContact::Client::Person do
FullContact::Configuration::VALID_FORMATS.each do |format|
context ".new(:format => '#{format}')" do
before do
Expand Down

0 comments on commit fb2fd99

Please sign in to comment.