gvive 0.1.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 +7 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.travis.yml +12 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +64 -0
- data/LICENSE.txt +21 -0
- data/README.md +109 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/gvive.gemspec +30 -0
- data/lib/gvive.rb +24 -0
- data/lib/gvive/configuration.rb +14 -0
- data/lib/gvive/encoding.rb +40 -0
- data/lib/gvive/identities.rb +18 -0
- data/lib/gvive/identity/driver.rb +23 -0
- data/lib/gvive/identity/passport.rb +20 -0
- data/lib/gvive/identity/voter.rb +20 -0
- data/lib/gvive/response.rb +29 -0
- data/lib/gvive/utils.rb +44 -0
- data/lib/gvive/version.rb +3 -0
- metadata +150 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 7f150a770738b0094810f0822cdd64b28353875e
|
|
4
|
+
data.tar.gz: be2426747f4a084c0a6ade7ac646afe31f80fce6
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 3c37d011e68a97d21970f550a71874d2b59687fc5b4d7239e214f3870a0c5cb1d3e27738fc0f4cd103f6af311ba03bfa305161a02eb381a8453303141737aa8a
|
|
7
|
+
data.tar.gz: 3003aec8f51e6f040ada1a1ccfc7cc30f9cdadd8b0132f694f24a33897629d4dccda02cd605c72bbb1f47410ec08778738f1959b99d2de636d204058c6c98466
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
addons:
|
|
2
|
+
code_climate:
|
|
3
|
+
repo_token: fd4f98a0b879612c6384c111a73a31b5be9c63df23fc0a1ffd02f9fadc8c7f24
|
|
4
|
+
after_success:
|
|
5
|
+
- bundle exec codeclimate-test-reporter
|
|
6
|
+
language: ruby
|
|
7
|
+
rvm:
|
|
8
|
+
- 2.4.0
|
|
9
|
+
- 2.3.0
|
|
10
|
+
- 2.2.0
|
|
11
|
+
- 2.1
|
|
12
|
+
before_install: gem install bundler --pre
|
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at alfred@encodevlabs.com. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: http://contributor-covenant.org
|
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
gvive (0.1.0)
|
|
5
|
+
http (~> 2.0)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
addressable (2.5.2)
|
|
11
|
+
public_suffix (>= 2.0.2, < 4.0)
|
|
12
|
+
codeclimate-test-reporter (1.0.7)
|
|
13
|
+
simplecov
|
|
14
|
+
diff-lcs (1.3)
|
|
15
|
+
docile (1.1.5)
|
|
16
|
+
domain_name (0.5.20170404)
|
|
17
|
+
unf (>= 0.0.5, < 1.0.0)
|
|
18
|
+
http (2.2.2)
|
|
19
|
+
addressable (~> 2.3)
|
|
20
|
+
http-cookie (~> 1.0)
|
|
21
|
+
http-form_data (~> 1.0.1)
|
|
22
|
+
http_parser.rb (~> 0.6.0)
|
|
23
|
+
http-cookie (1.0.3)
|
|
24
|
+
domain_name (~> 0.5)
|
|
25
|
+
http-form_data (1.0.3)
|
|
26
|
+
http_parser.rb (0.6.0)
|
|
27
|
+
json (2.1.0)
|
|
28
|
+
public_suffix (3.0.0)
|
|
29
|
+
rake (10.5.0)
|
|
30
|
+
rspec (3.6.0)
|
|
31
|
+
rspec-core (~> 3.6.0)
|
|
32
|
+
rspec-expectations (~> 3.6.0)
|
|
33
|
+
rspec-mocks (~> 3.6.0)
|
|
34
|
+
rspec-core (3.6.0)
|
|
35
|
+
rspec-support (~> 3.6.0)
|
|
36
|
+
rspec-expectations (3.6.0)
|
|
37
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
38
|
+
rspec-support (~> 3.6.0)
|
|
39
|
+
rspec-mocks (3.6.0)
|
|
40
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
41
|
+
rspec-support (~> 3.6.0)
|
|
42
|
+
rspec-support (3.6.0)
|
|
43
|
+
simplecov (0.15.1)
|
|
44
|
+
docile (~> 1.1.0)
|
|
45
|
+
json (>= 1.8, < 3)
|
|
46
|
+
simplecov-html (~> 0.10.0)
|
|
47
|
+
simplecov-html (0.10.2)
|
|
48
|
+
unf (0.1.4)
|
|
49
|
+
unf_ext
|
|
50
|
+
unf_ext (0.0.7.4)
|
|
51
|
+
|
|
52
|
+
PLATFORMS
|
|
53
|
+
ruby
|
|
54
|
+
|
|
55
|
+
DEPENDENCIES
|
|
56
|
+
bundler (~> 1.16.a)
|
|
57
|
+
codeclimate-test-reporter (~> 1.0.0)
|
|
58
|
+
gvive!
|
|
59
|
+
rake (~> 10.0)
|
|
60
|
+
rspec (~> 3.0)
|
|
61
|
+
simplecov
|
|
62
|
+
|
|
63
|
+
BUNDLED WITH
|
|
64
|
+
1.16.0.pre.2
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Alfred Rowe
|
|
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,109 @@
|
|
|
1
|
+
[](https://codeclimate.com/github/nukturnal/gvive) [](https://travis-ci.org/nukturnal/gvive)
|
|
2
|
+
# GVIVE Ruby SDK
|
|
3
|
+
|
|
4
|
+
This gem is a wrapper around GVIVE Identity Verification API offered at https://gvivegh.com/ by Bsystems Limited Ghana. The SDK currently supports Voter ID, Passport & Driver License verifications.
|
|
5
|
+
|
|
6
|
+
This gem was extracted from a private project I was working on for reuse in other projects, hope it saves u some code time :)
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
Add this line to your application's Gemfile:
|
|
11
|
+
|
|
12
|
+
```ruby
|
|
13
|
+
gem 'gvive'
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
And then execute:
|
|
17
|
+
|
|
18
|
+
$ bundle
|
|
19
|
+
|
|
20
|
+
Or install it yourself as:
|
|
21
|
+
|
|
22
|
+
$ gem install gvive
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
### Environment Variables
|
|
27
|
+
You can simply set `GVIVE_API_KEY` & `GVIVE_USERNAME` environment variables and gem should work flawlessly. You may check your OS documentations on how to set environment variables.
|
|
28
|
+
|
|
29
|
+
On Mac OS X & Linux Systems you can set these variables in your `~/.profile`
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
export GVIVE_API_KEY=some_api_key
|
|
33
|
+
export GVIVE_USERNAME=some_username
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Initializer Setup (Optional)
|
|
37
|
+
If you do not prefer or want to override the environment variable option you can simply initialize a config setting. If you using Rails you can put this in your `initializers` directory eg `initializers/gvive.rb`
|
|
38
|
+
|
|
39
|
+
```ruby
|
|
40
|
+
GVIVE.configure do |config|
|
|
41
|
+
config.api_key = 'some_api_key' # Provided by GVIVE
|
|
42
|
+
config.username = 'some_username' # Provided by GVIVE
|
|
43
|
+
end
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Voter ID Verification
|
|
47
|
+
You are required to provide the Voter ID number
|
|
48
|
+
|
|
49
|
+
```ruby
|
|
50
|
+
voter = GVIVE::Identity::Voter.new('6580676543')
|
|
51
|
+
if voter.valid?
|
|
52
|
+
p voter.data.Fullname
|
|
53
|
+
p voter.data.PollingStation
|
|
54
|
+
p voter.data.ResidentialAddress
|
|
55
|
+
# ...
|
|
56
|
+
else
|
|
57
|
+
p voter.data.Message
|
|
58
|
+
end
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Passport ID Verification
|
|
62
|
+
You are required to provide the Passport ID number
|
|
63
|
+
|
|
64
|
+
```ruby
|
|
65
|
+
passport = GVIVE::Identity::Passport.new('G00827283')
|
|
66
|
+
if passport.valid?
|
|
67
|
+
p passport.data.FirstName
|
|
68
|
+
p passport.data.LastName
|
|
69
|
+
p passport.data.Gender
|
|
70
|
+
p passport.data.ExpiryDate
|
|
71
|
+
# ...
|
|
72
|
+
else
|
|
73
|
+
p passport.data.Message
|
|
74
|
+
end
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Driver License Verification
|
|
78
|
+
You are required to provide the Certificate of Competence Number & the full name as printed exactly on the card.
|
|
79
|
+
|
|
80
|
+
```ruby
|
|
81
|
+
driver = GVIVE::Identity::Driver.new('COO92930','Alfred Rowe')
|
|
82
|
+
if driver.valid?
|
|
83
|
+
p driver.data.FirstName
|
|
84
|
+
p driver.data.LastName
|
|
85
|
+
p driver.data.Gender
|
|
86
|
+
p driver.data.ExpiryDate
|
|
87
|
+
# ...
|
|
88
|
+
else
|
|
89
|
+
p driver.data.Message
|
|
90
|
+
end
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Development
|
|
94
|
+
|
|
95
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
96
|
+
|
|
97
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
98
|
+
|
|
99
|
+
## Contributing
|
|
100
|
+
|
|
101
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/gvive. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
102
|
+
|
|
103
|
+
## License
|
|
104
|
+
|
|
105
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
106
|
+
|
|
107
|
+
## Code of Conduct
|
|
108
|
+
|
|
109
|
+
Everyone interacting in the Gvive project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/nukturnal/gvive/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "gvive"
|
|
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(__FILE__)
|
data/bin/setup
ADDED
data/gvive.gemspec
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require "gvive/version"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "gvive"
|
|
8
|
+
spec.version = GVIVE::VERSION
|
|
9
|
+
spec.authors = ["Alfred Rowe"]
|
|
10
|
+
spec.email = ["alfred@encodevlabs.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{GVIVE Ruby SDK}
|
|
13
|
+
spec.description = %q{Identity Theft Protection SDK for GVIVE Web Service}
|
|
14
|
+
spec.homepage = "https://github.com/nukturnal/gvive"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
|
19
|
+
end
|
|
20
|
+
spec.bindir = "exe"
|
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
22
|
+
spec.require_paths = ["lib"]
|
|
23
|
+
|
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.16.a"
|
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
27
|
+
spec.add_development_dependency "simplecov"
|
|
28
|
+
spec.add_development_dependency "codeclimate-test-reporter", "~> 1.0.0"
|
|
29
|
+
spec.add_dependency "http", "~> 2.0"
|
|
30
|
+
end
|
data/lib/gvive.rb
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require "gvive/version"
|
|
2
|
+
require "gvive/configuration"
|
|
3
|
+
require "gvive/encoding"
|
|
4
|
+
require "gvive/response"
|
|
5
|
+
require "gvive/utils"
|
|
6
|
+
require "gvive/identities"
|
|
7
|
+
|
|
8
|
+
module GVIVE
|
|
9
|
+
class << self
|
|
10
|
+
attr_accessor :configuration
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.configuration
|
|
14
|
+
@configuration ||= Configuration.new
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# def self.reset
|
|
18
|
+
# @configuration = Configuration.new
|
|
19
|
+
# end
|
|
20
|
+
|
|
21
|
+
def self.configure
|
|
22
|
+
yield(configuration)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module GVIVE
|
|
2
|
+
class Configuration
|
|
3
|
+
attr_accessor :base_url, :api_key, :username, :voter_path, :passport_path, :driver_path
|
|
4
|
+
|
|
5
|
+
def initialize
|
|
6
|
+
@base_url = 'https://gvivegh.com:1355/gvivewar' # GVIVE Base Endpoint
|
|
7
|
+
@api_key = ENV['GVIVE_API_KEY'] # GVIVE APIKey
|
|
8
|
+
@username = ENV['GVIVE_USERNAME'] # GVIVE Username
|
|
9
|
+
@voter_path = '/voter' # Voter ID Veriification path
|
|
10
|
+
@passport_path = '/passport' # Passport Veriification path
|
|
11
|
+
@driver_path = '/driver' # Driver License Veriification path
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
require 'uri'
|
|
2
|
+
require 'cgi'
|
|
3
|
+
require 'openssl'
|
|
4
|
+
require 'base64'
|
|
5
|
+
|
|
6
|
+
# GVIVE Payload Diget
|
|
7
|
+
module GVIVE
|
|
8
|
+
module Encoding
|
|
9
|
+
|
|
10
|
+
# From the GVIVE docs this is REQUEST METHOD + ENCODED URL
|
|
11
|
+
# eg. https://gvivegh.com:1355/gvivewar/Voter?Vid=123456
|
|
12
|
+
# becomes https%3A%2F%2Fgvivegh.com%3A1355%2Fgvivewar%2FVoter%3FVid%3D123456
|
|
13
|
+
# The url encoding must be converted to lowercase
|
|
14
|
+
# @param [String] url
|
|
15
|
+
# @param [Hash] params
|
|
16
|
+
# @param [String] method
|
|
17
|
+
def request_concat(url, params={}, method="GET")
|
|
18
|
+
url_build = CGI.escape("#{url}?#{URI.encode_www_form(params)}").downcase
|
|
19
|
+
"#{method.upcase}#{url_build}"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# GVIVE docs states the digest signature as DIGEST = HMAC-SHA256(REQCONCAT, API KEY)
|
|
23
|
+
# The digest result should also be encodeded in Base64 format
|
|
24
|
+
# @param [String] api_key
|
|
25
|
+
# @param [String] request_concat
|
|
26
|
+
# @return [Base64]
|
|
27
|
+
def hmac_digest(api_key, request_concat)
|
|
28
|
+
Base64.strict_encode64(OpenSSL::HMAC.digest('sha256', api_key, request_concat))
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Base64 encoding of USERNAME:HMAC-DIGEST
|
|
32
|
+
# @param [String] username
|
|
33
|
+
# @param [String] hmac_digest
|
|
34
|
+
# @return [Base64]
|
|
35
|
+
def auth_token(username, hmac_digest)
|
|
36
|
+
Base64.strict_encode64("#{username}:#{hmac_digest}")
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module GVIVE
|
|
2
|
+
class Identities
|
|
3
|
+
include GVIVE::Utils
|
|
4
|
+
|
|
5
|
+
attr_accessor :data, :response
|
|
6
|
+
|
|
7
|
+
# Implement this method in subclass
|
|
8
|
+
# Validate Identity with GVIVE Web Service
|
|
9
|
+
# Assign OpenStruct Object via @response.to_o call
|
|
10
|
+
# - to @data variable if request was sucessful
|
|
11
|
+
# @return [Boolean]
|
|
12
|
+
def valid?; end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
require_relative 'identity/driver'
|
|
17
|
+
require_relative 'identity/passport'
|
|
18
|
+
require_relative 'identity/voter'
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module GVIVE
|
|
2
|
+
module Identity
|
|
3
|
+
class Driver < GVIVE::Identities
|
|
4
|
+
attr_accessor :coc, :fullname
|
|
5
|
+
|
|
6
|
+
# Certificate of Competence required
|
|
7
|
+
# Fullname of card holder as it appears on the card
|
|
8
|
+
# @param [String] coc
|
|
9
|
+
# @param [String] fullname
|
|
10
|
+
def initialize(coc, fullname)
|
|
11
|
+
@coc = coc
|
|
12
|
+
@fullname = fullname
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Implementing valid? method signature as described in Identity Class
|
|
16
|
+
def valid?
|
|
17
|
+
@response = gvive_request(driver_endpoint, { coc: @coc, fname: @fullname })
|
|
18
|
+
@data = @response.to_o
|
|
19
|
+
@response.success?
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module GVIVE
|
|
2
|
+
module Identity
|
|
3
|
+
class Passport < GVIVE::Identities
|
|
4
|
+
attr_accessor :passport_id
|
|
5
|
+
|
|
6
|
+
# Passport ID number required
|
|
7
|
+
# @param [String] passport_id
|
|
8
|
+
def initialize(passport_id)
|
|
9
|
+
@passport_id = passport_id
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# Implementing valid? method signature as described in Identity Class
|
|
13
|
+
def valid?
|
|
14
|
+
@response = gvive_request(passport_endpoint, { pid: @passport_id })
|
|
15
|
+
@data = @response.to_o
|
|
16
|
+
@response.success?
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module GVIVE
|
|
2
|
+
module Identity
|
|
3
|
+
class Voter < GVIVE::Identities
|
|
4
|
+
attr_accessor :voter_id
|
|
5
|
+
|
|
6
|
+
# Voter ID number required
|
|
7
|
+
# @param [String] voter_id
|
|
8
|
+
def initialize(voter_id)
|
|
9
|
+
@voter_id = voter_id
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# Implementing valid? method signature as described in Identity Class
|
|
13
|
+
def valid?
|
|
14
|
+
@response = gvive_request(voter_endpoint, { vid: @voter_id })
|
|
15
|
+
@data = @response.to_o
|
|
16
|
+
@response.success?
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
require 'ostruct'
|
|
3
|
+
|
|
4
|
+
module GVIVE
|
|
5
|
+
class Response
|
|
6
|
+
attr_accessor :http_response, :cache
|
|
7
|
+
|
|
8
|
+
# Requires an HTTP::Response Object
|
|
9
|
+
# which is a dependency from the http gem Response Class
|
|
10
|
+
# @param [HTTP::Response] http_response
|
|
11
|
+
def initialize(http_response)
|
|
12
|
+
@http_response = http_response
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Convert response data to plain Ruby Objects
|
|
16
|
+
# @return [OpenStruct]
|
|
17
|
+
def to_o
|
|
18
|
+
@cache = JSON.parse @http_response.body.to_s, object_class: OpenStruct
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# GVIVE returned valid response
|
|
22
|
+
# Check the raw HTTP Response for success
|
|
23
|
+
# Check also for GVIVE ResponseCode Key in the response body 200 for data found
|
|
24
|
+
# @return [Boolean]
|
|
25
|
+
def success?
|
|
26
|
+
@http_response.code == 200 && to_o.ResponseCode == "200"
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
data/lib/gvive/utils.rb
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
require 'http'
|
|
2
|
+
|
|
3
|
+
module GVIVE
|
|
4
|
+
module Utils
|
|
5
|
+
include GVIVE::Encoding
|
|
6
|
+
|
|
7
|
+
attr_accessor :status, :response_text, :transaction_id,
|
|
8
|
+
:uuid, :result, :response, :amount
|
|
9
|
+
|
|
10
|
+
# Voter ID Verification Endpoint
|
|
11
|
+
def voter_endpoint
|
|
12
|
+
endpoint GVIVE.configuration.voter_path
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Passport Verification Endpoint
|
|
16
|
+
def passport_endpoint
|
|
17
|
+
endpoint GVIVE.configuration.passport_path
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Driver's License Verification Endpoint
|
|
21
|
+
def driver_endpoint
|
|
22
|
+
endpoint GVIVE.configuration.driver_path
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# GVIVE HTTP Request
|
|
26
|
+
def gvive_request(url, params = {})
|
|
27
|
+
result = http_connect(url, params)
|
|
28
|
+
GVIVE::Response.new(result)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Append base_url to all paths
|
|
32
|
+
def endpoint(path = nil)
|
|
33
|
+
"#{GVIVE.configuration.base_url}#{path}"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# HTTP Connection with Digest as required by GVIVE
|
|
37
|
+
def http_connect(url, params = {})
|
|
38
|
+
request_concat_str = request_concat(url, params)
|
|
39
|
+
hmac_digest_str = hmac_digest(GVIVE.configuration.api_key, request_concat_str)
|
|
40
|
+
auth_token_str = auth_token(GVIVE.configuration.username, hmac_digest_str)
|
|
41
|
+
HTTP.auth("hmac #{auth_token_str}").get(url, params: params)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: gvive
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Alfred Rowe
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2017-09-28 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 1.16.a
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 1.16.a
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: simplecov
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: codeclimate-test-reporter
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: 1.0.0
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: 1.0.0
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: http
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '2.0'
|
|
90
|
+
type: :runtime
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '2.0'
|
|
97
|
+
description: Identity Theft Protection SDK for GVIVE Web Service
|
|
98
|
+
email:
|
|
99
|
+
- alfred@encodevlabs.com
|
|
100
|
+
executables: []
|
|
101
|
+
extensions: []
|
|
102
|
+
extra_rdoc_files: []
|
|
103
|
+
files:
|
|
104
|
+
- ".gitignore"
|
|
105
|
+
- ".rspec"
|
|
106
|
+
- ".travis.yml"
|
|
107
|
+
- CODE_OF_CONDUCT.md
|
|
108
|
+
- Gemfile
|
|
109
|
+
- Gemfile.lock
|
|
110
|
+
- LICENSE.txt
|
|
111
|
+
- README.md
|
|
112
|
+
- Rakefile
|
|
113
|
+
- bin/console
|
|
114
|
+
- bin/setup
|
|
115
|
+
- gvive.gemspec
|
|
116
|
+
- lib/gvive.rb
|
|
117
|
+
- lib/gvive/configuration.rb
|
|
118
|
+
- lib/gvive/encoding.rb
|
|
119
|
+
- lib/gvive/identities.rb
|
|
120
|
+
- lib/gvive/identity/driver.rb
|
|
121
|
+
- lib/gvive/identity/passport.rb
|
|
122
|
+
- lib/gvive/identity/voter.rb
|
|
123
|
+
- lib/gvive/response.rb
|
|
124
|
+
- lib/gvive/utils.rb
|
|
125
|
+
- lib/gvive/version.rb
|
|
126
|
+
homepage: https://github.com/nukturnal/gvive
|
|
127
|
+
licenses:
|
|
128
|
+
- MIT
|
|
129
|
+
metadata: {}
|
|
130
|
+
post_install_message:
|
|
131
|
+
rdoc_options: []
|
|
132
|
+
require_paths:
|
|
133
|
+
- lib
|
|
134
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - ">="
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: '0'
|
|
139
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
|
+
requirements:
|
|
141
|
+
- - ">="
|
|
142
|
+
- !ruby/object:Gem::Version
|
|
143
|
+
version: '0'
|
|
144
|
+
requirements: []
|
|
145
|
+
rubyforge_project:
|
|
146
|
+
rubygems_version: 2.6.13
|
|
147
|
+
signing_key:
|
|
148
|
+
specification_version: 4
|
|
149
|
+
summary: GVIVE Ruby SDK
|
|
150
|
+
test_files: []
|