Skip to content
This repository was archived by the owner on Aug 20, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Changes
-------

0.6.0 - Removal of timeoutSeconds parameter. This parameter is automatically stripped from your request if included.
0.7.0 - Added support for cardReader API

Installation
------------
Expand Down Expand Up @@ -43,6 +44,15 @@ Usage Examples

# Get person's family_name
puts person.contact_info.family_name

# Gets a list of all the cards a user has scanned
cards = FullContact.card_reader

# cards.total_pages will give you the number of pages you can request.
# cards.total_records will give you the total number of cards FullContact has on your account.

# Gets 2nd page of cards (note: pagination starts at 0)
cards = FullContact.card_reader(page:1)

Contributions
-------------
Expand Down
2 changes: 2 additions & 0 deletions lib/fullcontact/client.rb
Original file line number Diff line number Diff line change
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/card_reader'

alias :api_endpoint :endpoint

include FullContact::Client::Person
include FullContact::Client::CardReader
end
end
13 changes: 13 additions & 0 deletions lib/fullcontact/client/card_reader.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module FullContact
class Client
module CardReader
# Returns extended information for a given person (email, phone, twitter or facebook)
#
def card_reader(options={}, faraday_options={})
response = get('cardReader', options, false, faraday_options)
format.to_s.downcase == 'xml' ? response['response'] : response
end

end
end
end
2 changes: 1 addition & 1 deletion lib/fullcontact/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module FullContact
VERSION = "0.6.1"
VERSION = "0.7.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We follow semver here, please bump this to 0.7.0

end
256 changes: 256 additions & 0 deletions spec/fixtures/card_reader.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@
{
"count": 2,
"results": [
{
"vCardUrl": "https://d1h3f0foa0xzdz.cloudfront.net/85272/38DCH97KHH977EFG620F5TGH5VAQJG_c.vcf",
"lastWebhookAttempt": "2014-03-31T23:18:29.000Z",
"URID": "59760208-BF9A-468D-A0A6-E4FEAD1EECA1",
"status": "CALLBACK_MADE",
"webhookUrl": "https://sfdc-api.fullcontact.com/sfdc-api/cardReader/webhook",
"submitted": "2014-03-31T22:12:12.000Z",
"unverifiedFields": [
"organizations[0]",
"urls[1]"
],
"params": {
"apns": "c452031e60f21637058aa9ceeb34e4410ff5d71037f64b9d08e523fc769a0fef",
"longitude": "-104.872340",
"sf": "{\n\n}",
"latitude": "39.757752",
"notes": "",
"recordType": "0",
"version": "2.4"
},
"contact": {
"photos": [{
"primary": false,
"value": "https://example.net/123456-front.jpeg",
"type": "BusinessCard"
}],
"urls": [{
"value": "http://example.com",
"type": "Company"
}],
"organizations": [{
"title": null,
"isPrimary": true,
"name": "Example Corp."
}],
"name": {
"middleName": null,
"honorificPrefix": null,
"familyName": "Sample",
"givenName": "Joan",
"honorificSuffix": null
},
"phoneNumbers": [
{
"value": "+1 303-555-1212",
"type": "Work Fax"
},
{
"value": "+1 720-555-1212",
"type": "Work"
}
],
"addresses": [{
"streetAddress": "123 Main Ave #304",
"region": "CO",
"formatted": null,
"postalCode": "80202",
"extendedAddress": null,
"locality": "Denver",
"type": "Work",
"country": "United States"
}]
},
"id": "f191f5afc917d794fb8844f1f955ecc99bfca10f",
"contactId": "4LFKyufMSU",
"webhookAttempts": 1,
"addressBookId": "c977be6bf27a6c660cd4a8c1293e4ab1be81c03a",
"quality": "MEDIUM",
"unverifiedContact": {
"photos": [{
"primary": false,
"value": "https://example.net/123456-front.jpeg",
"type": "BusinessCard"
}],
"urls": [{
"value": "http://example.com",
"type": "Company"
}],
"organizations": [{
"title": null,
"isPrimary": true,
"name": "Example Corp."
}],
"name": {
"middleName": null,
"honorificPrefix": null,
"familyName": "Sample",
"givenName": "Joan",
"honorificSuffix": null
},
"phoneNumbers": [
{
"value": "+1 303-555-1212",
"type": "Work Fax"
},
{
"value": "+1 720-555-1212",
"type": "Work"
}
],
"addresses": [{
"streetAddress": "123 Main Ave #304",
"region": "CO",
"formatted": null,
"postalCode": "80202",
"extendedAddress": null,
"locality": "Denver",
"type": "Work",
"country": "United States"
}]
},
"unverifiedVCardUrl": "https://d1h3f0foa0xzdz.cloudfront.net/85272/38DCH97KHH797EFG620F5TGH5VAQJG.vcf"
},
{
"vCardUrl": "https://d1h3f0foa0xzdz.cloudfront.net/85272/2Y6VR14IXKO6PY019TNAFX3YSAMA9E_c.vcf",
"lastWebhookAttempt": "2014-03-20T00:53:12.000Z",
"URID": "05E93102-BA85-4369-9B98-9EAB814CABB0",
"status": "CALLBACK_MADE",
"webhookUrl": "https://sfdc-api.fullcontact.com/sfdc-api/cardReader/webhook",
"submitted": "2014-03-19T20:38:58.000Z",
"unverifiedFields": [
"urls[1]",
"name[2]"
],
"params": {
"apns": "c452031e60f21637058aa9ceeb34e4410ff5d71037f64b9d08e523fc769a0fef",
"longitude": "-105.016022",
"sf": "{\n\n}",
"latitude": "39.753488",
"notes": "",
"recordType": "0",
"version": "2.4"
},
"contact": {
"photos": [
{
"primary": false,
"value": "https://d1h3f0foa0xzdz.cloudfront.net/85272/dd587b781e539b98411d626360a10c251e76d2df-front.jpeg",
"type": "BusinessCard"
},
{
"primary": false,
"value": "https://d1h3f0foa0xzdz.cloudfront.net/85272/dd587b781e539b98411d626360a10c251e76d2df-back.jpeg",
"type": "BusinessCard"
}
],
"urls": [{
"value": "http://sweetcowicecream.com",
"type": "Company"
}],
"organizations": [{
"title": null,
"isPrimary": true,
"name": "Sweet Cow"
}],
"emails": [{
"value": "info@sweetcowicecream.com",
"type": "Work"
}],
"phoneNumbers": [
{
"value": "+1 303-666-4269",
"type": "Work"
},
{
"value": "+1 303-477-3269",
"type": "Work"
}
],
"addresses": [{
"streetAddress": "3475 W 32nd Ave",
"region": "CO",
"formatted": null,
"postalCode": "80027",
"extendedAddress": null,
"locality": "Louisville",
"type": "Work",
"country": "United States"
}]
},
"id": "dd587b781e539b98411d626360a10c251e76d2df",
"contactId": "2qMB12rhRG",
"webhookAttempts": 2,
"addressBookId": "c977be6bf72a6c660cd4a8c1293e4ab1be81c03a",
"quality": "MEDIUM",
"unverifiedContact": {
"photos": [
{
"primary": false,
"value": "https://d1h3f0foa0xzdz.cloudfront.net/85272/dd587b781e539b98411d626360a10c251e76d2df-front.jpeg",
"type": "BusinessCard"
},
{
"primary": false,
"value": "https://d1h3f0foa0xzdz.cloudfront.net/85272/dd587b781e539b98411d626360a10c251e76d2df-back.jpeg",
"type": "BusinessCard"
}
],
"urls": [
{
"value": "http://sweetcowicecream.com",
"type": "Company"
},
{
"value": "www.sweetcowicwstram.com",
"type": "Company"
}
],
"organizations": [{
"title": null,
"isPrimary": true,
"name": "Sweet Cow"
}],
"name": {
"middleName": null,
"honorificPrefix": null,
"familyName": "Barn",
"givenName": "Denver",
"honorificSuffix": null
},
"emails": [{
"value": "info@sweetcowicecream.com",
"type": "Work"
}],
"phoneNumbers": [
{
"value": "+1 303-666-4269",
"type": "Work"
},
{
"value": "+1 303-477-3269",
"type": "Work"
}
],
"addresses": [{
"streetAddress": "3475 W 32nd Ave",
"region": "CO",
"formatted": null,
"postalCode": "80027",
"extendedAddress": null,
"locality": "Louisville",
"type": "Work",
"country": "United States"
}]
},
"unverifiedVCardUrl": "https://d1h3f0foa0xzdz.cloudfront.net/85272/2Y6VR14IXKO6PY019TNAFX3YSAMA9E.vcf"
}
],
"status": 200,
"totalRecords": 2,
"currentPage": 0,
"totalPages": 1
}
42 changes: 29 additions & 13 deletions spec/fullcontact_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,39 @@
context "when delegating to a client" do

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

stub_get("person.json").
with(:query => {:apiKey => "api_key", :email => "brawest@gmail.com"}).
to_return(:body => fixture("person.json"), :headers => {:content_type => "application/json; charset=utf-8"})

stub_get("person.json").
with(:query => {:apiKey => "api_key", :email => "brawest@gmail.com"}).
to_return(:body => fixture("person.json"), :headers => {:content_type => "application/json; charset=utf-8"})
stub_get("person.json").
with(:query => {:apiKey => "api_key", :twitter => "brawtest"}).
to_return(:body => fixture("person.json"), :headers => {:content_type => "application/json; charset=utf-8"})

stub_get("person.json").
with(:query => {:apiKey => "api_key", :twitter => "brawtest"}).
to_return(:body => fixture("person.json"), :headers => {:content_type => "application/json; charset=utf-8"})
stub_get("cardReader.json").
with(:query => {:apiKey => "api_key"}).
to_return(:body => fixture("card_reader.json"), :headers => {:content_type => "application/json; charset=utf-8"})

stub_get("cardReader.json").
with(:query => {:apiKey => "api_key", :page => 2}).
to_return(:body => fixture("card_reader.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end

it "should get the correct resource" do
FullContact.person(email: "brawest@gmail.com")
a_get("person.json")
.with(:query => {:apiKey => "api_key", :email => "brawest@gmail.com"})
.should have_been_made
.with(:query => {:apiKey => "api_key", :email => "brawest@gmail.com"})
.should have_been_made
end

it "should strip the timeoutSeconds parameter" do
FullContact.person(email: "brawest@gmail.com", timeoutSeconds: 30)
a_get("person.json")
.with(:query => {:apiKey => "api_key", :email => "brawest@gmail.com"})
.should have_been_made
.with(:query => {:apiKey => "api_key", :email => "brawest@gmail.com"})
.should have_been_made
end

it "should return the same results as a client by email" do
Expand All @@ -43,6 +51,14 @@
it "should return the same results as a client by twitter" do
FullContact.person(:twitter => "brawtest").should == FullContact::Client.new.person(:twitter => "brawtest")
end

it "should return cardReader results to a client" do
FullContact.card_reader.should == FullContact::Client.new.card_reader
end

it "should return the specified page of cardReader results to a client" do
FullContact.card_reader(:page => 2).should == FullContact::Client.new.card_reader(:page => 2 )
end
end

describe '.respond_to?' do
Expand Down
12 changes: 12 additions & 0 deletions spec/ruby_fullcontact/client/card_reader_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require 'helper'

describe FullContact::Client 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
end