whitepagespro 0.0.2

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1a4663a819858fe210aa431cef3fb6984449cb75
4
+ data.tar.gz: 786335defddba056c7cdd5d3bbeadaa71a4acdd5
5
+ SHA512:
6
+ metadata.gz: a8e4d77a880076c986b94e7c8a7fc3cdd3d054b045161e0b7d4939f2482757cbeb54b74a6729d329d9178c1dbb3a41311e14c483bd4498d77f15c3206b9d46dc
7
+ data.tar.gz: bda39e1d2f08aa055080d3bb6dcdde5885adcbb893a1d98fa1e2e0e4a2966b9b7a2155781a56df19110cecb0d576bf1cd351f665b7bd4b5c78976c7d5d37b774
@@ -0,0 +1,22 @@
1
+ require 'whitepagespro/configurable'
2
+ require 'whitepagespro/client'
3
+
4
+ module WhitepagesPro
5
+
6
+ class << self
7
+ include WhitepagesPro::Configurable
8
+ end
9
+
10
+ # def configure
11
+ # yield config
12
+ # end
13
+
14
+ # def config
15
+ # @config ||= Configuration.new
16
+ # end
17
+
18
+
19
+ # def reset_config
20
+ # @config = nil
21
+ # end
22
+ end
@@ -0,0 +1,41 @@
1
+ require 'whitepagespro/api/util'
2
+ module WhitepagesPro
3
+ module API
4
+ module IdentityCheck
5
+ include WhitepagesPro::API::Util
6
+
7
+ API_VERSION = '3.2'
8
+
9
+ def identity_check(options = {})
10
+ api_key = api_keys[:identity_check]
11
+ call('phone_intel', API_VERSION, :get, {api_key: api_key}.merge(options))
12
+ end
13
+
14
+ def api_key_valid?
15
+ true unless keys[:identity_check_api_key].blank?
16
+ false
17
+ end
18
+ end
19
+ end
20
+ end
21
+
22
+ #
23
+ # primary.name
24
+ # primary.phone
25
+ # primary.address.street_line_1
26
+ # primary.address.street_line_2 (optional, can include this as part of street_line_1)
27
+ # primary.address.city
28
+ # primary.address.state_code
29
+ # primary.address.postal_code
30
+ # primary.address.country_code
31
+ # email_address
32
+ # ip_address
33
+ #
34
+ # secondary.name
35
+ # secondary.phone
36
+ # secondary.address.street_line_1
37
+ # secondary.address.street_line_2 (optional, can include this as part of street_line_1)
38
+ # secondary.address.city
39
+ # secondary.address.state_code
40
+ # secondary.address.postal_code
41
+ # secondary.address.country_code
@@ -0,0 +1,20 @@
1
+ require 'whitepagespro/api/util'
2
+ module WhitepagesPro
3
+ module API
4
+ module PhoneIntelligence
5
+ include WhitepagesPro::API::Util
6
+
7
+ API_VERSION = '3.0'
8
+
9
+ def intelligence_lookup(phone_number, options = {})
10
+ api_key = api_keys[:phone_intelligence_api_key]
11
+ call('phone_intel', API_VERSION, :get, {phone: phone_number, api_key: api_key}.merge(options))
12
+ end
13
+
14
+ def api_key_valid?
15
+ true unless keys[:phone_intelligence_api_key].blank?
16
+ false
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ require 'whitepagespro/api/util'
2
+ module WhitepagesPro
3
+ module API
4
+ module ReversePhone
5
+ include WhitepagesPro::API::Util
6
+
7
+ API_VERSION = '3.0'
8
+
9
+ def reverse_lookup(phone_number, options = {})
10
+ api_key = api_keys[:reverse_phone_api_key]
11
+ call('phone', API_VERSION, :get, {phone: phone_number, api_key: api_key}.merge(options))
12
+ end
13
+
14
+ def api_key_valid?
15
+ true unless keys[:reverse_phone_api_key].blank?
16
+ false
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,43 @@
1
+ require 'net/http'
2
+ require 'json'
3
+
4
+ module WhitepagesPro
5
+ module API
6
+ module Util
7
+
8
+ include WhitepagesPro::Configurable
9
+
10
+ ROOT_URL = 'https://proapi.whitepages.com'
11
+
12
+ def call(path, api_version = "3.0", type = :get, params = {})
13
+
14
+ uri = URI.parse(build_url(path, api_version))
15
+ uri.query = URI.encode_www_form(params)
16
+
17
+ http = Net::HTTP.new(uri.host, uri.port)
18
+
19
+ http.use_ssl = true if uri.scheme.upcase == "HTTPS"
20
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE if uri.scheme.upcase == "HTTPS"
21
+
22
+ case type
23
+ when :get
24
+ request = Net::HTTP::Get.new(uri.request_uri)
25
+ when :post
26
+ request = Net::HTTP::Post.new(uri.request_uri)
27
+ end
28
+
29
+ response = http.request(request)
30
+ JSON.parse(response.body)
31
+ end
32
+
33
+ def build_url(path, api_version)
34
+ "#{ File.join(ROOT_URL, api_version, path) }"
35
+ end
36
+
37
+ def phone_number_valid?(phone_number)
38
+ return true
39
+ end
40
+
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,18 @@
1
+ require 'whitepagespro/api/util'
2
+ require 'whitepagespro/api/reverse_phone'
3
+ require 'whitepagespro/api/phone_intelligence'
4
+
5
+ module WhitepagesPro
6
+
7
+ class Client
8
+ include WhitepagesPro::Configurable
9
+ include WhitepagesPro::API::ReversePhone
10
+ include WhitepagesPro::API::PhoneIntelligence
11
+
12
+ def initialize(options={})
13
+ WhitepagesPro::Configurable.keys.each do |key|
14
+ instance_variable_set(:"@#{key}", options[key] || WhitepagesPro.instance_variable_get(:"@#{key}"))
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,41 @@
1
+
2
+ module WhitepagesPro
3
+ module Configurable
4
+
5
+ attr_writer :identity_check_api_key, :lead_verify_api_key, :reverse_phone_api_key, :phone_intelligence_api_key,
6
+ :phone_reputation_api_key, :find_person_api_key, :reverse_address_api_key
7
+
8
+ class << self
9
+ def keys
10
+ @keys ||= [
11
+ :identity_check_api_key,
12
+ :lead_verify_api_key,
13
+ :reverse_phone_api_key,
14
+ :phone_intelligence_api_key,
15
+ :phone_reputation_api_key,
16
+ :find_person_api_key,
17
+ :reverse_address_api_key
18
+ ]
19
+ end
20
+ end
21
+
22
+ def configure
23
+ yield self
24
+ self
25
+ end
26
+
27
+
28
+ def api_keys
29
+
30
+ {
31
+ identity_check_api_key: @identity_check_api_key,
32
+ lead_verify_api_key: @lead_verify_api_key,
33
+ reverse_phone_api_key: @reverse_phone_api_key,
34
+ phone_intelligence_api_key: @phone_intelligence_api_key,
35
+ phone_reputation_api_key: @phone_reputation_api_key,
36
+ find_person_api_key: @find_person_api_key,
37
+ reverse_address_api_key: @reverse_address_api_key
38
+ }
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,6 @@
1
+
2
+ require 'spec_helper'
3
+
4
+ describe WhitepagesPro::API::PhoneIntelligence do
5
+
6
+ end
@@ -0,0 +1,6 @@
1
+
2
+ require 'spec_helper'
3
+
4
+ describe WhitepagesPro::API::ReversePhone do
5
+
6
+ end
@@ -0,0 +1,6 @@
1
+
2
+ require 'spec_helper'
3
+
4
+ describe WhitepagesPro::API::Util do
5
+
6
+ end
@@ -0,0 +1,26 @@
1
+
2
+ require 'simplecov'
3
+
4
+ SimpleCov.start do
5
+ add_filter {|sf| sf.filename !~ /\/lib\//}
6
+ end
7
+
8
+ require 'whitepagespro'
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
+
22
+ class TestAPIKeys
23
+ def TestAPIKeys.get_reverse_phone_key
24
+ YAML.load_file('api_keys.yml')["reverse_phone_key"]
25
+ end
26
+ end
metadata ADDED
@@ -0,0 +1,54 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: whitepagespro
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Jonathan De Jong
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-06-08 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: This gem is for interacting with version 3.0 of the Whitepages Pro API
14
+ email: ''
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/whitepagespro.rb
20
+ - lib/whitepagespro/api/identity_check.rb
21
+ - lib/whitepagespro/api/phone_intelligence.rb
22
+ - lib/whitepagespro/api/reverse_phone.rb
23
+ - lib/whitepagespro/api/util.rb
24
+ - lib/whitepagespro/client.rb
25
+ - lib/whitepagespro/configurable.rb
26
+ - spec/api/phone_intelligence_spec.rb
27
+ - spec/api/reverse_phone_spec.rb
28
+ - spec/api/util_spec.rb
29
+ - spec/spec_helper.rb
30
+ homepage: http://rubygems.org/gems/whitepagespro
31
+ licenses:
32
+ - MIT
33
+ metadata: {}
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirements: []
49
+ rubyforge_project:
50
+ rubygems_version: 2.4.8
51
+ signing_key:
52
+ specification_version: 4
53
+ summary: Whitpages Pro
54
+ test_files: []