phone_connect 1.0.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1178f87218f6ac7b5727c40df0efb16a5ddcb15a
4
+ data.tar.gz: 4e637e8058de9731b304e1e19f9de8f63985f8f9
5
+ SHA512:
6
+ metadata.gz: c0a3599a7f684674bbecdd36a013cf0f2fe7b5719303c8cacd0440733ff38a4a3843270849e00035c609887b839d475bb1485ca81d4f75b3012656106f4a570a
7
+ data.tar.gz: c25aaf6151e12b905fad16d1d4176b129c4793db67e79f97df64ab10c56a8d6fd8aa2295e7aa9f5bcf0688a2148925ff240aba507c2c20458bc1e2282e991779
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
4
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in phone_connect.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 homoudrana
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # PhoneConnect
2
+
3
+ This is a Ruby gem integrated with [RealPhoneValidation](https://realphonevalidation.com/) Turbo API to validate / determine the connectivity of US phone numbers.
4
+
5
+ It provides: Connected/Disconnected, Phone Type (landline, cell, VoIP), & Carrier ID.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'phone_connect'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install phone_connect
22
+
23
+ ## Usage
24
+
25
+ Add the following configurations in `config/initializers`:
26
+
27
+ ```ruby
28
+ # phone_connect_config.rb
29
+
30
+ PhoneConnect.configure do |config|
31
+ config.token = "5FA3B89E-21A4-C4E1-2AB2-B87BA3C1659F" # RealPhoneValidation Token
32
+ config.timeout = 5 # Request Timeout
33
+ end
34
+ ```
35
+
36
+ Then simply use the following command:
37
+ ```ruby
38
+ response = PhoneConnect.response "9991112222" # your testing phone numebr
39
+ # => {"status"=>"connected", "error_text"=>nil, "iscell"=>"Y", "cnam"=>"WIRELESS CALLER", "carrier"=>"Verizon Wireless"}
40
+ # => {"status"=>"disconnected", "error_text"=>nil, "iscell"=>"N", "cnam"=>"Unavailable", "carrier"=>"Pioneer Tel Coop"}
41
+ # status could be connected|connected-75|busy|pending|disconnected
42
+ ```
43
+
44
+ ## Contributing
45
+
46
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/phone_connect. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
47
+
48
+
49
+ ## License
50
+
51
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "phone_connect"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,22 @@
1
+ require "phone_connect/version"
2
+ require "phone_connect/configuration"
3
+ require "phone_connect/real_phone_validation"
4
+
5
+ module PhoneConnect
6
+ class << self
7
+ attr_accessor :configuration
8
+
9
+ def configure
10
+ self.configuration ||= Configuration.new
11
+ yield(configuration)
12
+ end
13
+
14
+ def reset
15
+ @configuration = Configuration.new
16
+ end
17
+
18
+ def fetch(phone_number)
19
+ PhoneConnect::RealPhoneValidation.new(phone_number)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,12 @@
1
+ module PhoneConnect
2
+ class Configuration
3
+
4
+ attr_accessor :token, :timeout
5
+
6
+ def initialize
7
+ @token = ''
8
+ @timeout = ''
9
+ end
10
+
11
+ end
12
+ end
@@ -0,0 +1,66 @@
1
+ require 'httparty'
2
+
3
+ module PhoneConnect
4
+ class RealPhoneValidation
5
+ include HTTParty
6
+ base_uri 'https://api.realvalidation.com'
7
+
8
+ attr_reader :phone_number, :execution_time
9
+
10
+ def initialize(phone_number)
11
+ @phone_number = phone_number
12
+ normalize!
13
+ end
14
+
15
+ def connected?
16
+ status = response['status']
17
+ return false unless status
18
+
19
+ !!status.match(/^(connected|connected-75|busy|pending)$/i)
20
+ end
21
+
22
+ def response
23
+ @parsed_response ||= validate
24
+ end
25
+
26
+ private
27
+
28
+ def normalize!
29
+ @phone_number = @phone_number.to_s.gsub(/[^0-9]/, '')
30
+ # Remove first digit `1` (US key) if the phone's length is 11 digits
31
+ @phone_number[0] = '' if @phone_number.length == 11 && @phone_number[0] == '1'
32
+ end
33
+
34
+ def options
35
+ {
36
+ verify: false,
37
+ timeout: PhoneConnect.configuration.timeout,
38
+ body: {
39
+ output: 'json',
40
+ token: PhoneConnect.configuration.token,
41
+ phone: @phone_number
42
+ }
43
+ }
44
+ end
45
+
46
+ def validate
47
+ start_time = Time.now
48
+ retries = 3
49
+ result = {}
50
+ begin
51
+ result = self.class.post('/rpvWebService/RealPhoneValidationTurbo.php', options).parsed_response
52
+ rescue Timeout::Error
53
+ retries -= 1
54
+ if retries.positive?
55
+ sleep 1; retry
56
+ end
57
+ result = { 'status' => 'TIMEOUT', 'error_text' => 'Timeout' }
58
+ rescue Exception => exception
59
+ result = { 'status' => 'ERROR', 'error_text' => exception.to_s }
60
+ end
61
+ @execution_time = Time.now - start_time
62
+
63
+ result
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,3 @@
1
+ module PhoneConnect
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,34 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'phone_connect/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "phone_connect"
8
+ spec.version = PhoneConnect::VERSION
9
+ spec.authors = ["homoudrana", 'Zakwan Hajjar']
10
+ spec.email = ["rana@remodeling.com", 'zakwan.haj@gmail.com']
11
+
12
+ spec.summary = %q{Check and determine the connectivity of US phone numbers}
13
+ spec.description = %q{Check and determine the connectivity of US phone numbers}
14
+ spec.homepage = ""
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+
19
+ # delete this section to allow pushing this gem to any host.
20
+ # if spec.respond_to?(:metadata)
21
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
22
+ # else
23
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
24
+ # end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_development_dependency "bundler", "~> 1.10"
32
+ spec.add_development_dependency "rake", "~> 10.0"
33
+ spec.add_runtime_dependency "httparty"
34
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: phone_connect
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - homoudrana
8
+ - Zakwan Hajjar
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2019-09-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.10'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.10'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '10.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '10.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: httparty
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ description: Check and determine the connectivity of US phone numbers
57
+ email:
58
+ - rana@remodeling.com
59
+ - zakwan.haj@gmail.com
60
+ executables: []
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - ".travis.yml"
65
+ - CODE_OF_CONDUCT.md
66
+ - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - bin/console
71
+ - bin/setup
72
+ - lib/phone_connect.rb
73
+ - lib/phone_connect/configuration.rb
74
+ - lib/phone_connect/real_phone_validation.rb
75
+ - lib/phone_connect/version.rb
76
+ - phone_connect.gemspec
77
+ homepage: ''
78
+ licenses:
79
+ - MIT
80
+ metadata: {}
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.6.13
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: Check and determine the connectivity of US phone numbers
101
+ test_files: []