fullcontact 0.14.0 → 0.15.0

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.
@@ -1,9 +1,10 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
- - 1.9.3
5
4
  - 2.0.0
6
- - 2.1
5
+ - 2.1.0
6
+ - 2.2.0
7
+ - 2.3.0
7
8
 
8
9
  gemfile:
9
10
  - Gemfile
data/README.md CHANGED
@@ -9,8 +9,8 @@ A Ruby wrapper for the [FullContact API](http://www.fullcontact.com/)
9
9
 
10
10
  Changes
11
11
  -------
12
- - 0.14.0
13
- - Remove `plissken` gem to support Rails 5 (#42)
12
+ - 0.15.0 - Add header-based auth via `config.auth_type = :header` control.
13
+ - 0.14.0 - Remove `plissken` gem to support Rails 5 (#42)
14
14
  - 0.13.0
15
15
  - Raise `ArgumentError` if query by Facebook ID/username is used.
16
16
  - Remove deprecated messages.
@@ -45,7 +45,7 @@ Usage Examples
45
45
  FullContact.configure do |config|
46
46
  config.api_key = 'fullcontact_api_key_goes_here'
47
47
  end
48
-
48
+
49
49
  # Get information about an email address
50
50
  person = FullContact.person(email: 'bart@fullcontact.com')
51
51
  ```
@@ -64,21 +64,30 @@ But you can also turn it into a normal hash
64
64
  person.to_hash['contact_info']['family_name']
65
65
  => "Lorang"
66
66
  ```
67
+ Authentication is done through query parameters by default. If you want to use headers instead:
68
+
69
+ ```ruby
70
+ # This could go in an initializer
71
+ FullContact.configure do |config|
72
+ config.api_key = 'fullcontact_api_key_goes_here'
73
+ config.auth_type = :headers # :header or :query
74
+ end
75
+ ```
67
76
 
68
77
  There's other ways you can query the Person API:
69
78
  ```ruby
70
79
  # Get information about an email address, organized by hashes vs. lists
71
80
  person2 = FullContact.person(email: 'bart@fullcontact.com', style: 'dictionary')
72
-
81
+
73
82
  # You can pass in any arbitrary parameters the Person API supports
74
83
  person3 = FullContact.person(email: 'bart@fullcontact.com', style: 'dictionary', webhookUrl: 'https://...')
75
-
84
+
76
85
  # Get information about a twitter handle
77
86
  person4 = FullContact.person(twitter: "bartlorang")
78
-
87
+
79
88
  # Get information from a phone number
80
89
  person6 = FullContact.person(phone:13037170414)
81
-
90
+
82
91
  # Get information about a twitter and ensure a 30s socket open timeout and a 15s socket read timeout
83
92
  # Can throw a Faraday::Error::TimeoutError if timeouts are exceeded
84
93
  person7 = FullContact.person({:twitter => "bartlorang"}, {:request => {:timeout => 15, :open_timeout => 30}})
@@ -94,7 +103,7 @@ Response formats can more closely mirror FullContact's APIs by disabling snake_c
94
103
 
95
104
  person8 = FullContact.person(email: "bart@fullcontact.com")
96
105
 
97
- => #<Hashie::Mash contactInfo=#<Hashie::Mash chats=[#<Hashie::Mash client="gtalk" handle="lorangb@gmail.com">,
106
+ => #<Hashie::Mash contactInfo=#<Hashie::Mash chats=[#<Hashie::Mash client="gtalk" handle="lorangb@gmail.com">,
98
107
  #<Hashie::Mash client="skype" handle="bart.lorang">] familyName="Lorang" fullName="Bart Lorang" givenName="Bart...
99
108
  ```
100
109
 
@@ -107,7 +116,7 @@ You can also query the Company API
107
116
  => "FullContact Inc."
108
117
  ```
109
118
 
110
-
119
+
111
120
  Contributions
112
121
  -------------
113
122
  A full list of contributors can be found in
@@ -8,6 +8,7 @@ module FullContact
8
8
  VALID_OPTIONS_KEYS = [
9
9
  :adapter,
10
10
  :api_key,
11
+ :auth_type,
11
12
  :endpoint,
12
13
  :format,
13
14
  :skip_rubyize,
@@ -27,6 +28,9 @@ module FullContact
27
28
  # By default, don't set an application key
28
29
  DEFAULT_API_KEY = nil
29
30
 
31
+ # By default, use query parameters
32
+ DEFAULT_AUTH_TYPE = :query
33
+
30
34
  # The endpoint that will be used to connect if none is set
31
35
  #
32
36
  DEFAULT_ENDPOINT = 'https://api.fullcontact.com/v2/'.freeze
@@ -50,6 +54,8 @@ module FullContact
50
54
 
51
55
  DEFAULT_GATEWAY = nil
52
56
 
57
+ AUTH_HEADER_NAME = 'X-FullContact-APIKey'.freeze
58
+
53
59
  # @private
54
60
  attr_accessor *VALID_OPTIONS_KEYS
55
61
 
@@ -74,6 +80,7 @@ module FullContact
74
80
  def reset
75
81
  self.adapter = DEFAULT_ADAPTER
76
82
  self.api_key = DEFAULT_API_KEY
83
+ self.auth_type = DEFAULT_AUTH_TYPE
77
84
  self.endpoint = DEFAULT_ENDPOINT
78
85
  self.format = DEFAULT_FORMAT
79
86
  self.skip_rubyize = DEFAULT_SKIP_RUBYIZE
@@ -10,10 +10,16 @@ module FullContact
10
10
 
11
11
  # Perform an HTTP request
12
12
  def request(method, path, options, raw=false, faraday_options={})
13
- options[:apiKey] = FullContact.options[:api_key]
13
+ if FullContact.options[:auth_type] == :query
14
+ options[:apiKey] = FullContact.options[:api_key]
15
+ end
14
16
 
15
17
  response = connection(raw, faraday_options).send(method) do |request|
16
18
  request.url(formatted_path(path), options)
19
+
20
+ if FullContact.options[:auth_type] == :header
21
+ request.headers[FullContact::Configuration::AUTH_HEADER_NAME] = FullContact.options[:api_key]
22
+ end
17
23
  end
18
24
 
19
25
  raw ? response : response.body
@@ -1,3 +1,3 @@
1
1
  module FullContact
2
- VERSION = '0.14.0'
2
+ VERSION = '0.15.0'
3
3
  end
@@ -20,13 +20,41 @@ describe FullContact do
20
20
  stub_get("person.json").
21
21
  with(:query => {:apiKey => "api_key", :twitter => "brawtest"}).
22
22
  to_return(:body => fixture("person.json"), :headers => {:content_type => "application/json; charset=utf-8"})
23
+
24
+ stub_get("person.json").
25
+ with(:query => {:email => "brawest@gmail.com"})
26
+ end
27
+
28
+ context "when using query auth type" do
29
+
30
+ before do
31
+ FullContact.configure do |config|
32
+ config.auth_type = :query
33
+ end
34
+ end
35
+
36
+ it "should get the correct resource" do
37
+ FullContact.person(email: "brawest@gmail.com")
38
+ a_get("person.json")
39
+ .with(:query => {:apiKey => "api_key", :email => "brawest@gmail.com"})
40
+ .should have_been_made
41
+ end
23
42
  end
24
43
 
25
- it "should get the correct resource" do
26
- FullContact.person(email: "brawest@gmail.com")
27
- a_get("person.json")
28
- .with(:query => {:apiKey => "api_key", :email => "brawest@gmail.com"})
29
- .should have_been_made
44
+ context "when using header auth type" do
45
+
46
+ before do
47
+ FullContact.configure do |config|
48
+ config.auth_type = :header
49
+ end
50
+ end
51
+
52
+ it "should get the correct resource" do
53
+ FullContact.person(email: "brawest@gmail.com")
54
+ a_get("person.json")
55
+ .with(:query => {:email => "brawest@gmail.com"}, :headers => {:'X-Fullcontact-Apikey'=>'api_key'})
56
+ .should have_been_made
57
+ end
30
58
  end
31
59
 
32
60
  it "should return the same results as a client by email" do
@@ -30,6 +30,7 @@ describe FullContact::API do
30
30
  before do
31
31
  @configuration = {
32
32
  :api_key => 'api_key',
33
+ :auth_type => :headers,
33
34
  :adapter => :typhoeus,
34
35
  :endpoint => 'http://tumblr.com/',
35
36
  :gateway => 'apigee-1111.apigee.com',
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.14.0
4
+ version: 0.15.0
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: 2016-07-11 00:00:00.000000000 Z
12
+ date: 2016-08-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: maruku
16
- requirement: &70240872599500 !ruby/object:Gem::Requirement
16
+ requirement: &70168063820700 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0.7'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70240872599500
24
+ version_requirements: *70168063820700
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: nokogiri
27
- requirement: &70240872599000 !ruby/object:Gem::Requirement
27
+ requirement: &70168063820120 !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: *70240872599000
35
+ version_requirements: *70168063820120
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &70240872598420 !ruby/object:Gem::Requirement
38
+ requirement: &70168063819600 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0.9'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70240872598420
46
+ version_requirements: *70168063819600
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &70240872597600 !ruby/object:Gem::Requirement
49
+ requirement: &70168063819080 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '3.1'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70240872597600
57
+ version_requirements: *70168063819080
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: simplecov
60
- requirement: &70240872597140 !ruby/object:Gem::Requirement
60
+ requirement: &70168063818600 !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: *70240872597140
68
+ version_requirements: *70168063818600
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: webmock
71
- requirement: &70240872596660 !ruby/object:Gem::Requirement
71
+ requirement: &70168063818140 !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: *70240872596660
79
+ version_requirements: *70168063818140
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: yard
82
- requirement: &70240872596120 !ruby/object:Gem::Requirement
82
+ requirement: &70168063817680 !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: *70240872596120
90
+ version_requirements: *70168063817680
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: hashie
93
- requirement: &70240872595560 !ruby/object:Gem::Requirement
93
+ requirement: &70168063833520 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -101,10 +101,10 @@ dependencies:
101
101
  version: '4.0'
102
102
  type: :runtime
103
103
  prerelease: false
104
- version_requirements: *70240872595560
104
+ version_requirements: *70168063833520
105
105
  - !ruby/object:Gem::Dependency
106
106
  name: faraday
107
- requirement: &70240872594780 !ruby/object:Gem::Requirement
107
+ requirement: &70168063832800 !ruby/object:Gem::Requirement
108
108
  none: false
109
109
  requirements:
110
110
  - - ~>
@@ -112,10 +112,10 @@ dependencies:
112
112
  version: 0.9.0
113
113
  type: :runtime
114
114
  prerelease: false
115
- version_requirements: *70240872594780
115
+ version_requirements: *70168063832800
116
116
  - !ruby/object:Gem::Dependency
117
117
  name: faraday_middleware
118
- requirement: &70240872610680 !ruby/object:Gem::Requirement
118
+ requirement: &70168063832260 !ruby/object:Gem::Requirement
119
119
  none: false
120
120
  requirements:
121
121
  - - ! '>='
@@ -123,7 +123,7 @@ dependencies:
123
123
  version: '0.9'
124
124
  type: :runtime
125
125
  prerelease: false
126
- version_requirements: *70240872610680
126
+ version_requirements: *70168063832260
127
127
  description: A Ruby wrapper for the FullContact API
128
128
  email:
129
129
  - support@fullcontact.com
@@ -181,7 +181,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
181
181
  version: '0'
182
182
  segments:
183
183
  - 0
184
- hash: -3898038741122446836
184
+ hash: 754980760843219828
185
185
  required_rubygems_version: !ruby/object:Gem::Requirement
186
186
  none: false
187
187
  requirements: