fullcontact 0.11.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -9,6 +9,8 @@ A Ruby wrapper for the [FullContact API](http://www.fullcontact.com/)
9
9
 
10
10
  Changes
11
11
  -------
12
+ - 0.12.0 - `include_headers_in_response = true` includes response headers in returned payload
13
+ - Accessible as `http_headers` in response. Also accessible on thrown errors (e.g. RateLimited)
12
14
  - 0.11.0 - Plisskin transformation can be disabled by specifying a `skip_rubyize = true` in config block.
13
15
  - 0.10.0 - Support for FullContact Company API
14
16
  - 0.9.0 - Removed Rash gem and replaced with Mashify + Plisskin
@@ -0,0 +1,8 @@
1
+ module Faraday
2
+ class Response::AddHeaders < Response::Middleware
3
+ def on_complete(env)
4
+ env.body[:http_headers] = env.response_headers
5
+ env.body
6
+ end
7
+ end
8
+ end
@@ -11,6 +11,7 @@ module FullContact
11
11
  :endpoint,
12
12
  :format,
13
13
  :skip_rubyize,
14
+ :include_headers_in_response,
14
15
  :gateway,
15
16
  :proxy,
16
17
  :user_agent].freeze
@@ -38,6 +39,9 @@ module FullContact
38
39
  # Default transformation done to response
39
40
  DEFAULT_SKIP_RUBYIZE = false
40
41
 
42
+ # Includes response headers
43
+ DEFAULT_INCLUDE_HEADERS_IN_RESPONSE = false
44
+
41
45
  # By default, don't use a proxy server
42
46
  DEFAULT_PROXY = nil
43
47
 
@@ -73,6 +77,7 @@ module FullContact
73
77
  self.endpoint = DEFAULT_ENDPOINT
74
78
  self.format = DEFAULT_FORMAT
75
79
  self.skip_rubyize = DEFAULT_SKIP_RUBYIZE
80
+ self.include_headers_in_response = DEFAULT_INCLUDE_HEADERS_IN_RESPONSE
76
81
  self.proxy = DEFAULT_PROXY
77
82
  self.user_agent = DEFAULT_USER_AGENT
78
83
  self.gateway = DEFAULT_GATEWAY
@@ -1,6 +1,7 @@
1
1
  require 'faraday_middleware'
2
2
  require 'faraday/request/gateway'
3
3
  require 'faraday/response/fullcontact_errors'
4
+ require 'faraday/response/add_headers'
4
5
  require 'faraday/response/rubyize'
5
6
  require 'faraday_middleware/response/mashify'
6
7
 
@@ -22,6 +23,7 @@ module FullContact
22
23
  builder.use Faraday::Request::UrlEncoded
23
24
  builder.use Faraday::Request::Gateway, gateway if gateway
24
25
  builder.use FaradayMiddleware::Mashify unless raw
26
+ builder.use Faraday::Response::AddHeaders if FullContact.include_headers_in_response
25
27
  builder.use Faraday::Response::Rubyize unless raw or FullContact.skip_rubyize
26
28
  unless raw
27
29
  case format.to_s.downcase
@@ -1,3 +1,3 @@
1
1
  module FullContact
2
- VERSION = '0.11.0'
2
+ VERSION = '0.12.0'
3
3
  end
@@ -36,7 +36,8 @@ describe FullContact::API do
36
36
  :format => :xml,
37
37
  :proxy => 'http://erik:sekret@proxy.example.com:8080',
38
38
  :user_agent => 'Custom User Agent',
39
- :skip_rubyize => true
39
+ :skip_rubyize => true,
40
+ :include_headers_in_response => true
40
41
  }
41
42
  end
42
43
 
@@ -52,4 +52,23 @@ describe FullContact::Client::Person do
52
52
  expect(FullContact.person(email: "brawest@gmail.com").contactInfo.givenName).to(eq("Brandon"))
53
53
  end
54
54
  end
55
+
56
+ context "with headers enabled" do
57
+
58
+ before do
59
+ FullContact.configure do |config|
60
+ config.api_key = "api_key"
61
+ config.include_headers_in_response = true
62
+ end
63
+
64
+ stub_get("person.json").
65
+ with(:query => {:apiKey => "api_key", :email => "brawest@gmail.com"}).
66
+ to_return(:body => fixture("person.json"), :headers => {:content_type => "application/json; charset=utf-8"})
67
+ end
68
+
69
+ it 'should include http headers from response' do
70
+ expect(FullContact.person(email: "brawest@gmail.com").http_headers['content-type'])
71
+ .to(eq("application/json; charset=utf-8"))
72
+ end
73
+ end
55
74
  end
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.11.0
4
+ version: 0.12.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: 2015-06-18 00:00:00.000000000 Z
12
+ date: 2015-07-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: maruku
16
- requirement: &70098643701000 !ruby/object:Gem::Requirement
16
+ requirement: &70200921792780 !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: *70098643701000
24
+ version_requirements: *70200921792780
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: nokogiri
27
- requirement: &70098643699940 !ruby/object:Gem::Requirement
27
+ requirement: &70200921791920 !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: *70098643699940
35
+ version_requirements: *70200921791920
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &70098643698340 !ruby/object:Gem::Requirement
38
+ requirement: &70200921791200 !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: *70098643698340
46
+ version_requirements: *70200921791200
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &70098643696100 !ruby/object:Gem::Requirement
49
+ requirement: &70200921790200 !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: *70098643696100
57
+ version_requirements: *70200921790200
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: simplecov
60
- requirement: &70098643694760 !ruby/object:Gem::Requirement
60
+ requirement: &70200921789020 !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: *70098643694760
68
+ version_requirements: *70200921789020
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: webmock
71
- requirement: &70098643694020 !ruby/object:Gem::Requirement
71
+ requirement: &70200921787660 !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: *70098643694020
79
+ version_requirements: *70200921787660
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: yard
82
- requirement: &70098643692980 !ruby/object:Gem::Requirement
82
+ requirement: &70200921784940 !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: *70098643692980
90
+ version_requirements: *70200921784940
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: hashie
93
- requirement: &70098643691040 !ruby/object:Gem::Requirement
93
+ requirement: &70200921781340 !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: *70098643691040
104
+ version_requirements: *70200921781340
105
105
  - !ruby/object:Gem::Dependency
106
106
  name: faraday
107
- requirement: &70098643689560 !ruby/object:Gem::Requirement
107
+ requirement: &70200921776380 !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: *70098643689560
115
+ version_requirements: *70200921776380
116
116
  - !ruby/object:Gem::Dependency
117
117
  name: faraday_middleware
118
- requirement: &70098643688980 !ruby/object:Gem::Requirement
118
+ requirement: &70200921775220 !ruby/object:Gem::Requirement
119
119
  none: false
120
120
  requirements:
121
121
  - - ! '>='
@@ -123,10 +123,10 @@ dependencies:
123
123
  version: '0.9'
124
124
  type: :runtime
125
125
  prerelease: false
126
- version_requirements: *70098643688980
126
+ version_requirements: *70200921775220
127
127
  - !ruby/object:Gem::Dependency
128
128
  name: plissken
129
- requirement: &70098643688160 !ruby/object:Gem::Requirement
129
+ requirement: &70200921774140 !ruby/object:Gem::Requirement
130
130
  none: false
131
131
  requirements:
132
132
  - - ! '>='
@@ -134,7 +134,7 @@ dependencies:
134
134
  version: '0'
135
135
  type: :runtime
136
136
  prerelease: false
137
- version_requirements: *70098643688160
137
+ version_requirements: *70200921774140
138
138
  description: A Ruby wrapper for the FullContact API
139
139
  email:
140
140
  - support@fullcontact.com
@@ -152,6 +152,7 @@ files:
152
152
  - Rakefile
153
153
  - fullcontact.gemspec
154
154
  - lib/faraday/request/gateway.rb
155
+ - lib/faraday/response/add_headers.rb
155
156
  - lib/faraday/response/fullcontact_errors.rb
156
157
  - lib/faraday/response/rubyize.rb
157
158
  - lib/fullcontact.rb
@@ -190,7 +191,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
190
191
  version: '0'
191
192
  segments:
192
193
  - 0
193
- hash: -2691881462496632106
194
+ hash: -928837889352333457
194
195
  required_rubygems_version: !ruby/object:Gem::Requirement
195
196
  none: false
196
197
  requirements: