idnow 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.rubocop.yml +43 -0
- data/.travis.yml +4 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +21 -0
- data/Makefile +2 -0
- data/README.md +142 -0
- data/circle.yml +7 -0
- data/docs/IDnow_API.pdf +0 -0
- data/examples/idnow_automated_testing.rb +35 -0
- data/examples/idnow_download_identification.rb +16 -0
- data/examples/idnow_get_identification.rb +16 -0
- data/examples/idnow_upload_download_default_document.rb +33 -0
- data/idnow-client.gemspec +30 -0
- data/lib/idnow.rb +68 -0
- data/lib/idnow/API/authentication.rb +13 -0
- data/lib/idnow/API/automated_testing.rb +19 -0
- data/lib/idnow/API/document_definitions.rb +29 -0
- data/lib/idnow/API/download_documents.rb +13 -0
- data/lib/idnow/API/request_identifications.rb +12 -0
- data/lib/idnow/API/retrieve_identifications.rb +36 -0
- data/lib/idnow/API/upload_documents.rb +23 -0
- data/lib/idnow/client.rb +60 -0
- data/lib/idnow/configuration.rb +25 -0
- data/lib/idnow/exception.rb +25 -0
- data/lib/idnow/get_request.rb +10 -0
- data/lib/idnow/helpers.rb +9 -0
- data/lib/idnow/http_client.rb +27 -0
- data/lib/idnow/json_response.rb +11 -0
- data/lib/idnow/models/contact_data.rb +12 -0
- data/lib/idnow/models/document_definition.rb +15 -0
- data/lib/idnow/models/identification.rb +25 -0
- data/lib/idnow/models/identification_data.rb +60 -0
- data/lib/idnow/models/identification_document.rb +34 -0
- data/lib/idnow/models/identification_process.rb +29 -0
- data/lib/idnow/models/identification_request.rb +16 -0
- data/lib/idnow/models/login.rb +9 -0
- data/lib/idnow/models/login_data.rb +13 -0
- data/lib/idnow/models/user_data.rb +39 -0
- data/lib/idnow/modules/jsonable.rb +28 -0
- data/lib/idnow/post_binary_request.rb +11 -0
- data/lib/idnow/post_json_request.rb +12 -0
- data/lib/idnow/raw_response.rb +31 -0
- data/lib/idnow/sftp_client.rb +24 -0
- metadata +187 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 68e89c9d1b1a11908376b9492588a24195deb333
|
4
|
+
data.tar.gz: 024274414183613e12b8dc8c2400085f5be24fc3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f8337596ceff9678d48c84599e5f2425e8ae6d708f5d41b0bf50ff0fa7652087656d4bdcf9e0c1c64146c54b2a1e2d323e3663f92d61dff7f4b8dc71cfb6e340
|
7
|
+
data.tar.gz: d138e5b6fe4600e56af9bc8667b6b19735e8b881149109ccddedc671b67d19695f2c2d7622a18c8b90d6227a38be9cc7cf5512b8c919611a3ad9856a7344ba43
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
AllCops:
|
2
|
+
DisplayCopNames: true
|
3
|
+
TargetRubyVersion: 2.2
|
4
|
+
|
5
|
+
# This configuration was generated by
|
6
|
+
# `rubocop --auto-gen-config`
|
7
|
+
# on 2016-01-27 19:56:34 +0100 using RuboCop version 0.36.0.
|
8
|
+
# The point is for the user to remove these configuration records
|
9
|
+
# one by one as the offenses are removed from the code base.
|
10
|
+
# Note that changes in the inspected code, or installation of new
|
11
|
+
# versions of RuboCop, may require this file to be generated again.
|
12
|
+
|
13
|
+
# Offense count: 8
|
14
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
|
15
|
+
# URISchemes: http, https
|
16
|
+
Metrics/LineLength:
|
17
|
+
Max: 140
|
18
|
+
|
19
|
+
Metrics/MethodLength:
|
20
|
+
Max: 31
|
21
|
+
|
22
|
+
Metrics/AbcSize:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
# Offense count: 2
|
26
|
+
# Cop supports --auto-correct.
|
27
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
28
|
+
# SupportedStyles: braces, no_braces, context_dependent
|
29
|
+
Style/BracesAroundHashParameters:
|
30
|
+
Enabled: false
|
31
|
+
|
32
|
+
# Offense count: 7
|
33
|
+
Style/Documentation:
|
34
|
+
Enabled: false
|
35
|
+
|
36
|
+
Style/GuardClause:
|
37
|
+
Enabled: false
|
38
|
+
|
39
|
+
# Offense count: 1
|
40
|
+
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts.
|
41
|
+
Style/FileName:
|
42
|
+
Exclude:
|
43
|
+
- 'lib/solaris/oauth2-error_monkey-patch.rb'
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Dominic Breuker
|
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/Makefile
ADDED
data/README.md
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
# Idnow Client
|
2
|
+
Library to consume the [IDnow API](http://www.idnow.eu/developers) in Ruby.
|
3
|
+
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'idnow'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install idnow
|
20
|
+
|
21
|
+
|
22
|
+
## Configuration
|
23
|
+
|
24
|
+
The Idnow client takes three settings:
|
25
|
+
|
26
|
+
* **env**
|
27
|
+
|
28
|
+
- can be set to `:live` or `:test`. Following the IDnow API documentation, each of these environments will correspondingly set the host to:
|
29
|
+
|
30
|
+
- Live server `gateway.idnow.de`
|
31
|
+
- Test server `gateway.test.idnow.de`
|
32
|
+
|
33
|
+
* **company_id**
|
34
|
+
* **api_key**
|
35
|
+
|
36
|
+
You have the option of using a global singleton client:
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
Idnow.env = :test
|
40
|
+
Idnow.company_id = "mycompany"
|
41
|
+
Idnow.api_key = "1234api_key"
|
42
|
+
```
|
43
|
+
|
44
|
+
Or many clients can be initialized with:
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
client = Idnow::Client.new(env: @env, company_id: @company_id, api_key: @api_key)
|
48
|
+
```
|
49
|
+
|
50
|
+
## API Summary
|
51
|
+
Please read the official IDnow documentation for details. Some examples can also be found at the examples folder.
|
52
|
+
|
53
|
+
####Identifications
|
54
|
+
```ruby
|
55
|
+
# Identification data, all fields are optional. If you want to use a testing robot instead of a real agent for the identification, write the robot name at the first_name, last_name or any custom field.
|
56
|
+
data = Idnow::IdentificationData.new({
|
57
|
+
birthday: '1984-07-20',
|
58
|
+
birthplace: 'Buxtehude',
|
59
|
+
birthname: 'Meier',
|
60
|
+
city: 'Berlin',
|
61
|
+
country: 'DE',
|
62
|
+
custom1: 'first custom parameter',
|
63
|
+
custom2: 'second custom parameter',
|
64
|
+
custom3: 'third custom parameter',
|
65
|
+
custom4: 'fourth custom parameter',
|
66
|
+
custom5: 'fifth custom parameter',
|
67
|
+
trackingid: 'track123',
|
68
|
+
email: 'petra.meier@example.com',
|
69
|
+
firstname: 'X-AUTOTEST-HAPPYPATH',
|
70
|
+
gender: 'FEMALE',
|
71
|
+
lastname: 'Meier',
|
72
|
+
nationality: 'DE',
|
73
|
+
street: 'Sesamstraße',
|
74
|
+
streetnumber: '34c',
|
75
|
+
title: 'Prof. Dr. Dr. hc',
|
76
|
+
zipcode: '10439'
|
77
|
+
})
|
78
|
+
|
79
|
+
# Request Identification
|
80
|
+
transaction_number = "A_TRANSACTION_NUMBER"
|
81
|
+
Idnow.client.request_identification(transaction_number: transaction_number, identification_data: data)
|
82
|
+
|
83
|
+
# Start testing robot - Only needed for automated robot testing
|
84
|
+
Idnow.client.testing_start(transaction_number: transaction_number)
|
85
|
+
|
86
|
+
# Testing video chat - Only needed for automated robot testing
|
87
|
+
Idnow.client.testing_request_video_chat(transaction_number: transaction_number)
|
88
|
+
|
89
|
+
# List successful identifications. When using automated robots, keep in mind that it might take a while until the identification is completed.
|
90
|
+
Idnow.client.login
|
91
|
+
Idnow.client.list_identifications
|
92
|
+
|
93
|
+
# List identifications by status pending or failed
|
94
|
+
Idnow.client.list_identifications(status: 'pending')
|
95
|
+
|
96
|
+
# Get identification. When using automated robots, keep in mind that it might take a while until the identification is completed.
|
97
|
+
Idnow.client.get_identification(transaction_number: transaction_number)
|
98
|
+
|
99
|
+
# Download identification files
|
100
|
+
Idnow.client.download_identification(transaction_number: transaction_number)
|
101
|
+
|
102
|
+
```
|
103
|
+
|
104
|
+
####Esigning
|
105
|
+
```ruby
|
106
|
+
# Create document definition
|
107
|
+
document_identifier = "doc_id"
|
108
|
+
document_data = {
|
109
|
+
"optional": true,
|
110
|
+
"name": 'SomeDoc',
|
111
|
+
"identifier": document_identifier,
|
112
|
+
"mimeType": 'txt',
|
113
|
+
"sortOrder": 1
|
114
|
+
}
|
115
|
+
|
116
|
+
Idnow.client.create_document_definition(document_data)
|
117
|
+
|
118
|
+
# List document definitions
|
119
|
+
Idnow.client.login
|
120
|
+
Idnow.client.list_document_definitions
|
121
|
+
# Or for cached results
|
122
|
+
Idnow.client.list_cached_document_definitions
|
123
|
+
|
124
|
+
# Upload document for a given identification
|
125
|
+
file_data = File.open('path/to/some/file.pdf', 'r')
|
126
|
+
Idnow.client.upload_identification_document(transaction_number, document_identifier, file_data)
|
127
|
+
|
128
|
+
# Upload default document
|
129
|
+
Idnow.client.upload_default_document(document_identifier, file_data)
|
130
|
+
|
131
|
+
# Download default document
|
132
|
+
Idnow.client.download_default_document(document_identifier)
|
133
|
+
```
|
134
|
+
|
135
|
+
|
136
|
+
## Development
|
137
|
+
|
138
|
+
RSpec is used for testing.
|
139
|
+
To enable code coverage check, set COV environment variable:
|
140
|
+
|
141
|
+
```COV=true bundle exec rspec```
|
142
|
+
|
data/circle.yml
ADDED
data/docs/IDnow_API.pdf
ADDED
Binary file
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'idnow'
|
2
|
+
|
3
|
+
fail 'please call with a transaction number' unless ARGV[0]
|
4
|
+
|
5
|
+
company_id = ENV.fetch('IDNOW_COMPANY_ID')
|
6
|
+
api_key = ENV.fetch('IDNOW_API_KEY')
|
7
|
+
|
8
|
+
transaction_number = ARGV[0]
|
9
|
+
|
10
|
+
Idnow.env = :test
|
11
|
+
Idnow.company_id = company_id
|
12
|
+
Idnow.api_key = api_key
|
13
|
+
|
14
|
+
data = Idnow::IdentificationData.new({
|
15
|
+
firstname: 'X-AUTOTEST-HAPPYPATH'
|
16
|
+
})
|
17
|
+
puts "\n\n"
|
18
|
+
|
19
|
+
puts "--- Request identification for #{transaction_number} ---"
|
20
|
+
identification = Idnow.client.request_identification(transaction_number: transaction_number, identification_data: data)
|
21
|
+
puts identification.inspect
|
22
|
+
|
23
|
+
puts "\n\n"
|
24
|
+
|
25
|
+
puts '--- Start testing robot ---'
|
26
|
+
testing_start = Idnow.client.testing_start(transaction_number: transaction_number)
|
27
|
+
puts testing_start.inspect
|
28
|
+
|
29
|
+
puts "\n\n"
|
30
|
+
|
31
|
+
puts '--- Testing video chat---'
|
32
|
+
Idnow.client.testing_request_video_chat(transaction_number: transaction_number)
|
33
|
+
|
34
|
+
puts 'It might take a while until the identification is marked as successfull,' \
|
35
|
+
' wait a little bit and then run idnow_get_identification.rb script'
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'idnow'
|
2
|
+
|
3
|
+
fail 'please call with a transaction number' unless ARGV[0]
|
4
|
+
|
5
|
+
company_id = ENV.fetch('IDNOW_COMPANY_ID')
|
6
|
+
api_key = ENV.fetch('IDNOW_API_KEY')
|
7
|
+
|
8
|
+
transaction_number = ARGV[0]
|
9
|
+
|
10
|
+
Idnow.env = :test
|
11
|
+
Idnow.company_id = company_id
|
12
|
+
Idnow.api_key = api_key
|
13
|
+
|
14
|
+
Idnow.client.login
|
15
|
+
puts 'Downloading ...'
|
16
|
+
Idnow.client.download_identification(transaction_number: transaction_number)
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'idnow'
|
2
|
+
|
3
|
+
fail 'please call with a transaction number' unless ARGV[0]
|
4
|
+
|
5
|
+
company_id = ENV.fetch('IDNOW_COMPANY_ID')
|
6
|
+
api_key = ENV.fetch('IDNOW_API_KEY')
|
7
|
+
|
8
|
+
transaction_number = ARGV[0]
|
9
|
+
|
10
|
+
Idnow.env = :test
|
11
|
+
Idnow.company_id = company_id
|
12
|
+
Idnow.api_key = api_key
|
13
|
+
|
14
|
+
Idnow.client.login
|
15
|
+
identification = Idnow.client.get_identification(transaction_number: transaction_number)
|
16
|
+
puts identification.inspect
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'idnow'
|
2
|
+
|
3
|
+
fail 'please call with a document identifier (must be unique)' unless ARGV[0]
|
4
|
+
|
5
|
+
company_id = ENV.fetch('IDNOW_COMPANY_ID')
|
6
|
+
api_key = ENV.fetch('IDNOW_API_KEY')
|
7
|
+
|
8
|
+
document_identifier = ARGV[0]
|
9
|
+
|
10
|
+
Idnow.env = :test
|
11
|
+
Idnow.company_id = company_id
|
12
|
+
Idnow.api_key = api_key
|
13
|
+
|
14
|
+
Idnow.client.login
|
15
|
+
|
16
|
+
# Please uncomment the lines below to also create a document definition
|
17
|
+
# document_data = {
|
18
|
+
# "optional": true,
|
19
|
+
# "name": 'SomeDoc',
|
20
|
+
# "identifier": document_identifier.to_s,
|
21
|
+
# "mimeType": 'txt',
|
22
|
+
# "sortOrder": 1
|
23
|
+
# }
|
24
|
+
|
25
|
+
# puts 'Creating document definition...'
|
26
|
+
# Idnow.client.create_document_definition(document_data)
|
27
|
+
|
28
|
+
puts 'Uploading default document...'
|
29
|
+
file = File.open('spec/support/test_files/example.txt', 'r')
|
30
|
+
Idnow.client.upload_default_document(document_identifier, file)
|
31
|
+
|
32
|
+
puts 'Downloading default document...'
|
33
|
+
Idnow.client.download_default_document(document_identifier)
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = 'idnow'
|
5
|
+
spec.version = '1.0.0'
|
6
|
+
spec.authors = ['Joan Martinez, Tobias Bielohlawek']
|
7
|
+
spec.email = ['joan.martinez.ripoll@gmail.com']
|
8
|
+
|
9
|
+
spec.summary = 'Ruby client for the IDnow API'
|
10
|
+
spec.description = 'Library to consume the IDnow API in Ruby, http://www.idnow.eu/developers'
|
11
|
+
|
12
|
+
fail 'RubyGems 2.0 or newer is required to protect against public gem pushes.' unless spec.respond_to?(:metadata)
|
13
|
+
|
14
|
+
spec.homepage = 'https://github.com/solarisBank/idnow-client'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = 'exe'
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_runtime_dependency 'net-sftp', '~>2.1'
|
23
|
+
|
24
|
+
spec.add_development_dependency 'rspec', '~> 3.3'
|
25
|
+
spec.add_development_dependency 'webmock', '~> 1.22'
|
26
|
+
spec.add_development_dependency 'simplecov', '~> 0.10'
|
27
|
+
spec.add_development_dependency 'rubocop', '~> 0.36.0'
|
28
|
+
spec.add_development_dependency 'factory_girl', '~> 4.5'
|
29
|
+
spec.add_development_dependency 'shoulda-matchers', '~>3.1'
|
30
|
+
end
|
data/lib/idnow.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'idnow/modules/jsonable'
|
2
|
+
require 'idnow/client'
|
3
|
+
|
4
|
+
require 'idnow/http_client'
|
5
|
+
require 'idnow/sftp_client'
|
6
|
+
require 'idnow/post_json_request'
|
7
|
+
require 'idnow/post_binary_request'
|
8
|
+
require 'idnow/get_request'
|
9
|
+
require 'idnow/raw_response'
|
10
|
+
require 'idnow/json_response'
|
11
|
+
require 'idnow/exception'
|
12
|
+
|
13
|
+
require 'idnow/models/login'
|
14
|
+
require 'idnow/models/identification_request'
|
15
|
+
require 'idnow/models/identification'
|
16
|
+
require 'idnow/models/identification_process'
|
17
|
+
|
18
|
+
require 'idnow/models/user_data'
|
19
|
+
require 'idnow/models/contact_data'
|
20
|
+
require 'idnow/models/identification_data'
|
21
|
+
require 'idnow/models/identification_document'
|
22
|
+
require 'idnow/models/login_data'
|
23
|
+
require 'idnow/models/document_definition'
|
24
|
+
|
25
|
+
module Idnow
|
26
|
+
module Host # Used to request an identification through the idnow API
|
27
|
+
TEST_SERVER = 'https://gateway.test.idnow.de'.freeze
|
28
|
+
LIVE_SERVER = 'https://gateway.idnow.de'.freeze
|
29
|
+
end
|
30
|
+
|
31
|
+
module TargetHost # Used for redirecting the user to the identification process
|
32
|
+
TEST_SERVER = 'https://go.test.idnow.de'.freeze
|
33
|
+
LIVE_SERVER = 'https://go.idnow.de'.freeze
|
34
|
+
end
|
35
|
+
|
36
|
+
ENVIRONMENTS = {
|
37
|
+
test: {
|
38
|
+
host: Host::TEST_SERVER,
|
39
|
+
target_host: TargetHost::TEST_SERVER
|
40
|
+
},
|
41
|
+
live: {
|
42
|
+
host: Host::LIVE_SERVER,
|
43
|
+
target_host: TargetHost::LIVE_SERVER
|
44
|
+
}
|
45
|
+
}.freeze
|
46
|
+
|
47
|
+
def env=(env)
|
48
|
+
fail ArgumentError, 'Please provide a valid enviroment, :test or :live' unless ENVIRONMENTS.keys.include?(env)
|
49
|
+
@client = nil
|
50
|
+
@env = env
|
51
|
+
end
|
52
|
+
|
53
|
+
def company_id=(company_id)
|
54
|
+
@client = nil
|
55
|
+
@company_id = company_id
|
56
|
+
end
|
57
|
+
|
58
|
+
def api_key=(api_key)
|
59
|
+
@client = nil
|
60
|
+
@api_key = api_key
|
61
|
+
end
|
62
|
+
|
63
|
+
def client
|
64
|
+
@client ||= Idnow::Client.new(env: @env, company_id: @company_id, api_key: @api_key)
|
65
|
+
end
|
66
|
+
|
67
|
+
module_function :env=, :company_id=, :api_key=, :client
|
68
|
+
end
|