Permalink
Browse files

Merge pull request #1 from scottwater/person

Improved Person API & Updated gem versions
  • Loading branch information...
2 parents 3c300e8 + 9821d96 commit 78c041fbb2891e2cbc82eb7c9d3db38c6118becc @Xorlev Xorlev committed Apr 5, 2012
View
8 fullcontact.gemspec
@@ -11,10 +11,10 @@ Gem::Specification.new do |s|
s.add_development_dependency 'webmock', '~> 1.6'
s.add_development_dependency 'yard', '~> 0.7'
s.add_runtime_dependency 'hashie', '~> 1.2.0'
- s.add_runtime_dependency 'faraday', '~> 0.6.1'
- s.add_runtime_dependency 'faraday_middleware', '~> 0.6.3'
- s.add_runtime_dependency 'multi_json', '~> 1.0.0'
- s.add_runtime_dependency 'multi_xml', '~> 0.2.0'
+ s.add_runtime_dependency 'faraday', '~> 0.7.3'
+ s.add_runtime_dependency 'faraday_middleware', '~> 0.8.6'
+ s.add_runtime_dependency 'multi_json', '~> 1.2.0'
+ s.add_runtime_dependency 'multi_xml', '~> 0.4.2'
s.add_runtime_dependency 'rash', '~> 0.3.0'
s.author = "Brandon West"
View
10 lib/fullcontact/client/person.rb
@@ -1,10 +1,14 @@
module FullContact
class Client
module Person
- # Returns extended information for a given email
+ # Returns extended information for a given person (email, phone, twitter or facebook)
#
- def person(email)
- response = get('person', :email => email)
+ def person(options={})
+ if options.is_a?(String)
+ warn "[DEPRECATION] supplying an email address directly is deprecated. Please use {email: #{options}} instead."
+ options = {:email => options}
+ end
+ response = get('person', options)
format.to_s.downcase == 'xml' ? response['person'] : response
end
end
View
4 spec/faraday/response_spec.rb
@@ -30,7 +30,7 @@
it "should raise #{exception.name} error" do
lambda do
- @client.person( 'brawest@gmail.com')
+ @client.person(:email => 'brawest@gmail.com')
end.should raise_error(exception)
end
end
@@ -46,7 +46,7 @@
it "should raise #{exception.name} error" do
lambda do
- @client.person( 'brawest@gmail.com')
+ @client.person(:email => 'brawest@gmail.com')
end.should raise_error(exception)
end
end
View
12 spec/fullcontact_spec.rb
@@ -17,19 +17,25 @@
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"})
end
it "should get the correct resource" do
- FullContact.person("brawest@gmail.com")
+ FullContact.person(email: "brawest@gmail.com")
a_get("person.json")
.with(:query => {:apiKey => "api_key", :email => "brawest@gmail.com"})
.should have_been_made
end
- it "should return the same results as a client" do
- FullContact.person("brawest@gmail.com").should == FullContact::Client.new.person("brawest@gmail.com")
+ it "should return the same results as a client by email" do
+ FullContact.person(:email => "brawest@gmail.com").should == FullContact::Client.new.person(:email => "brawest@gmail.com")
end
+ it "should return the same results as a client by twitter" do
+ FullContact.person(:twitter => "brawtest").should == FullContact::Client.new.person(:twitter => "brawtest")
+ end
end
describe '.respond_to?' do
View
2 spec/ruby_fullcontact/client_spec.rb
@@ -4,7 +4,7 @@
it "should connect using the endpoint configuration" do
client = FullContact::Client.new
endpoint = URI.parse(client.api_endpoint)
- connection = client.send(:connection).build_url(nil).to_s
+ connection = "#{client.send(:connection).build_url(nil).to_s}/"
connection.should == endpoint.to_s
end
end
View
BIN vendor/cache/addressable-2.2.6.gem
Binary file not shown.
View
BIN vendor/cache/faraday-0.6.1.gem
Binary file not shown.
View
BIN vendor/cache/multi_json-1.0.3.gem
Binary file not shown.
View
BIN vendor/cache/multi_xml-0.2.2.gem
Binary file not shown.

0 comments on commit 78c041f

Please sign in to comment.