fullcontact 0.7.0 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.rspec +1 -1
- data/LICENSE.md +18 -17
- data/README.md +18 -5
- data/fullcontact.gemspec +5 -5
- data/lib/faraday/response/fullcontact_errors.rb +23 -20
- data/lib/fullcontact.rb +1 -0
- data/lib/fullcontact/client/person.rb +10 -10
- data/lib/fullcontact/configuration.rb +19 -22
- data/lib/fullcontact/connection.rb +6 -8
- data/lib/fullcontact/error.rb +20 -8
- data/lib/fullcontact/request.rb +1 -1
- data/lib/fullcontact/version.rb +1 -1
- data/spec/faraday/response_spec.rb +17 -17
- data/spec/fullcontact_spec.rb +21 -21
- data/spec/ruby_fullcontact/api_spec.rb +13 -13
- data/spec/ruby_fullcontact/client/person_spec.rb +1 -1
- metadata +28 -41
- data/VERSION +0 -1
- data/lib/faraday/response/raise_http_4xx.rb +0 -45
- data/lib/faraday/response/raise_http_5xx.rb +0 -24
data/.rspec
CHANGED
data/LICENSE.md
CHANGED
@@ -1,20 +1,21 @@
|
|
1
|
-
|
1
|
+
The MIT License (MIT)
|
2
2
|
|
3
|
-
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
3
|
+
Copyright (c) 2014 FullContact Inc. and contributors
|
10
4
|
|
11
|
-
|
12
|
-
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
13
11
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -2,10 +2,20 @@ FullContact Ruby Gem
|
|
2
2
|
====================
|
3
3
|
A Ruby wrapper for the [FullContact API](http://www.fullcontact.com/)
|
4
4
|
|
5
|
+
|
6
|
+
[](http://badge.fury.io/rb/fullcontact)
|
7
|
+
[](https://codeclimate.com/github/fullcontact/fullcontact-api-ruby)
|
8
|
+
[](https://codeclimate.com/github/fullcontact/fullcontact-api-ruby)
|
9
|
+
|
5
10
|
Changes
|
6
11
|
-------
|
7
|
-
|
8
|
-
|
12
|
+
- 0.8.0
|
13
|
+
- Hashie now allowed from [2.2, 4.0) to support a wide range of other applications
|
14
|
+
- Default useragent includes version number for our own information
|
15
|
+
- Useless XML mode and dep on `multi_xml` removed
|
16
|
+
- Code reformatting & basic code hygiene, prep for new features in 0.9.0
|
17
|
+
- 0.7.0 - Faraday 0.9.0
|
18
|
+
- 0.6.0 - Removal of timeoutSeconds parameter. This parameter is automatically stripped from your request if included.
|
9
19
|
|
10
20
|
Installation
|
11
21
|
------------
|
@@ -54,13 +64,16 @@ Usage Examples
|
|
54
64
|
Contributions
|
55
65
|
-------------
|
56
66
|
- Michael Rose (Xorlev)
|
67
|
+
- Brandon West (bwest)
|
57
68
|
- Ian Fisher (i-taptera)
|
58
69
|
- Scott Watermasysk (scottwater)
|
59
70
|
- Stefano Fontanelli (stefanofontanelli)
|
60
71
|
- John Bachir (jjb)
|
61
72
|
|
62
|
-
|
73
|
+
License
|
63
74
|
---------
|
64
|
-
Copyright (c) 2014 FullContact
|
75
|
+
Copyright (c) 2014 FullContact Inc. and contributors
|
76
|
+
|
77
|
+
|
65
78
|
|
66
|
-
See [LICENSE](https://github.com/
|
79
|
+
See [LICENSE](https://github.com/fullcontact/fullcontact-api-ruby/blob/master/LICENSE.md) for details.
|
data/fullcontact.gemspec
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
$:.push File.expand_path(
|
3
|
-
require
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'fullcontact/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.add_development_dependency 'maruku', '~> 0.6'
|
7
7
|
s.add_development_dependency 'nokogiri', '~> 1.4'
|
8
8
|
s.add_development_dependency 'rake', '~> 0.9'
|
9
|
-
s.add_development_dependency 'rspec', '~>
|
9
|
+
s.add_development_dependency 'rspec', '~> 3.1'
|
10
10
|
s.add_development_dependency 'simplecov', '~> 0.4'
|
11
11
|
s.add_development_dependency 'webmock', '~> 1.6'
|
12
12
|
s.add_development_dependency 'yard', '~> 0.7'
|
13
13
|
s.add_runtime_dependency 'hashie', '>= 2.0'
|
14
14
|
s.add_runtime_dependency 'faraday', '~> 0.9.0'
|
15
15
|
s.add_runtime_dependency 'faraday_middleware', '>= 0.9'
|
16
|
-
s.add_runtime_dependency 'multi_xml', '>= 0.5'
|
17
16
|
s.add_runtime_dependency 'rash', '>= 0.4'
|
18
17
|
|
19
|
-
s.author =
|
18
|
+
s.author = 'FullContact, Inc.'
|
20
19
|
s.description = %q{A Ruby wrapper for the FullContact API}
|
21
20
|
s.email = ['support@fullcontact.com']
|
21
|
+
s.license = 'MIT'
|
22
22
|
|
23
23
|
s.post_install_message = ''
|
24
24
|
|
@@ -1,27 +1,30 @@
|
|
1
1
|
module Faraday
|
2
2
|
class Response::FullContactErrors < Response::Middleware
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
3
|
+
def on_complete(env)
|
4
|
+
case env[:status]
|
5
|
+
when 400
|
6
|
+
raise FullContact::BadRequest.new(error_message(env), env[:response_headers])
|
7
|
+
when 401
|
8
|
+
raise FullContact::Unauthorized.new(error_message(env), env[:response_headers])
|
9
|
+
when 403
|
10
|
+
raise FullContact::Forbidden.new(error_message(env), env[:response_headers])
|
11
|
+
when 404
|
12
|
+
raise FullContact::NotFound.new(error_message(env), env[:response_headers])
|
13
|
+
when 422
|
14
|
+
raise FullContact::Invalid.new(error_message(env), env[:response_headers])
|
15
|
+
when 429
|
16
|
+
# Note: not currently in use
|
17
|
+
raise FullContact::RateLimited.new(error_message(env), env[:response_headers])
|
18
|
+
when 500
|
19
|
+
raise FullContact::InternalServerError.new(error_message(env), env[:response_headers])
|
20
|
+
when 502
|
21
|
+
raise FullContact::BadGateway.new(error_message(env), env[:response_headers])
|
22
|
+
when 503
|
23
|
+
raise FullContact::ServiceUnavailable.new(error_message(env), env[:response_headers])
|
21
24
|
end
|
22
|
-
|
25
|
+
end
|
23
26
|
|
24
|
-
|
27
|
+
def error_message(env)
|
25
28
|
"#{env[:method].to_s.upcase} #{env[:url].to_s}: #{env[:status]}"
|
26
29
|
end
|
27
30
|
|
data/lib/fullcontact.rb
CHANGED
@@ -3,20 +3,20 @@ module FullContact
|
|
3
3
|
module Person
|
4
4
|
# Returns extended information for a given person (email, phone, twitter or facebook)
|
5
5
|
#
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
def person(options={}, faraday_options={})
|
7
|
+
if options.is_a?(String)
|
8
|
+
warn "[DEPRECATION] supplying an email address directly is deprecated. Please use {email: #{options}} instead. This will be removed in 0.9.0."
|
9
|
+
options = {:email => options}
|
10
|
+
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
if options.has_key?(:timeoutSeconds)
|
13
|
+
options.delete(:timeoutSeconds)
|
14
|
+
warn '[DEPRECATION] timeoutSeconds is no longer a supported parameter. It has been removed from your request.'
|
15
|
+
end
|
16
16
|
|
17
17
|
response = get('person', options, false, faraday_options)
|
18
18
|
format.to_s.downcase == 'xml' ? response['person'] : response
|
19
19
|
end
|
20
|
-
|
20
|
+
end
|
21
21
|
end
|
22
22
|
end
|
@@ -1,24 +1,21 @@
|
|
1
1
|
require 'faraday'
|
2
|
+
require 'fullcontact/version'
|
2
3
|
|
3
4
|
module FullContact
|
4
5
|
# Defines constants and methods related to configuration
|
5
6
|
module Configuration
|
6
7
|
# An array of valid keys in the options hash when configuring a {FullContact::API}
|
7
8
|
VALID_OPTIONS_KEYS = [
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
:adapter,
|
10
|
+
:api_key,
|
11
|
+
:endpoint,
|
12
|
+
:format,
|
13
|
+
:gateway,
|
14
|
+
:proxy,
|
15
|
+
:user_agent].freeze
|
15
16
|
|
16
17
|
# An array of valid request/response formats
|
17
|
-
|
18
|
-
# @note Not all methods support the XML format.
|
19
|
-
VALID_FORMATS = [
|
20
|
-
:json,
|
21
|
-
:xml].freeze
|
18
|
+
VALID_FORMATS = [:json].freeze
|
22
19
|
|
23
20
|
# The adapter that will be used to connect if none is set
|
24
21
|
#
|
@@ -37,11 +34,11 @@ module FullContact
|
|
37
34
|
# @note JSON is preferred over XML because it is more concise and faster to parse.
|
38
35
|
DEFAULT_FORMAT = :json
|
39
36
|
|
40
|
-
|
37
|
+
# By default, don't use a proxy server
|
41
38
|
DEFAULT_PROXY = nil
|
42
39
|
|
43
40
|
# The user agent that will be sent to the API endpoint if none is set
|
44
|
-
DEFAULT_USER_AGENT =
|
41
|
+
DEFAULT_USER_AGENT = "FullContact Ruby Client/#{FullContact::VERSION}".freeze
|
45
42
|
|
46
43
|
DEFAULT_GATEWAY = nil
|
47
44
|
|
@@ -61,19 +58,19 @@ module FullContact
|
|
61
58
|
# Create a hash of options and their values
|
62
59
|
def options
|
63
60
|
options = {}
|
64
|
-
VALID_OPTIONS_KEYS.each{|k| options[k] = send(k) }
|
61
|
+
VALID_OPTIONS_KEYS.each { |k| options[k] = send(k) }
|
65
62
|
options
|
66
63
|
end
|
67
64
|
|
68
65
|
# Reset all configuration options to defaults
|
69
66
|
def reset
|
70
|
-
self.adapter
|
71
|
-
self.api_key
|
72
|
-
self.endpoint
|
73
|
-
self.format
|
74
|
-
self.proxy
|
75
|
-
self.user_agent
|
76
|
-
self.gateway
|
67
|
+
self.adapter = DEFAULT_ADAPTER
|
68
|
+
self.api_key = DEFAULT_API_KEY
|
69
|
+
self.endpoint = DEFAULT_ENDPOINT
|
70
|
+
self.format = DEFAULT_FORMAT
|
71
|
+
self.proxy = DEFAULT_PROXY
|
72
|
+
self.user_agent = DEFAULT_USER_AGENT
|
73
|
+
self.gateway = DEFAULT_GATEWAY
|
77
74
|
self
|
78
75
|
end
|
79
76
|
end
|
@@ -10,10 +10,10 @@ module FullContact
|
|
10
10
|
|
11
11
|
def connection(raw=false, faraday_options={})
|
12
12
|
options = {
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
:headers => {'Accept' => "application/#{format}", 'User-Agent' => user_agent},
|
14
|
+
:proxy => proxy,
|
15
|
+
:ssl => {:verify => false},
|
16
|
+
:url => api_endpoint,
|
17
17
|
}.merge(faraday_options)
|
18
18
|
|
19
19
|
Faraday.new(options) do |builder|
|
@@ -22,10 +22,8 @@ module FullContact
|
|
22
22
|
builder.use Faraday::Response::Rashify unless raw
|
23
23
|
unless raw
|
24
24
|
case format.to_s.downcase
|
25
|
-
|
26
|
-
|
27
|
-
when 'xml'
|
28
|
-
builder.use Faraday::Response::ParseXml
|
25
|
+
when 'json'
|
26
|
+
builder.use Faraday::Response::ParseJson
|
29
27
|
end
|
30
28
|
end
|
31
29
|
builder.use Faraday::Response::FullContactErrors
|
data/lib/fullcontact/error.rb
CHANGED
@@ -10,26 +10,38 @@ module FullContact
|
|
10
10
|
end
|
11
11
|
|
12
12
|
# Raised when FullContact returns the HTTP status code 400
|
13
|
-
class BadRequest < Error;
|
13
|
+
class BadRequest < Error;
|
14
|
+
end
|
14
15
|
|
15
16
|
# Raised when FullContact returns the HTTP status code 401
|
16
|
-
class Unauthorized < Error;
|
17
|
+
class Unauthorized < Error;
|
18
|
+
end
|
17
19
|
|
18
20
|
# Raised when FullContact returns the HTTP status code 403
|
19
|
-
class Forbidden < Error;
|
21
|
+
class Forbidden < Error;
|
22
|
+
end
|
20
23
|
|
21
24
|
# Raised when FullContact returns the HTTP status code 404
|
22
|
-
class NotFound < Error;
|
25
|
+
class NotFound < Error;
|
26
|
+
end
|
23
27
|
|
24
28
|
# Raised when FullContact returns the HTTP status code 422
|
25
|
-
class Invalid < Error;
|
29
|
+
class Invalid < Error;
|
30
|
+
end
|
31
|
+
|
32
|
+
# Raised when FullContact returns the HTTP status code 429
|
33
|
+
class RateLimited < Error;
|
34
|
+
end
|
26
35
|
|
27
36
|
# Raised when FullContact returns the HTTP status code 500
|
28
|
-
class InternalServerError < Error;
|
37
|
+
class InternalServerError < Error;
|
38
|
+
end
|
29
39
|
|
30
40
|
# Raised when FullContact returns the HTTP status code 502
|
31
|
-
class BadGateway < Error;
|
41
|
+
class BadGateway < Error;
|
42
|
+
end
|
32
43
|
|
33
44
|
# Raised when FullContact returns the HTTP status code 503
|
34
|
-
class ServiceUnavailable < Error;
|
45
|
+
class ServiceUnavailable < Error;
|
46
|
+
end
|
35
47
|
end
|
data/lib/fullcontact/request.rb
CHANGED
data/lib/fullcontact/version.rb
CHANGED
@@ -4,28 +4,28 @@ require 'fullcontact'
|
|
4
4
|
|
5
5
|
describe Faraday::Response do
|
6
6
|
before do
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
FullContact.configure do |config|
|
8
|
+
config.api_key = "api_key"
|
9
|
+
end
|
10
10
|
@client = FullContact::Client.new
|
11
11
|
end
|
12
12
|
|
13
13
|
{
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
14
|
+
400 => FullContact::BadRequest,
|
15
|
+
401 => FullContact::Unauthorized,
|
16
|
+
403 => FullContact::Forbidden,
|
17
|
+
404 => FullContact::NotFound,
|
18
|
+
422 => FullContact::Invalid,
|
19
|
+
500 => FullContact::InternalServerError,
|
20
|
+
502 => FullContact::BadGateway,
|
21
|
+
503 => FullContact::ServiceUnavailable,
|
22
22
|
}.each do |status, exception|
|
23
23
|
if (status >= 500)
|
24
24
|
context "when HTTP status is #{status}" do
|
25
25
|
before do
|
26
26
|
stub_get('person.json').
|
27
|
-
|
28
|
-
|
27
|
+
with(:query => {:apiKey => "api_key", :email => 'brawest@gmail.com'}).
|
28
|
+
to_return(:status => status)
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should raise #{exception.name} error" do
|
@@ -39,14 +39,14 @@ describe Faraday::Response do
|
|
39
39
|
context "when HTTP status is #{status} and body is #{body||='nil'}" do
|
40
40
|
before do
|
41
41
|
body_message = '{"'+body+'":"test"}' unless body.nil?
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
stub_get('person.json').
|
43
|
+
with(:query => {:apiKey => "api_key", :email => 'brawest@gmail.com'}).
|
44
|
+
to_return(:status => status, :body => body_message)
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should raise #{exception.name} error" do
|
48
48
|
lambda do
|
49
|
-
|
49
|
+
@client.person(:email => 'brawest@gmail.com')
|
50
50
|
end.should raise_error(exception)
|
51
51
|
end
|
52
52
|
end
|
data/spec/fullcontact_spec.rb
CHANGED
@@ -9,31 +9,31 @@ describe FullContact do
|
|
9
9
|
context "when delegating to a client" do
|
10
10
|
|
11
11
|
before do
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
FullContact.configure do |config|
|
13
|
+
config.api_key = "api_key"
|
14
|
+
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
stub_get("person.json").
|
17
|
+
with(:query => {:apiKey => "api_key", :email => "brawest@gmail.com"}).
|
18
|
+
to_return(:body => fixture("person.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
stub_get("person.json").
|
21
|
+
with(:query => {:apiKey => "api_key", :twitter => "brawtest"}).
|
22
|
+
to_return(:body => fixture("person.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should get the correct resource" do
|
26
|
-
FullContact.person(email:
|
26
|
+
FullContact.person(email: "brawest@gmail.com")
|
27
27
|
a_get("person.json")
|
28
|
-
|
29
|
-
|
28
|
+
.with(:query => {:apiKey => "api_key", :email => "brawest@gmail.com"})
|
29
|
+
.should have_been_made
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should strip the timeoutSeconds parameter" do
|
33
|
-
FullContact.person(email:
|
33
|
+
FullContact.person(email: "brawest@gmail.com", timeoutSeconds: 30)
|
34
34
|
a_get("person.json")
|
35
|
-
|
36
|
-
|
35
|
+
.with(:query => {:apiKey => "api_key", :email => "brawest@gmail.com"})
|
36
|
+
.should have_been_made
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should return the same results as a client by email" do
|
@@ -45,12 +45,6 @@ describe FullContact do
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
describe '.respond_to?' do
|
49
|
-
it 'takes an optional include private argument' do
|
50
|
-
FullContact.respond_to?(:client, true).should be_true
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
48
|
describe ".client" do
|
55
49
|
it "should be a FullContact::Client" do
|
56
50
|
FullContact.client.should be_a FullContact::Client
|
@@ -102,6 +96,12 @@ describe FullContact do
|
|
102
96
|
end
|
103
97
|
end
|
104
98
|
|
99
|
+
describe ".user_agent" do
|
100
|
+
it "should return the default user agent" do
|
101
|
+
expect(FullContact.user_agent).to satisfy { |ua| ua.start_with? 'FullContact Ruby Client/' }
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
105
|
describe ".user_agent=" do
|
106
106
|
it "should set the user_agent" do
|
107
107
|
FullContact.user_agent = 'Custom User Agent'
|
@@ -6,7 +6,7 @@ describe FullContact::API do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
context "with module configuration" do
|
9
|
-
|
9
|
+
before do
|
10
10
|
FullContact.configure do |config|
|
11
11
|
@keys.each do |key|
|
12
12
|
config.send("#{key}=", key)
|
@@ -29,24 +29,24 @@ describe FullContact::API do
|
|
29
29
|
|
30
30
|
before do
|
31
31
|
@configuration = {
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
32
|
+
:api_key => 'api_key',
|
33
|
+
:adapter => :typhoeus,
|
34
|
+
:endpoint => 'http://tumblr.com/',
|
35
|
+
:gateway => 'apigee-1111.apigee.com',
|
36
|
+
:format => :xml,
|
37
|
+
:proxy => 'http://erik:sekret@proxy.example.com:8080',
|
38
|
+
:user_agent => 'Custom User Agent',
|
39
39
|
}
|
40
40
|
end
|
41
41
|
|
42
42
|
context "during initialization"
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
44
|
+
it "should override module configuration" do
|
45
|
+
api = FullContact::API.new(@configuration)
|
46
|
+
@keys.each do |key|
|
47
|
+
api.send(key).should == @configuration[key]
|
49
48
|
end
|
49
|
+
end
|
50
50
|
|
51
51
|
context "after initilization" do
|
52
52
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fullcontact
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-11-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: maruku
|
16
|
-
requirement: &
|
16
|
+
requirement: &70332720405680 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0.6'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70332720405680
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: nokogiri
|
27
|
-
requirement: &
|
27
|
+
requirement: &70332720404800 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '1.4'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70332720404800
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &70332720404160 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,21 +43,21 @@ dependencies:
|
|
43
43
|
version: '0.9'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70332720404160
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &70332720403700 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '3.1'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70332720403700
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: simplecov
|
60
|
-
requirement: &
|
60
|
+
requirement: &70332720403200 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0.4'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70332720403200
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: webmock
|
71
|
-
requirement: &
|
71
|
+
requirement: &70332720402680 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '1.6'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70332720402680
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: yard
|
82
|
-
requirement: &
|
82
|
+
requirement: &70332720401800 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0.7'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70332720401800
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: hashie
|
93
|
-
requirement: &
|
93
|
+
requirement: &70332720401200 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '2.0'
|
99
99
|
type: :runtime
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70332720401200
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: faraday
|
104
|
-
requirement: &
|
104
|
+
requirement: &70332720400480 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ~>
|
@@ -109,10 +109,10 @@ dependencies:
|
|
109
109
|
version: 0.9.0
|
110
110
|
type: :runtime
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *70332720400480
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: faraday_middleware
|
115
|
-
requirement: &
|
115
|
+
requirement: &70332720399600 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
118
|
- - ! '>='
|
@@ -120,21 +120,10 @@ dependencies:
|
|
120
120
|
version: '0.9'
|
121
121
|
type: :runtime
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
124
|
-
- !ruby/object:Gem::Dependency
|
125
|
-
name: multi_xml
|
126
|
-
requirement: &70341113063500 !ruby/object:Gem::Requirement
|
127
|
-
none: false
|
128
|
-
requirements:
|
129
|
-
- - ! '>='
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0.5'
|
132
|
-
type: :runtime
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: *70341113063500
|
123
|
+
version_requirements: *70332720399600
|
135
124
|
- !ruby/object:Gem::Dependency
|
136
125
|
name: rash
|
137
|
-
requirement: &
|
126
|
+
requirement: &70332720399140 !ruby/object:Gem::Requirement
|
138
127
|
none: false
|
139
128
|
requirements:
|
140
129
|
- - ! '>='
|
@@ -142,7 +131,7 @@ dependencies:
|
|
142
131
|
version: '0.4'
|
143
132
|
type: :runtime
|
144
133
|
prerelease: false
|
145
|
-
version_requirements: *
|
134
|
+
version_requirements: *70332720399140
|
146
135
|
description: A Ruby wrapper for the FullContact API
|
147
136
|
email:
|
148
137
|
- support@fullcontact.com
|
@@ -157,12 +146,9 @@ files:
|
|
157
146
|
- LICENSE.md
|
158
147
|
- README.md
|
159
148
|
- Rakefile
|
160
|
-
- VERSION
|
161
149
|
- fullcontact.gemspec
|
162
150
|
- lib/faraday/request/gateway.rb
|
163
151
|
- lib/faraday/response/fullcontact_errors.rb
|
164
|
-
- lib/faraday/response/raise_http_4xx.rb
|
165
|
-
- lib/faraday/response/raise_http_5xx.rb
|
166
152
|
- lib/fullcontact.rb
|
167
153
|
- lib/fullcontact/api.rb
|
168
154
|
- lib/fullcontact/client.rb
|
@@ -182,7 +168,8 @@ files:
|
|
182
168
|
- vendor/cache/maruku-0.6.0.gem
|
183
169
|
- vendor/cache/syntax-1.0.0.gem
|
184
170
|
homepage: https://github.com/fullcontact/fullcontact-api-ruby
|
185
|
-
licenses:
|
171
|
+
licenses:
|
172
|
+
- MIT
|
186
173
|
post_install_message: ''
|
187
174
|
rdoc_options: []
|
188
175
|
require_paths:
|
@@ -195,7 +182,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
195
182
|
version: '0'
|
196
183
|
segments:
|
197
184
|
- 0
|
198
|
-
hash: -
|
185
|
+
hash: -4162318102109248767
|
199
186
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
200
187
|
none: false
|
201
188
|
requirements:
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.0.1
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'faraday'
|
2
|
-
|
3
|
-
# @private
|
4
|
-
module Faraday
|
5
|
-
# @private
|
6
|
-
class Response::RaiseHttp4xx < Response::Middleware
|
7
|
-
def on_complete(env)
|
8
|
-
case env[:status].to_i
|
9
|
-
when 400
|
10
|
-
raise FullContact::BadRequest.new(error_message(env), env[:response_headers])
|
11
|
-
when 401
|
12
|
-
raise FullContact::Unauthorized.new(error_message(env), env[:response_headers])
|
13
|
-
when 403
|
14
|
-
raise FullContact::Forbidden.new(error_message(env), env[:response_headers])
|
15
|
-
when 404
|
16
|
-
raise FullContact::NotFound.new(error_message(env), env[:response_headers])
|
17
|
-
when 422
|
18
|
-
raise FullContact::Invalid.new(error_message(env), env[:response_headers])
|
19
|
-
end
|
20
|
-
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
|
26
|
-
def error_message(env)
|
27
|
-
"#{env[:method].to_s.upcase} #{env[:url].to_s}: #{env[:status]}#{error_body(env[:body])}"
|
28
|
-
end
|
29
|
-
|
30
|
-
def error_body(body)
|
31
|
-
if body.nil?
|
32
|
-
nil
|
33
|
-
elsif body['error']
|
34
|
-
": #{body['error']}"
|
35
|
-
elsif body['errors']
|
36
|
-
first = Array(body['errors']).first
|
37
|
-
if first.kind_of? Hash
|
38
|
-
": #{first['message'].chomp}"
|
39
|
-
else
|
40
|
-
": #{first.chomp}"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'faraday'
|
2
|
-
|
3
|
-
# @private
|
4
|
-
module Faraday
|
5
|
-
# @private
|
6
|
-
class Response::RaiseHttp5xx < Response::Middleware
|
7
|
-
def on_complete(env)
|
8
|
-
case env[:status].to_i
|
9
|
-
when 500
|
10
|
-
raise FullContact::InternalServerError.new(error_message(env, "Internal server error."), env[:response_headers])
|
11
|
-
when 502
|
12
|
-
raise FullContact::BadGateway.new(error_message(env, "FullContact is down or being upgraded."), env[:response_headers])
|
13
|
-
when 503
|
14
|
-
raise FullContact::ServiceUnavailable.new(error_message(env, "Service unavailable."), env[:response_headers])
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def error_message(env, body=nil)
|
21
|
-
"#{env[:method].to_s.upcase} #{env[:url].to_s}: #{[env[:status].to_s + ':', body].compact.join(' ')} Check http://status.fullcontact.cc/ for updates on the status of the FullContact service."
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|