white_pages 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/.rspec +1 -0
- data/.rvmrc +2 -0
- data/Gemfile +3 -0
- data/LICENSE +20 -0
- data/README +34 -0
- data/Rakefile +7 -0
- data/lib/white_pages/client.rb +105 -0
- data/lib/white_pages.rb +30 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/white_pages_spec.rb +28 -0
- data/white_pages.gemspec +26 -0
- metadata +101 -0
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.rvmrc
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Octohq.com
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
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:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
WhitePages
|
2
|
+
=========
|
3
|
+
|
4
|
+
WhitePages is a Ruby wrapper for the WhitePages.com API.
|
5
|
+
|
6
|
+
WhitePages API Docs
|
7
|
+
=========
|
8
|
+
|
9
|
+
http://developer.whitepages.com/
|
10
|
+
|
11
|
+
You will need to register for a WhitePages API Key.
|
12
|
+
|
13
|
+
INSTALLATION
|
14
|
+
==========
|
15
|
+
|
16
|
+
gem install white_pages
|
17
|
+
|
18
|
+
USAGE
|
19
|
+
==========
|
20
|
+
|
21
|
+
# Set API Key
|
22
|
+
WhitePages.api_key = 'XXXXXXXX'
|
23
|
+
|
24
|
+
WhitePages.find_person(name: 'John Doe')
|
25
|
+
WhitePages.find_business(businessname: 'Target')
|
26
|
+
WhitePages.reverse_phone(phone: '3334445555')
|
27
|
+
WhitePages.reverse_address(street: '333 S. 3rd St', city: 'Los Angeles', state: 'CA')
|
28
|
+
|
29
|
+
Available options can be found by generating RDoc or visiting http://developer.whitepages.com.
|
30
|
+
|
31
|
+
COPYRIGHT
|
32
|
+
=========
|
33
|
+
|
34
|
+
Copyright (c) 2011 octohq.com. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
module WhitePages
|
2
|
+
class Client
|
3
|
+
include HTTParty
|
4
|
+
base_uri 'http://api.whitepages.com'
|
5
|
+
|
6
|
+
# API Version
|
7
|
+
def version
|
8
|
+
'1.0'
|
9
|
+
end
|
10
|
+
|
11
|
+
# Find a person
|
12
|
+
#
|
13
|
+
# http://developer.whitepages.com/docs/read/Methods/find_person
|
14
|
+
#
|
15
|
+
# * <tt>:firstname</tt>
|
16
|
+
# * <tt>:lastname</tt> - Required unless :name is provided
|
17
|
+
# * <tt>:name</tt> - Full name. Required unless :lastname is provided
|
18
|
+
# * <tt>:house</tt> - House number
|
19
|
+
# * <tt>:street</tt> - Street name, including any directional prefix or suffix
|
20
|
+
# * <tt>:city</tt>
|
21
|
+
# * <tt>:state</tt> - USPS two-character abbreviation
|
22
|
+
# * <tt>:zip</tt> - Will accept 5 digit ZIP Code or 9 digit ZIP+4
|
23
|
+
# * <tt>:areacode</tt>
|
24
|
+
# * <tt>:metro</tt> - Expand search to metro area
|
25
|
+
#
|
26
|
+
# == Example
|
27
|
+
#
|
28
|
+
# WhitePages.api_key = API_KEY
|
29
|
+
# WhitePages.find_person(name: 'John Doe', state: 'CA')
|
30
|
+
#
|
31
|
+
def find_person(options = {})
|
32
|
+
fetch(:find_person, options)
|
33
|
+
end
|
34
|
+
|
35
|
+
# Find a business
|
36
|
+
#
|
37
|
+
# http://developer.whitepages.com/docs/read/Methods/find_business
|
38
|
+
#
|
39
|
+
# * <tt>:businessname</tt> - Required unless :category is provided
|
40
|
+
# * <tt>:category</tt> - Required unless :businessname is provided
|
41
|
+
# * <tt>:house</tt> - House number
|
42
|
+
# * <tt>:street</tt> - Street name, including any directional prefix or suffix
|
43
|
+
# * <tt>:city</tt>
|
44
|
+
# * <tt>:state</tt> - USPS two-character abbreviation
|
45
|
+
# * <tt>:zip</tt> - Will accept 5 digit ZIP Code or 9 digit ZIP+4
|
46
|
+
# * <tt>:areacode</tt>
|
47
|
+
# * <tt>:metro</tt> - Expand search to metro area
|
48
|
+
#
|
49
|
+
# == Example
|
50
|
+
#
|
51
|
+
# WhitePages.api_key = API_KEY
|
52
|
+
# WhitePages.find_business(businessname: 'Target', city: 'Los Angeles', state: 'CA')
|
53
|
+
#
|
54
|
+
def find_business(options = {})
|
55
|
+
fetch(:find_business, options)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Reverse lookup of a phone number
|
59
|
+
#
|
60
|
+
# http://developer.whitepages.com/docs/read/Methods/reverse_phone
|
61
|
+
#
|
62
|
+
# * <tt>:phone</tt> - 7 or 10 digits
|
63
|
+
# * <tt>:state</tt> - USPS two-character abbreviation. Required if :phone is 7 digits
|
64
|
+
#
|
65
|
+
# == Example
|
66
|
+
#
|
67
|
+
# WhitePages.api_key = API_KEY
|
68
|
+
# WhitePages.reverse_phone(phone: '3334445555')
|
69
|
+
#
|
70
|
+
def reverse_phone(options = {})
|
71
|
+
fetch(:reverse_phone, options)
|
72
|
+
end
|
73
|
+
|
74
|
+
# Reverse lookup of an address
|
75
|
+
#
|
76
|
+
# http://developer.whitepages.com/docs/read/Methods/reverse_address
|
77
|
+
#
|
78
|
+
# * <tt>:house</tt> - House number
|
79
|
+
# * <tt>:apt</tt> - Apartment number
|
80
|
+
# * <tt>:street</tt> - Street name, including any directional prefix or suffix. Required
|
81
|
+
# * <tt>:city</tt>
|
82
|
+
# * <tt>:state</tt> - USPS two-character abbreviation
|
83
|
+
# * <tt>:zip</tt> - Will accept 5 digit ZIP Code or 9 digit ZIP+4
|
84
|
+
# * <tt>:areacode</tt>
|
85
|
+
#
|
86
|
+
# == Example
|
87
|
+
#
|
88
|
+
# WhitePages.api_key = API_KEY
|
89
|
+
# WhitePages.reverse_address(street: '333 S. 3rd St', city: 'Los Angeles', state: 'CA')
|
90
|
+
#
|
91
|
+
def reverse_address(options = {})
|
92
|
+
fetch(:reverse_address, options)
|
93
|
+
end
|
94
|
+
|
95
|
+
protected
|
96
|
+
def fetch(method, options)
|
97
|
+
options.merge!(api_key: WhitePages.api_key, outputtype: 'JSON')
|
98
|
+
response = self.class.get("/#{method}/#{version}", query: options)
|
99
|
+
case response.code
|
100
|
+
when 400...600 then raise WhitePagesError.new(response.headers['x-mashery-error-code'])
|
101
|
+
else Hashie::Mash.new(response)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
data/lib/white_pages.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'hashie'
|
2
|
+
require 'httparty'
|
3
|
+
|
4
|
+
module WhitePages
|
5
|
+
VERSION = "0.0.1"
|
6
|
+
|
7
|
+
class WhitePagesError < StandardError; end
|
8
|
+
|
9
|
+
autoload :Client, 'white_pages/client'
|
10
|
+
|
11
|
+
class << self
|
12
|
+
attr_accessor :api_key
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.find_person(options)
|
16
|
+
Client.new(self.api_key).find_person(options)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.find_business(options)
|
20
|
+
Client.new(self.api_key).find_business(options)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.reverse_address(options)
|
24
|
+
Client.new(self.api_key).reverse_address(options)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.reverse_phone(options)
|
28
|
+
Client.new(self.api_key).reverse_phone(options)
|
29
|
+
end
|
30
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
require 'white_pages'
|
5
|
+
|
6
|
+
RSpec.configure do |config|
|
7
|
+
config.mock_with :rspec
|
8
|
+
end
|
9
|
+
|
10
|
+
# Be sure to pass wp_api_key=XXX or change the API key here
|
11
|
+
WhitePages.api_key = ENV['wp_api_key'] || '0123456789abcdef'
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe WhitePages do
|
4
|
+
context "Valid API Key" do
|
5
|
+
it "should find a person" do
|
6
|
+
WhitePages.find_person(name: 'John Doe').should be_an_instance_of(Hashie::Mash)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should find a business" do
|
10
|
+
WhitePages.find_business(businessname: 'Target').should be_an_instance_of(Hashie::Mash)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should reverse a phone number" do
|
14
|
+
WhitePages.reverse_phone(phone: '3236030004').should be_an_instance_of(Hashie::Mash)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should reverse an address" do
|
18
|
+
WhitePages.reverse_address(street: 'Santa Monica Blvd').should be_an_instance_of(Hashie::Mash)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "Invalid API Key" do
|
23
|
+
it "should raise errors" do
|
24
|
+
WhitePages.api_key = 'invalid'
|
25
|
+
lambda { WhitePages.find_person(name: 'John Doe') }.should raise_error(WhitePages::WhitePagesError)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/white_pages.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "white_pages"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "white_pages"
|
7
|
+
s.version = WhitePages::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["kris"]
|
10
|
+
s.email = ["kris@octohq.com"]
|
11
|
+
s.homepage = ""
|
12
|
+
s.summary = %q{Simple interface to WhitePages API}
|
13
|
+
s.description = %q{Simple interface to WhitePages API}
|
14
|
+
|
15
|
+
s.rubyforge_project = "white_pages"
|
16
|
+
|
17
|
+
s.add_dependency "hashie"
|
18
|
+
s.add_dependency "httparty"
|
19
|
+
|
20
|
+
s.add_development_dependency("rspec", "~> 2.0.1")
|
21
|
+
|
22
|
+
s.files = `git ls-files`.split("\n")
|
23
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
24
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
25
|
+
s.require_paths = ["lib"]
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: white_pages
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- kris
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-05-21 00:00:00 -07:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: hashie
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: httparty
|
29
|
+
prerelease: false
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: "0"
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: rspec
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ~>
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 2.0.1
|
47
|
+
type: :development
|
48
|
+
version_requirements: *id003
|
49
|
+
description: Simple interface to WhitePages API
|
50
|
+
email:
|
51
|
+
- kris@octohq.com
|
52
|
+
executables: []
|
53
|
+
|
54
|
+
extensions: []
|
55
|
+
|
56
|
+
extra_rdoc_files: []
|
57
|
+
|
58
|
+
files:
|
59
|
+
- .gitignore
|
60
|
+
- .rspec
|
61
|
+
- .rvmrc
|
62
|
+
- Gemfile
|
63
|
+
- LICENSE
|
64
|
+
- README
|
65
|
+
- Rakefile
|
66
|
+
- lib/white_pages.rb
|
67
|
+
- lib/white_pages/client.rb
|
68
|
+
- spec/spec_helper.rb
|
69
|
+
- spec/white_pages_spec.rb
|
70
|
+
- white_pages.gemspec
|
71
|
+
has_rdoc: true
|
72
|
+
homepage: ""
|
73
|
+
licenses: []
|
74
|
+
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: "0"
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: "0"
|
92
|
+
requirements: []
|
93
|
+
|
94
|
+
rubyforge_project: white_pages
|
95
|
+
rubygems_version: 1.6.0
|
96
|
+
signing_key:
|
97
|
+
specification_version: 3
|
98
|
+
summary: Simple interface to WhitePages API
|
99
|
+
test_files:
|
100
|
+
- spec/spec_helper.rb
|
101
|
+
- spec/white_pages_spec.rb
|