rapleaf_api 1.2.2 → 1.2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -1
- data/README.md +6 -5
- data/Rakefile +1 -1
- data/lib/rapleaf_api.rb +29 -2
- data/rapleaf_api.gemspec +2 -2
- metadata +7 -6
data/CHANGELOG
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
v1.2.3. Bulk API support
|
2
|
+
|
1
3
|
v1.2.2. Downcase emails before hashing
|
2
4
|
|
3
5
|
v1.2.1. Support ca_file instead of ca_path in constructor
|
@@ -8,4 +10,4 @@ v0.1.1. Bug fixes
|
|
8
10
|
|
9
11
|
v0.1.0. Added support for show_available
|
10
12
|
|
11
|
-
v0.0.1. Initial version
|
13
|
+
v0.0.1. Initial version
|
data/README.md
CHANGED
@@ -13,7 +13,7 @@ Usage
|
|
13
13
|
=> true
|
14
14
|
> api = RapleafApi::Api.new('my secret API key')
|
15
15
|
=> #<RapleafApi::Api:0x101b7f5f0 @API_KEY="my secret API key", @CA_FILE=nil, @TIMEOUT=2, @BASE_PATH="/v4/dr?api_key=my secret API key">
|
16
|
-
> h = api.query_by_email('test@
|
16
|
+
> h = api.query_by_email('test@rapleaf.com')
|
17
17
|
=> {"location"=>"Fakesville, California, United States", "gender"=>"Male", "age"=>"25-34"}
|
18
18
|
|
19
19
|
Constructor Options
|
@@ -57,16 +57,17 @@ This method queries Rapleaf's API with a name and postal address: first name, la
|
|
57
57
|
|
58
58
|
This method queries Rapleaf's API with a name and ZIP+4 code. The ZIP+4 is a string with a 5-digit ZIP code and 4-digit extension separated by a dash. This method accepts the following options:
|
59
59
|
|
60
|
-
- :email => You can include an email in your NAP query to increase the hit rate. Defaults to nil.
|
61
|
-
- :show_available => Controls whether the response will include information about available data. Defaults to nil.
|
60
|
+
- :email => You can include an email in your NAP query to increase the hit rate. Defaults to nil.
|
61
|
+
- :show_available => Controls whether the response will include information about available data. Defaults to nil.
|
62
62
|
|
63
63
|
|
64
64
|
Contributing
|
65
65
|
============
|
66
66
|
If you have suggestions or patches, feel free to email us at
|
67
|
-
|
67
|
+
[developer at rapleaf dot com]. We look forward to hearing from you!
|
68
68
|
|
69
69
|
|
70
70
|
Contributors
|
71
71
|
============
|
72
|
-
Greg Poulos
|
72
|
+
- Greg Poulos [greg at rapleaf dot com]
|
73
|
+
- Sean Carr [sean at rapleaf dot com]
|
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('rapleaf_api', '1.2.
|
5
|
+
Echoe.new('rapleaf_api', '1.2.3') do |p|
|
6
6
|
p.author = 'Rapleaf'
|
7
7
|
p.description = "A library for interacting with Rapleaf's Personalization API."
|
8
8
|
p.email = 'developer @nospam@ rapleaf.com'
|
data/lib/rapleaf_api.rb
CHANGED
@@ -24,12 +24,13 @@ include ERB::Util
|
|
24
24
|
module RapleafApi
|
25
25
|
HOST = "personalize.rapleaf.com"
|
26
26
|
PORT = 443
|
27
|
-
HEADERS = {'User-Agent' => 'RapleafApi/Ruby/1.2.
|
27
|
+
HEADERS = {'User-Agent' => 'RapleafApi/Ruby/1.2.3', 'Content-Type' => 'application/json'}
|
28
28
|
|
29
29
|
class Api
|
30
30
|
def initialize(api_key, options = {})
|
31
31
|
@API_KEY = api_key
|
32
32
|
@BASE_PATH = "/v4/dr?api_key=#{@API_KEY}"
|
33
|
+
@BULK_PATH = "/v4/bulk?api_key=#{@API_KEY}"
|
33
34
|
@TIMEOUT = options[:timeout] || 2
|
34
35
|
@CA_FILE = options[:ca_file] # set to your system-wide root ca cert file
|
35
36
|
# if you're having ssl verification issues
|
@@ -97,8 +98,34 @@ module RapleafApi
|
|
97
98
|
get_json_response(url, options[:show_available])
|
98
99
|
end
|
99
100
|
|
101
|
+
def bulk_query(set, upsell = false)
|
102
|
+
path = @BULK_PATH
|
103
|
+
if upsell
|
104
|
+
path = path + "&show_available=true"
|
105
|
+
end
|
106
|
+
|
107
|
+
get_bulk_response(path,JSON.generate(set))
|
108
|
+
end
|
109
|
+
|
100
110
|
private
|
101
111
|
|
112
|
+
def get_bulk_response(path, data)
|
113
|
+
response = Timeout::timeout(@TIMEOUT) do
|
114
|
+
http_client.post(path, data, HEADERS)
|
115
|
+
begin
|
116
|
+
http_client.post(path, data, HEADERS)
|
117
|
+
rescue EOFError # Connection cut out. Just try a second time.
|
118
|
+
http_client.post(path, data, HEADERS)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
if response.code =~ /^2\d\d/
|
123
|
+
(response.body && response.body != "") ? JSON.parse(response.body) : []
|
124
|
+
else
|
125
|
+
raise "Error Code #{response.code}: \"#{response.body}\""
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
102
129
|
# Takes a url and returns a hash mapping attribute fields onto attributes
|
103
130
|
# Note that an exception is raised in the case that
|
104
131
|
# an HTTP response code other than 200 is sent back
|
@@ -125,7 +152,7 @@ module RapleafApi
|
|
125
152
|
@@http_client = Net::HTTP.new(HOST, PORT)
|
126
153
|
@@http_client.use_ssl = true
|
127
154
|
@@http_client.ca_file = @CA_FILE if @CA_FILE
|
128
|
-
|
155
|
+
#@@http_client.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
129
156
|
@@http_client.start
|
130
157
|
end
|
131
158
|
@@http_client
|
data/rapleaf_api.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{rapleaf_api}
|
5
|
-
s.version = "1.2.
|
5
|
+
s.version = "1.2.3.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Rapleaf"]
|
9
|
-
s.date = %q{2011-
|
9
|
+
s.date = %q{2011-08-23}
|
10
10
|
s.description = %q{A library for interacting with Rapleaf's Personalization API.}
|
11
11
|
s.email = %q{developer @nospam@ rapleaf.com}
|
12
12
|
s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README.md", "lib/rapleaf_api.rb"]
|
metadata
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rapleaf_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 67
|
5
|
+
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
|
9
|
+
- 3
|
10
|
+
- 0
|
11
|
+
version: 1.2.3.0
|
11
12
|
platform: ruby
|
12
13
|
authors:
|
13
14
|
- Rapleaf
|
@@ -15,7 +16,7 @@ autorequire:
|
|
15
16
|
bindir: bin
|
16
17
|
cert_chain: []
|
17
18
|
|
18
|
-
date: 2011-
|
19
|
+
date: 2011-08-23 00:00:00 -07:00
|
19
20
|
default_executable:
|
20
21
|
dependencies:
|
21
22
|
- !ruby/object:Gem::Dependency
|
@@ -101,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
102
|
requirements: []
|
102
103
|
|
103
104
|
rubyforge_project: rapleaf_api
|
104
|
-
rubygems_version: 1.
|
105
|
+
rubygems_version: 1.3.7
|
105
106
|
signing_key:
|
106
107
|
specification_version: 3
|
107
108
|
summary: A library for interacting with Rapleaf's Personalization API.
|