whitepages_pro 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZjU5N2QzZTBkOWUyYjJjY2Y1MmYxNjc0YTNlYTQ5ZjBhOTkzOWJkZA==
5
+ data.tar.gz: !binary |-
6
+ Y2I3NjA5YTg1NmU3ZDJiMjU4MDdlOGNkNjFlNmNiM2RmNzRmZWNkYQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ Yzk2M2YwMDEzN2IyZjhiZGY4ZDQ5Y2RiMDc0YWJiNmIxNzkyNTU2MmE5Mjlh
10
+ MmM3NGUwNDMzNTIzZmQ2Mzc0ZTlmMTQ1Y2YzZjdmNDgwY2ZmM2RjNGMxOWM1
11
+ MjJhNWQyZDRhZTQ2M2YxOWFjNGNhNTM1ZDEzYzExYjUzYjdmZjc=
12
+ data.tar.gz: !binary |-
13
+ Y2NjNDMxMTcxMzM0MGEyZWU0ODIwOWY0ZDhhYWFlM2RmMjQ5MWZmNDcxNjRi
14
+ ZTQzNmVjNjcwZGZlYjA0ZDI5OTYzYjkzMTAxNTQ1ZDg3YWQzYWEzNmVkMmVk
15
+ ZGFjOWIzNzMyNWQxNjdlZDFkOWQxNzVjNmQ3NGU3ODYzOGNkYzU=
data/LICENSE.txt ADDED
@@ -0,0 +1,24 @@
1
+ Copyright (c) 2013, WhitePages, Inc.
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+ * Redistributions of source code must retain the above copyright
7
+ notice, this list of conditions and the following disclaimer.
8
+ * Redistributions in binary form must reproduce the above copyright
9
+ notice, this list of conditions and the following disclaimer in the
10
+ documentation and/or other materials provided with the distribution.
11
+ * Neither the name of the company nor the
12
+ names of its contributors may be used to endorse or promote products
13
+ derived from this software without specific prior written permission.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
+ DISCLAIMED. IN NO EVENT SHALL WHITEPAGES, INC. BE LIABLE FOR ANY
19
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.rdoc ADDED
@@ -0,0 +1,32 @@
1
+ = Overview
2
+
3
+ = History
4
+
5
+ [0.1.0 - 2013-Apr-25] Initial Release.
6
+
7
+ = License
8
+
9
+ Copyright (c) 2013, WhitePages, Inc.
10
+ All rights reserved.
11
+
12
+ Redistribution and use in source and binary forms, with or without
13
+ modification, are permitted provided that the following conditions are met:
14
+ * Redistributions of source code must retain the above copyright
15
+ notice, this list of conditions and the following disclaimer.
16
+ * Redistributions in binary form must reproduce the above copyright
17
+ notice, this list of conditions and the following disclaimer in the
18
+ documentation and/or other materials provided with the distribution.
19
+ * Neither the name of the company nor the
20
+ names of its contributors may be used to endorse or promote products
21
+ derived from this software without specific prior written permission.
22
+
23
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26
+ DISCLAIMED. IN NO EVENT SHALL WHITEPAGES, INC. BE LIABLE FOR ANY
27
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/Rakefile ADDED
@@ -0,0 +1,19 @@
1
+ require 'pathname'
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../Gemfile", Pathname.new(__FILE__).realpath)
3
+ require 'rubygems'
4
+ require 'bundler/setup'
5
+
6
+ require "rspec/core/rake_task"
7
+
8
+ RSpec::Core::RakeTask.new(:spec) do |spec|
9
+ spec.rspec_opts = ['--backtrace']
10
+ end
11
+
12
+ require 'rdoc/task'
13
+
14
+ RDoc::Task.new do |rdoc|
15
+ rdoc.rdoc_dir = "rdoc"
16
+ rdoc.rdoc_files.add "lib/**/*.rb", "README.rdoc"
17
+ rdoc.options << "--all"
18
+ #rdoc.options << "--coverage-report" # Useful for finding something undocumented, but won't generate output when this is selected!
19
+ end
@@ -0,0 +1,65 @@
1
+ require 'httparty'
2
+ require 'whitepages_pro'
3
+
4
+ module WhitepagesPro
5
+ module MatchScore
6
+ def api_key(api_key)
7
+ WhitepagesPro.api_key(api_key)
8
+ end
9
+
10
+ # ActiveMerchant has definition
11
+
12
+ # :order_id - The order number
13
+ # :ip - The IP address of the customer making the purchase
14
+ # :customer - The name, customer number, or other information that identifies the customer
15
+ # :invoice - The invoice number
16
+ # :merchant - The name or description of the merchant offering the product
17
+ # :description - A description of the transaction
18
+ # :email - The email address of the customer
19
+ # :currency - The currency of the transaction. Only important when you are using a currency that is not the default with a gateway that supports multiple currencies.
20
+ # :billing_address - A hash containing the billing address of the customer.
21
+ # :shipping_address - A hash containing the shipping address of the customer.
22
+
23
+ # The :billing_address, and :shipping_address hashes can have the following keys:
24
+
25
+ # :name - The full name of the customer.
26
+ # :company - The company name of the customer.
27
+ # :address1 - The primary street address of the customer.
28
+ # :address2 - Additional line of address information.
29
+ # :city - The city of the customer.
30
+ # :state - The state of the customer. The 2 digit code for US and Canadian addresses. The full name of the state or province for foreign addresses.
31
+ # :country - The [ISO 3166-1-alpha-2 code](www.iso.org/iso/country_codes/iso_3166_code_lists/english_country_names_and_code_elements.htm) for the customer.
32
+ # :zip - The zip or postal code of the customer.
33
+ # :phone - The phone number of the customer.
34
+
35
+ def match_score(money, creditcard, options)
36
+ name = (options[:billing_address] && options[:billing_address][:name]) ||
37
+ (options[:shipping_address] && options[:shipping_address][:name])
38
+
39
+ billing_address_street = get_street options[:billing_address]
40
+ billing_address_zip = get_zip options[:billing_address]
41
+ billing_phone = get_phone options[:shipping_address]
42
+
43
+ shipping_address_street = get_street options[:shipping_address]
44
+ shipping_address_zip = get_zip options[:shipping_address]
45
+ shipping_phone = get_phone options[:shipping_address]
46
+
47
+ WhitepagesPro.match_score(name, billing_address_street, billing_address_zip, billing_phone,
48
+ shipping_address_street, shipping_address_zip, shipping_phone)
49
+ end
50
+
51
+ def get_street(address_info)
52
+ return nil unless address_info
53
+ "#{address_info[:address1]} #{address_info[:address2]}"
54
+ end
55
+
56
+ def get_zip(address_info)
57
+ return address_info[:zip] if address_info[:zip]
58
+ return "#{address_info[:city]} #{address_info[:state]}"
59
+ end
60
+
61
+ def get_phone(address_info)
62
+ address_info[:phone]
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,4 @@
1
+ module WhitepagesPro
2
+ # The current version of the WhitePagesPRO gem.
3
+ VERSION = '0.1.0'
4
+ end
@@ -0,0 +1,73 @@
1
+ require 'httparty'
2
+ require 'json'
3
+
4
+ module WhitepagesPro
5
+
6
+ class WhitepagesPro
7
+ include HTTParty
8
+ base_uri 'https://proapi.whitepages.com'
9
+ # debug_output
10
+
11
+ def WhitepagesPro.api_key(api_key)
12
+ @@api_key = api_key
13
+ end
14
+
15
+ def WhitepagesPro.get_default_options
16
+ {}.tap do | options |
17
+ options["api_key"] = @@api_key
18
+ options["outputtype"] = "JSON"
19
+ end
20
+ end
21
+
22
+ def WhitepagesPro.result(response)
23
+ return nil unless response.code == 200
24
+ JSON.parse response.body
25
+ end
26
+
27
+
28
+ def WhitepagesPro.match_score(name = nil, billing_address_street = nil, billing_address_zip = nil, billing_phone = nil, shipping_address_street = nil, shipping_address_zip = nil, shipping_phone = nil)
29
+ query = get_default_options
30
+ query["name"] = name if name
31
+ query["billing_address_street"] = billing_address_street if billing_address_street
32
+ query["billing_address_zip"] = billing_address_zip if billing_address_zip
33
+ query["billing_phone"] = billing_phone if billing_phone
34
+ query["shipping_address_street"] = shipping_address_street if shipping_address_street
35
+ query["shipping_address_zip"] = shipping_address_zip if shipping_address_zip
36
+ query["shipping_phone"] = shipping_phone if shipping_phone
37
+
38
+ result get("/match_score/1.1/", :query => query)
39
+
40
+ end
41
+
42
+ def WhitepagesPro.reverse_address(street, where)
43
+ query = get_default_options
44
+ query["street"] = street
45
+ query["where"] = where
46
+
47
+ result get("/reverse_address/1.1", :query => query)
48
+ end
49
+
50
+ def WhitepagesPro.reverse_phone(phone)
51
+ query = get_default_options
52
+ query["phone"] = phone
53
+ result get("/reverse_phone/1.1", :query => query)
54
+ end
55
+
56
+ def WhitepagesPro.find_person(name, where, metro = true)
57
+ query = get_default_options
58
+ query["metro"] = metro ? 1 : 0
59
+ query["name"] = name
60
+ query["where"] = where
61
+
62
+ result get("/find_person/1.1", :query => query)
63
+ end
64
+
65
+ def WhitepagesPro.find_business(keywords, where)
66
+ query = get_default_options
67
+ query["keywords"] = keywords
68
+ query["location"] = where
69
+
70
+ result get("/find_business/1.1", :query => query)
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,8 @@
1
+ require 'whitepages_pro/version'
2
+
3
+ require 'whitepages_pro/whitepages_pro'
4
+ require 'whitepages_pro/match_score'
5
+
6
+ module WhitepagesPro
7
+ # Only declared here for RDoc docuemntation purposes of the module.
8
+ end
@@ -0,0 +1,81 @@
1
+ require 'spec_helper'
2
+ require 'activemerchant'
3
+
4
+ describe WhitepagesPro::MatchScore do
5
+ describe 'requests' do
6
+ it 'should return a payload for match score' do
7
+ # test gateway
8
+ ActiveMerchant::Billing::Base.mode = :test
9
+
10
+ credit_card = ActiveMerchant::Billing::CreditCard.new(
11
+ :number => '4111111111111111',
12
+ :month => '8',
13
+ :year => '2015',
14
+ :first_name => 'Matt',
15
+ :last_name => 'Woodward',
16
+ :verification_value => '123'
17
+ )
18
+ expect(credit_card.valid?).to eq(true)
19
+
20
+ # Create a gateway object to the TrustCommerce service
21
+ gateway = ActiveMerchant::Billing::TrustCommerceGateway.new(
22
+ :login => 'TestMerchant',
23
+ :password => 'password'
24
+ )
25
+
26
+ billing_address = {
27
+ :name => 'Matt Woodward',
28
+ :address1 => '1835 73rd Ave NE',
29
+ :city => 'Medina',
30
+ :state => 'WA',
31
+ :zip => '98039',
32
+ :phone => '4254138445',
33
+ }
34
+
35
+ shipping_address = {
36
+ :name => 'Matt Woodward',
37
+ :address1 => '1301 5th Ave',
38
+ :address2 => 'Suite 1600',
39
+ :city => 'Seattle',
40
+ :state => 'WA',
41
+ :zip => '98101',
42
+ :phone => '2069735100',
43
+ }
44
+
45
+ order = {
46
+ :order_id => '1234',
47
+ :ip => '192.168.1.1',
48
+ :customer => 'c118e792',
49
+ :invoice => '230',
50
+ :merchant => 'SuperTrain, Inc.',
51
+ :description => 'ticket purchase',
52
+ :email => 'mwoodward@whitepages.com',
53
+ :currency => 'USD',
54
+ :billing_address => billing_address,
55
+ :shipping_address => shipping_address,
56
+ }
57
+
58
+ gateway.extend(WhitepagesPro::MatchScore)
59
+
60
+ gateway.api_key APIKey.get_api_key
61
+
62
+ ms_response = gateway.match_score(1000, credit_card, order)
63
+
64
+ expect(ms_response).not_to eq(nil)
65
+
66
+
67
+ # authorize for $10
68
+
69
+ response = gateway.authorize(1000, credit_card, order)
70
+
71
+ if response.success?
72
+ # capture
73
+ gateway.capture(1000, response.authorization, order)
74
+ end
75
+ end
76
+
77
+ it 'should not return a payload outside of the US' do
78
+ end
79
+
80
+ end
81
+ end
@@ -0,0 +1,25 @@
1
+ require 'simplecov'
2
+ require 'yaml'
3
+
4
+ SimpleCov.start do
5
+ add_filter {|sf| sf.filename !~ /\/lib\//}
6
+ end
7
+
8
+ require 'whitepages_pro'
9
+
10
+ # Require the debugger, if present.
11
+ begin
12
+ require 'debugger'
13
+ rescue LoadError
14
+ module Kernel
15
+ def debugger(*args, &block)
16
+ STDERR.puts "*** Debugger not available."
17
+ end
18
+ end
19
+ end
20
+
21
+ class APIKey
22
+ def APIKey.get_api_key
23
+ YAML.load_file('apikey.yml')["whitepages_api_key"]
24
+ end
25
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe WhitepagesPro::WhitepagesPro do
4
+ describe 'requests' do
5
+ it 'should return a json payload for reverse_phone' do
6
+ WhitepagesPro::WhitepagesPro.api_key APIKey.get_api_key
7
+ rev_phone_data = WhitepagesPro::WhitepagesPro.reverse_phone("2069735100")
8
+ expect(rev_phone_data).not_to eq(nil)
9
+ end
10
+
11
+ it 'should return a json payload for find_person' do
12
+ WhitepagesPro::WhitepagesPro.api_key APIKey.get_api_key
13
+ find_person_data = WhitepagesPro::WhitepagesPro.find_person("bill gates", "seattle, wa")
14
+ expect(find_person_data).not_to eq(nil)
15
+ end
16
+
17
+ it 'should return a json payload for match_score' do
18
+ WhitepagesPro::WhitepagesPro.api_key APIKey.get_api_key
19
+ match_score_data = WhitepagesPro::WhitepagesPro.match_score("Matthew Woodward", "12234 10th ave s", "98168", "2062444545", "12234 10th ave s", "98168", "2062444724")
20
+ expect(match_score_data).not_to eq(nil)
21
+ end
22
+
23
+ it 'should return a json payload reverse_address' do
24
+ WhitepagesPro::WhitepagesPro.api_key APIKey.get_api_key
25
+ rev_address_data = WhitepagesPro::WhitepagesPro.reverse_address("1301 5th Ave", "seattle, wa")
26
+ expect(rev_address_data).not_to eq(nil)
27
+ end
28
+
29
+ it 'should return a json payload for find_business' do
30
+ WhitepagesPro::WhitepagesPro.api_key APIKey.get_api_key
31
+ find_business_data = WhitepagesPro::WhitepagesPro.find_business("starbucks", "seattle, wa")
32
+ expect(find_business_data).not_to eq(nil)
33
+ end
34
+ end
35
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: whitepages_pro
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Matt Woodward
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-04-28 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: WhitePagesPRO provides lookup and anti-fraud APIs. For access, please
14
+ contact pro-sales@whitepages.com
15
+ email:
16
+ - mwoodward@whitepages.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files:
20
+ - README.rdoc
21
+ files:
22
+ - lib/whitepages_pro/match_score.rb
23
+ - lib/whitepages_pro/version.rb
24
+ - lib/whitepages_pro/whitepages_pro.rb
25
+ - lib/whitepages_pro.rb
26
+ - spec/match_score_spec.rb
27
+ - spec/spec_helper.rb
28
+ - spec/whitepages_pro_spec.rb
29
+ - README.rdoc
30
+ - LICENSE.txt
31
+ - Rakefile
32
+ homepage: https://github.com/whitepages/whitepages_pro
33
+ licenses:
34
+ - BSD
35
+ metadata: {}
36
+ post_install_message:
37
+ rdoc_options: []
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ requirements: []
51
+ rubyforge_project:
52
+ rubygems_version: 2.0.3
53
+ signing_key:
54
+ specification_version: 4
55
+ summary: Ruby interfaces for WhitePagesPRO web services.
56
+ test_files: []
57
+ has_rdoc: true