dolmade 0.1.0 → 0.1.1

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,6 +1,6 @@
1
1
  = dolmade
2
2
 
3
- Description goes here.
3
+ A very simple API wrapper for the RapLeaf API v4. Based on HTTParty.
4
4
 
5
5
  == Contributing to dolmade
6
6
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{dolmade}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jordan Sitkin"]
@@ -6,7 +6,8 @@ module Dolmade
6
6
 
7
7
  include HTTParty
8
8
  format :json
9
- base_uri "https://personalize.rapleaf.com/v4/dr"
9
+ base_uri "https://personalize.rapleaf.com/v4"
10
+ # debug_output $stderr
10
11
 
11
12
  attr_accessor :api_key
12
13
 
@@ -15,14 +16,24 @@ module Dolmade
15
16
  end
16
17
 
17
18
  def lookup_by_email(email)
18
- Person.new(self.request({:email => email}))
19
+ if email.respond_to?(:map)
20
+ result = bulk_lookup_by_email(email)
21
+ result.map! { |e| Person.new(e) }
22
+ else
23
+ Person.new(self.request({:email => email}))
24
+ end
19
25
  end
20
26
 
21
27
  protected
22
28
 
23
29
  def request(query={})
24
30
  query.merge!({:api_key => self.api_key})
25
- self.class.get('',{:query => query})
31
+ self.class.get('/dr',{:query => query})
32
+ end
33
+
34
+ def bulk_lookup_by_email(emails)
35
+ emails.map! { |e| {'email' => e} }
36
+ self.class.post('/bulk', {:query => {:api_key => self.api_key}, :body => emails.to_json, :headers => {'Content-Type' => 'application/json'}})
26
37
  end
27
38
 
28
39
  end
@@ -10,4 +10,11 @@ describe "Dolmade" do
10
10
  @dolmade.lookup_by_email('jordan@fiftyfootfoghorn.com').class.should eq(Dolmade::Person)
11
11
  end
12
12
 
13
+ it "should make a successful bulk request to the Rapleaf API and return an array of infos" do
14
+ result = @dolmade.lookup_by_email(['jordan@fiftyfootfoghorn.com','polobv@gmail.com'])
15
+ result.each do |r|
16
+ r.class.should eq(Dolmade::Person)
17
+ end
18
+ end
19
+
13
20
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dolmade
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jordan Sitkin