idnow 1.3.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -1
- data/.travis.yml +1 -2
- data/Dockerfile +13 -0
- data/Gemfile +2 -0
- data/README.md +42 -12
- data/circle.yml +1 -1
- data/examples/idnow_automated_testing.rb +3 -1
- data/examples/idnow_download_identification.rb +3 -1
- data/examples/idnow_get_identification.rb +3 -1
- data/examples/idnow_upload_download_default_document.rb +3 -1
- data/idnow-client.gemspec +10 -8
- data/lib/idnow.rb +20 -8
- data/lib/idnow/API/authentication.rb +2 -0
- data/lib/idnow/API/automated_testing.rb +2 -1
- data/lib/idnow/API/document_definitions.rb +6 -4
- data/lib/idnow/API/download_documents.rb +3 -1
- data/lib/idnow/API/request_identifications.rb +2 -0
- data/lib/idnow/API/retrieve_identifications.rb +6 -4
- data/lib/idnow/API/upload_documents.rb +3 -1
- data/lib/idnow/client.rb +13 -9
- data/lib/idnow/configuration.rb +3 -2
- data/lib/idnow/exception.rb +2 -0
- data/lib/idnow/get_request.rb +2 -0
- data/lib/idnow/helpers.rb +2 -0
- data/lib/idnow/http_client.rb +3 -1
- data/lib/idnow/json_response.rb +3 -1
- data/lib/idnow/models/contact_data.rb +2 -0
- data/lib/idnow/models/document_definition.rb +2 -0
- data/lib/idnow/models/identification.rb +2 -0
- data/lib/idnow/models/identification_data.rb +15 -11
- data/lib/idnow/models/identification_document.rb +11 -18
- data/lib/idnow/models/identification_process.rb +3 -1
- data/lib/idnow/models/identification_request.rb +2 -0
- data/lib/idnow/models/login.rb +2 -0
- data/lib/idnow/models/login_data.rb +2 -0
- data/lib/idnow/models/user_data.rb +2 -0
- data/lib/idnow/modules/jsonable.rb +2 -0
- data/lib/idnow/post_binary_request.rb +2 -0
- data/lib/idnow/post_json_request.rb +2 -0
- data/lib/idnow/raw_response.rb +4 -2
- data/lib/idnow/sftp_client.rb +8 -3
- metadata +25 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71c54deac5050e48ce75bb19ff81ab76ca827055
|
4
|
+
data.tar.gz: 5e47156913a5f7127277cb5c6ef5a1e343ecad15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 303055651e8474d3f2d42f76c331f11ba45c8ca85eff341fa9b3b2fb05c5dbe31e581b854bf3fb84f9e481eea682420f82b024cc317251dc6c194703a986f4ed
|
7
|
+
data.tar.gz: 6de474e0a88f7e24adf051327bbd14438ae93352a0304aa3660af81f79cdddb487d8d5eec051b418fdb18bd3358af543fe925d0cc4c6668b508b099681778fd8
|
data/.rubocop.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
AllCops:
|
2
2
|
DisplayCopNames: true
|
3
|
-
TargetRubyVersion: 2.
|
3
|
+
TargetRubyVersion: 2.3
|
4
4
|
|
5
5
|
# This configuration was generated by
|
6
6
|
# `rubocop --auto-gen-config`
|
@@ -19,6 +19,9 @@ Metrics/LineLength:
|
|
19
19
|
Metrics/MethodLength:
|
20
20
|
Max: 31
|
21
21
|
|
22
|
+
Metrics/BlockLength:
|
23
|
+
Max: 190
|
24
|
+
|
22
25
|
Metrics/AbcSize:
|
23
26
|
Enabled: false
|
24
27
|
|
data/.travis.yml
CHANGED
data/Dockerfile
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Idnow Client
|
2
|
-
Library to consume the [IDnow API](http://www.idnow.eu/developers) in Ruby.
|
3
2
|
|
3
|
+
Library to consume the [IDnow API](http://www.idnow.eu/developers) in Ruby.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -18,7 +18,6 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
$ gem install idnow
|
20
20
|
|
21
|
-
|
22
21
|
## Configuration
|
23
22
|
|
24
23
|
The Idnow client takes three settings:
|
@@ -32,6 +31,7 @@ The Idnow client takes three settings:
|
|
32
31
|
|
33
32
|
* **company_id**
|
34
33
|
* **api_key**
|
34
|
+
* **custom_environments** (optional)
|
35
35
|
|
36
36
|
You have the option of using a global singleton client:
|
37
37
|
|
@@ -39,6 +39,18 @@ You have the option of using a global singleton client:
|
|
39
39
|
Idnow.env = :test
|
40
40
|
Idnow.company_id = "mycompany"
|
41
41
|
Idnow.api_key = "1234api_key"
|
42
|
+
|
43
|
+
# optional
|
44
|
+
Idnow.custom_environments = {
|
45
|
+
test: {
|
46
|
+
host: 'https://gateway.test.idnow.example.com',
|
47
|
+
target_host: 'https://go.test.idnow.example.com'
|
48
|
+
},
|
49
|
+
live: {
|
50
|
+
host: 'https://gateway.idnow.example.com',
|
51
|
+
target_host: 'https://go.idnow.example.com'
|
52
|
+
}
|
53
|
+
}
|
42
54
|
```
|
43
55
|
|
44
56
|
Or many clients can be initialized with:
|
@@ -48,11 +60,15 @@ client = Idnow::Client.new(env: @env, company_id: @company_id, api_key: @api_key
|
|
48
60
|
```
|
49
61
|
|
50
62
|
## API Summary
|
51
|
-
Please read the official IDnow documentation for details. Some examples can also be found at the examples folder.
|
52
63
|
|
53
|
-
|
64
|
+
Please read the official IDnow documentation for details. Some examples can also be found in the examples folder.
|
65
|
+
|
66
|
+
#### Identifications
|
67
|
+
|
54
68
|
```ruby
|
55
|
-
# Identification data, all fields are optional.
|
69
|
+
# Identification data, all fields are optional.
|
70
|
+
# If you want to use a testing robot instead of a real agent for the identification,
|
71
|
+
# write the robot name at the first_name, last_name or any custom field.
|
56
72
|
data = Idnow::IdentificationData.new({
|
57
73
|
birthday: '1984-07-20',
|
58
74
|
birthplace: 'Buxtehude',
|
@@ -86,22 +102,24 @@ Idnow.client.testing_start(transaction_number: transaction_number)
|
|
86
102
|
# Testing video chat - Only needed for automated robot testing
|
87
103
|
Idnow.client.testing_request_video_chat(transaction_number: transaction_number)
|
88
104
|
|
89
|
-
# List successful identifications.
|
105
|
+
# List successful identifications. When using automated robots,
|
106
|
+
# keep in mind that it might take a while until the identification is completed.
|
90
107
|
Idnow.client.login
|
91
108
|
Idnow.client.list_identifications
|
92
109
|
|
93
110
|
# List identifications by status pending or failed
|
94
111
|
Idnow.client.list_identifications(status: 'pending')
|
95
112
|
|
96
|
-
# Get identification. When using automated robots,
|
113
|
+
# Get identification. When using automated robots,
|
114
|
+
# keep in mind that it might take a while until the identification is completed.
|
97
115
|
Idnow.client.get_identification(transaction_number: transaction_number)
|
98
116
|
|
99
117
|
# Download identification files
|
100
118
|
Idnow.client.download_identification(transaction_number: transaction_number)
|
101
|
-
|
102
119
|
```
|
103
120
|
|
104
|
-
####Esigning
|
121
|
+
#### Esigning
|
122
|
+
|
105
123
|
```ruby
|
106
124
|
# Create document definition
|
107
125
|
document_identifier = "doc_id"
|
@@ -132,11 +150,23 @@ Idnow.client.upload_default_document(document_identifier, file_data)
|
|
132
150
|
Idnow.client.download_default_document(document_identifier)
|
133
151
|
```
|
134
152
|
|
135
|
-
|
136
|
-
## Development
|
153
|
+
## Development & testing
|
137
154
|
|
138
155
|
RSpec is used for testing.
|
156
|
+
|
157
|
+
### Coverage report
|
158
|
+
|
139
159
|
To enable code coverage check, set COV environment variable:
|
140
160
|
|
141
|
-
```
|
161
|
+
```sh
|
162
|
+
COV=true make test
|
163
|
+
```
|
164
|
+
|
165
|
+
### Testing with docker
|
142
166
|
|
167
|
+
To run the tests through docker, you can use the included `Dockerfile`:
|
168
|
+
|
169
|
+
```sh
|
170
|
+
docker build . -t idnow-client
|
171
|
+
docker run -it idnow-client:latest make test
|
172
|
+
```
|
data/circle.yml
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'idnow'
|
2
4
|
|
3
|
-
|
5
|
+
raise 'please call with a document identifier (must be unique)' unless ARGV[0]
|
4
6
|
|
5
7
|
company_id = ENV.fetch('IDNOW_COMPANY_ID')
|
6
8
|
api_key = ENV.fetch('IDNOW_API_KEY')
|
data/idnow-client.gemspec
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = 'idnow'
|
5
|
-
spec.version = '1.
|
5
|
+
spec.version = '2.1.1'
|
6
6
|
spec.authors = ['Joan Martinez, Tobias Bielohlawek']
|
7
|
-
spec.email = ['joan.martinez
|
7
|
+
spec.email = ['joan.martinez@solarisbank.de']
|
8
8
|
|
9
9
|
spec.summary = 'Ruby client for the IDnow API'
|
10
10
|
spec.description = 'Library to consume the IDnow API in Ruby, http://www.idnow.eu/developers'
|
11
11
|
|
12
|
-
|
12
|
+
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.' unless spec.respond_to?(:metadata)
|
13
13
|
|
14
14
|
spec.homepage = 'https://github.com/solarisBank/idnow-client'
|
15
15
|
spec.license = 'MIT'
|
@@ -21,10 +21,12 @@ Gem::Specification.new do |spec|
|
|
21
21
|
|
22
22
|
spec.add_runtime_dependency 'net-sftp', '~>2.1'
|
23
23
|
|
24
|
+
spec.required_ruby_version = '~> 2.3'
|
25
|
+
|
26
|
+
spec.add_development_dependency 'factory_bot', '~> 4.5'
|
24
27
|
spec.add_development_dependency 'rspec', '~> 3.3'
|
25
|
-
spec.add_development_dependency '
|
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'
|
28
|
+
spec.add_development_dependency 'rubocop', '~> 0.54.0'
|
29
29
|
spec.add_development_dependency 'shoulda-matchers', '~>3.1'
|
30
|
+
spec.add_development_dependency 'simplecov', '~> 0.10'
|
31
|
+
spec.add_development_dependency 'webmock', '~> 1.22'
|
30
32
|
end
|
data/lib/idnow.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'idnow/modules/jsonable'
|
3
4
|
require 'idnow/client'
|
4
5
|
|
@@ -24,14 +25,16 @@ require 'idnow/models/login_data'
|
|
24
25
|
require 'idnow/models/document_definition'
|
25
26
|
|
26
27
|
module Idnow
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
# Used to request an identification through the idnow API
|
29
|
+
module Host
|
30
|
+
TEST_SERVER = 'https://gateway.test.idnow.de'
|
31
|
+
LIVE_SERVER = 'https://gateway.idnow.de'
|
30
32
|
end
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
-
|
34
|
+
# Used for redirecting the user to the identification process
|
35
|
+
module TargetHost
|
36
|
+
TEST_SERVER = 'https://go.test.idnow.de'
|
37
|
+
LIVE_SERVER = 'https://go.idnow.de'
|
35
38
|
end
|
36
39
|
|
37
40
|
ENVIRONMENTS = {
|
@@ -46,7 +49,7 @@ module Idnow
|
|
46
49
|
}.freeze
|
47
50
|
|
48
51
|
def env=(env)
|
49
|
-
|
52
|
+
raise ArgumentError, 'Please provide a valid enviroment, :test or :live' unless ENVIRONMENTS.keys.include?(env)
|
50
53
|
@client = nil
|
51
54
|
@env = env
|
52
55
|
end
|
@@ -61,9 +64,18 @@ module Idnow
|
|
61
64
|
@api_key = api_key
|
62
65
|
end
|
63
66
|
|
67
|
+
def custom_environments=(custom_environments)
|
68
|
+
@client = nil
|
69
|
+
@custom_environments = custom_environments
|
70
|
+
end
|
71
|
+
|
72
|
+
def endpoint(env, host)
|
73
|
+
(@custom_environments || {}).dig(env, host) || Idnow::ENVIRONMENTS[env][host]
|
74
|
+
end
|
75
|
+
|
64
76
|
def client
|
65
77
|
@client ||= Idnow::Client.new(env: @env, company_id: @company_id, api_key: @api_key)
|
66
78
|
end
|
67
79
|
|
68
|
-
module_function :env=, :company_id=, :api_key=, :client
|
80
|
+
module_function :env=, :company_id=, :api_key=, :custom_environments=, :endpoint, :client
|
69
81
|
end
|
@@ -1,8 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Idnow
|
3
4
|
module API
|
4
5
|
module AutomatedTesting
|
5
|
-
HOST = 'https://api.test.idnow.de'
|
6
|
+
HOST = 'https://api.test.idnow.de'
|
6
7
|
|
7
8
|
def testing_start(transaction_number:)
|
8
9
|
path = full_path_for("identifications/#{transaction_number}/start")
|
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Idnow
|
2
4
|
module API
|
3
5
|
module DocumentDefinitions
|
4
6
|
def create_document_definition(document_data)
|
5
|
-
|
7
|
+
raise Idnow::AuthenticationException if @auth_token.nil?
|
6
8
|
|
7
9
|
path = full_path_for('documentdefinitions')
|
8
10
|
request = Idnow::PostJsonRequest.new(path, document_data)
|
@@ -10,7 +12,7 @@ module Idnow
|
|
10
12
|
end
|
11
13
|
|
12
14
|
def list_document_definitions
|
13
|
-
|
15
|
+
raise Idnow::AuthenticationException if @auth_token.nil?
|
14
16
|
|
15
17
|
path = full_path_for('documentdefinitions')
|
16
18
|
request = Idnow::GetRequest.new(path)
|
@@ -21,8 +23,8 @@ module Idnow
|
|
21
23
|
end
|
22
24
|
|
23
25
|
def list_cached_document_definitions(refresh = false)
|
24
|
-
return @
|
25
|
-
@
|
26
|
+
return @list_cached_document_definitions = list_document_definitions if refresh
|
27
|
+
@list_cached_document_definitions ||= list_document_definitions
|
26
28
|
end
|
27
29
|
end
|
28
30
|
end
|
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Idnow
|
2
4
|
module API
|
3
5
|
module DownloadDocuments
|
4
6
|
def download_default_document(document_definition_identifier)
|
5
|
-
|
7
|
+
raise Idnow::AuthenticationException if @auth_token.nil?
|
6
8
|
|
7
9
|
path = full_path_for("documentdefinitions/#{document_definition_identifier}/data")
|
8
10
|
request = Idnow::GetRequest.new(path, '')
|
@@ -1,13 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Idnow
|
2
4
|
module API
|
3
5
|
module RetrieveIdentifications
|
4
|
-
IDENTIFICATION_STATUSES = %w
|
6
|
+
IDENTIFICATION_STATUSES = %w[pending failed].freeze
|
5
7
|
|
6
8
|
def list_identifications(status: nil)
|
7
|
-
|
9
|
+
raise Idnow::AuthenticationException if @auth_token.nil?
|
8
10
|
|
9
11
|
unless status.nil? || IDENTIFICATION_STATUSES.include?(status)
|
10
|
-
|
12
|
+
raise Idnow::InvalidArguments, "Status #{status} not defined, possible options are: #{IDENTIFICATION_STATUSES.join(',')}"
|
11
13
|
end
|
12
14
|
partial_path = status.nil? ? 'identifications' : "identifications?#{status}=true"
|
13
15
|
path = full_path_for(partial_path)
|
@@ -19,7 +21,7 @@ module Idnow
|
|
19
21
|
end
|
20
22
|
|
21
23
|
def get_identification(transaction_number:)
|
22
|
-
|
24
|
+
raise Idnow::AuthenticationException if @auth_token.nil?
|
23
25
|
|
24
26
|
path = full_path_for("identifications/#{transaction_number}")
|
25
27
|
request = Idnow::GetRequest.new(path)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Idnow
|
2
4
|
module API
|
3
5
|
module UploadDocuments
|
@@ -14,7 +16,7 @@ module Idnow
|
|
14
16
|
private
|
15
17
|
|
16
18
|
def upload_document(file_data, request_path)
|
17
|
-
|
19
|
+
raise Idnow::AuthenticationException if @auth_token.nil?
|
18
20
|
request = Idnow::PostBinaryRequest.new(request_path, file_data)
|
19
21
|
execute(request, 'X-API-LOGIN-TOKEN' => @auth_token)
|
20
22
|
end
|
data/lib/idnow/client.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'idnow/API/authentication'
|
3
4
|
require 'idnow/API/automated_testing' # shouldn't be included by default
|
4
5
|
require 'idnow/API/request_identifications'
|
@@ -17,21 +18,24 @@ module Idnow
|
|
17
18
|
include Idnow::API::UploadDocuments
|
18
19
|
include Idnow::API::DownloadDocuments
|
19
20
|
|
20
|
-
API_VERSION = 'v1'
|
21
|
+
API_VERSION = 'v1'
|
21
22
|
|
22
23
|
attr_reader :host
|
23
24
|
|
24
|
-
def initialize(env:, company_id:, api_key:)
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
@host = Idnow
|
29
|
-
@target_host = Idnow
|
25
|
+
def initialize(env:, company_id:, api_key:, timeout: nil)
|
26
|
+
raise 'Please set env to :test or :live' unless Idnow::ENVIRONMENTS.keys.include?(env)
|
27
|
+
raise 'Please set your company_id' if company_id.nil?
|
28
|
+
raise 'Please set your api_key' if api_key.nil?
|
29
|
+
@host = Idnow.endpoint(env, :host)
|
30
|
+
@target_host = Idnow.endpoint(env, :target_host)
|
30
31
|
@company_id = company_id
|
31
32
|
@api_key = api_key
|
32
33
|
|
33
34
|
@http_client = HttpClient.new(host: @host)
|
34
|
-
|
35
|
+
|
36
|
+
sftp_client_options = { host: @host, username: @company_id, password: @api_key }
|
37
|
+
sftp_client_options[:timeout] = timeout if timeout
|
38
|
+
@sftp_client = SftpClient.new(sftp_client_options)
|
35
39
|
end
|
36
40
|
|
37
41
|
private
|
@@ -46,7 +50,7 @@ module Idnow
|
|
46
50
|
end
|
47
51
|
|
48
52
|
response.tap do |r|
|
49
|
-
|
53
|
+
raise Idnow::ResponseException, r.errors if r.errors?
|
50
54
|
end
|
51
55
|
end
|
52
56
|
|
data/lib/idnow/configuration.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Idnow
|
3
4
|
class Configuration
|
4
5
|
# TODO: This class is not being used right now, but its aim is to be able for the developers
|
@@ -15,8 +16,8 @@ module Idnow
|
|
15
16
|
|
16
17
|
module Idnow
|
17
18
|
module Host
|
18
|
-
TEST = 'https://gateway.test.idnow.de'
|
19
|
-
PRODUCTION = 'https://gateway.idnow.de'
|
19
|
+
TEST = 'https://gateway.test.idnow.de'
|
20
|
+
PRODUCTION = 'https://gateway.idnow.de'
|
20
21
|
end
|
21
22
|
end
|
22
23
|
attr_accessor :host
|
data/lib/idnow/exception.rb
CHANGED
data/lib/idnow/get_request.rb
CHANGED
data/lib/idnow/helpers.rb
CHANGED
data/lib/idnow/http_client.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Idnow
|
2
4
|
class HttpClient
|
3
5
|
def initialize(host:, read_timout_sec: 30)
|
@@ -21,7 +23,7 @@ module Idnow
|
|
21
23
|
def client
|
22
24
|
Net::HTTP.new(@uri.host, @uri.port).tap do |http|
|
23
25
|
http.read_timeout = @read_timeout
|
24
|
-
http.use_ssl =
|
26
|
+
http.use_ssl = @uri.scheme == 'https'
|
25
27
|
end
|
26
28
|
end
|
27
29
|
end
|
data/lib/idnow/json_response.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Idnow
|
2
4
|
class JsonResponse < RawResponse
|
3
5
|
attr_reader :data
|
4
6
|
|
5
7
|
def initialize(raw_response)
|
6
8
|
super
|
7
|
-
raw_response =
|
9
|
+
raw_response = raw_response == '' ? '{}' : raw_response
|
8
10
|
@data = JSON.parse(raw_response)
|
9
11
|
end
|
10
12
|
end
|
@@ -1,20 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'json'
|
3
4
|
|
4
5
|
module Idnow
|
5
6
|
class IdentificationData
|
6
7
|
module Gender
|
7
|
-
MALE = 'MALE'
|
8
|
-
FEMALE = 'FEMALE'
|
8
|
+
MALE = 'MALE'
|
9
|
+
FEMALE = 'FEMALE'
|
9
10
|
end
|
10
11
|
|
11
|
-
attr_accessor :birthplace, :birthname, :city, :
|
12
|
-
:custom2, :custom3, :custom4, :custom5, :trackingid, :email, :firstname,
|
13
|
-
:lastname, :mobilephone, :nationality, :street, :streetnumber, :title, :zipcode
|
12
|
+
attr_accessor :birthplace, :birthname, :city, :custom1,
|
13
|
+
:custom2, :custom3, :custom4, :custom5, :trackingid, :email, :firstname,
|
14
|
+
:lastname, :mobilephone, :nationality, :street, :streetnumber, :title, :zipcode,
|
15
|
+
:preferredLang
|
16
|
+
|
17
|
+
attr_reader :country, :gender
|
14
18
|
|
15
19
|
def initialize(params = {})
|
16
20
|
params.keys.each do |key|
|
17
|
-
|
21
|
+
raise ArgumentError, "Attribute #{key} is not supported!" unless respond_to?(key.to_sym)
|
18
22
|
|
19
23
|
send("#{key}=", params[key])
|
20
24
|
end
|
@@ -31,7 +35,7 @@ module Idnow
|
|
31
35
|
########### Getter / Setter ############
|
32
36
|
|
33
37
|
def birthday
|
34
|
-
@birthday
|
38
|
+
@birthday&.strftime('%Y-%m-%d')
|
35
39
|
end
|
36
40
|
|
37
41
|
def birthday=(birthday)
|
@@ -43,18 +47,18 @@ module Idnow
|
|
43
47
|
end
|
44
48
|
|
45
49
|
def country=(country)
|
46
|
-
|
50
|
+
raise ArgumentError, 'Country must be ISO 3166 two letter country code' unless country.instance_of?(String) && country.size == 2
|
47
51
|
|
48
52
|
@country = country.upcase
|
49
53
|
end
|
50
54
|
|
51
55
|
def gender=(gender)
|
52
|
-
if %w
|
56
|
+
if %w[M MALE].include?(gender.to_s.strip.upcase)
|
53
57
|
@gender = Gender::MALE
|
54
|
-
elsif %w
|
58
|
+
elsif %w[F FEMALE].include?(gender.to_s.strip.upcase)
|
55
59
|
@gender = Gender::FEMALE
|
56
60
|
else
|
57
|
-
|
61
|
+
raise ArgumentError, 'Provide valid value for gender: MALE or FEMALE'
|
58
62
|
end
|
59
63
|
end
|
60
64
|
end
|
@@ -1,15 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Idnow
|
2
4
|
class IdentificationDocument
|
3
5
|
include Idnow::Jsonable
|
4
6
|
|
5
|
-
attr_accessor :country, :number, :issued_by, :
|
7
|
+
attr_accessor :country, :number, :issued_by, :type
|
8
|
+
attr_writer :date_issued, :valid_until
|
9
|
+
|
6
10
|
def initialize(data)
|
7
|
-
@country
|
8
|
-
@number
|
9
|
-
@issued_by
|
10
|
-
@date_issued
|
11
|
-
@type
|
12
|
-
@valid_until
|
11
|
+
@country = data.dig('country', 'value')
|
12
|
+
@number = data.dig('number', 'value')
|
13
|
+
@issued_by = data.dig('issuedby', 'value')
|
14
|
+
@date_issued = data.dig('dateissued', 'value')
|
15
|
+
@type = data.dig('type', 'value')
|
16
|
+
@valid_until = data.dig('validuntil', 'value')
|
13
17
|
end
|
14
18
|
|
15
19
|
def date_issued
|
@@ -19,16 +23,5 @@ module Idnow
|
|
19
23
|
def valid_until
|
20
24
|
Date.parse(@valid_until) if @valid_until
|
21
25
|
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def dig_value(*keys, data)
|
26
|
-
# TODO: use ruby 2.3 and dig
|
27
|
-
result = data
|
28
|
-
keys.each do |key|
|
29
|
-
result = result.fetch(key, {})
|
30
|
-
end
|
31
|
-
result['value']
|
32
|
-
end
|
33
26
|
end
|
34
27
|
end
|
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Idnow
|
2
4
|
class IdentificationProcess
|
3
5
|
include Idnow::Jsonable
|
4
6
|
|
5
|
-
SUCCESSFUL_RESPONSES = %w
|
7
|
+
SUCCESSFUL_RESPONSES = %w[SUCCESS SUCCESS_DATA_CHANGED].freeze
|
6
8
|
attr_accessor :result, :reason, :company_id, :filename, :agentname, :identification_time, :id, :href, :type, :transaction_number
|
7
9
|
|
8
10
|
def initialize(data)
|
data/lib/idnow/models/login.rb
CHANGED
data/lib/idnow/raw_response.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Idnow
|
2
4
|
class RawResponse
|
3
5
|
attr_reader :raw
|
@@ -23,9 +25,9 @@ module Idnow
|
|
23
25
|
|
24
26
|
def valid_json?(json)
|
25
27
|
JSON.parse(json)
|
26
|
-
|
28
|
+
true
|
27
29
|
rescue JSON::ParserError
|
28
|
-
|
30
|
+
false
|
29
31
|
end
|
30
32
|
end
|
31
33
|
end
|
data/lib/idnow/sftp_client.rb
CHANGED
@@ -1,17 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'net/sftp'
|
2
4
|
|
3
5
|
module Idnow
|
4
6
|
class SftpClient
|
5
|
-
def initialize(host:, username:, password:)
|
7
|
+
def initialize(host:, username:, password:, timeout: nil)
|
6
8
|
@host = URI.parse(host).host
|
7
9
|
@username = username
|
8
10
|
@password = password
|
11
|
+
@timeout = timeout
|
9
12
|
end
|
10
13
|
|
11
14
|
def download(file_name)
|
12
15
|
data = nil
|
13
|
-
|
14
|
-
|
16
|
+
options = { password: @password }
|
17
|
+
options[:timeout] = @timeout if @timeout
|
18
|
+
Net::SFTP.start(@host, @username, options) do |sftp|
|
19
|
+
raise Idnow::Exception, "Invalid path. No identification file found under #{file_name}" unless file_exists(sftp, file_name)
|
15
20
|
begin
|
16
21
|
data = sftp.download!(file_name)
|
17
22
|
rescue Net::SFTP::Exception => e
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: idnow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joan Martinez, Tobias Bielohlawek
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-sftp
|
@@ -25,92 +25,92 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: factory_bot
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '4.5'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '4.5'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '3.3'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '3.3'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rubocop
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 0.54.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 0.54.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: shoulda-matchers
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: '3.1'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: '3.1'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: simplecov
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '0.10'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '0.10'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: webmock
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '1.22'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '1.22'
|
111
111
|
description: Library to consume the IDnow API in Ruby, http://www.idnow.eu/developers
|
112
112
|
email:
|
113
|
-
- joan.martinez
|
113
|
+
- joan.martinez@solarisbank.de
|
114
114
|
executables: []
|
115
115
|
extensions: []
|
116
116
|
extra_rdoc_files: []
|
@@ -120,6 +120,7 @@ files:
|
|
120
120
|
- ".rubocop.yml"
|
121
121
|
- ".travis.yml"
|
122
122
|
- CODE_OF_CONDUCT.md
|
123
|
+
- Dockerfile
|
123
124
|
- Gemfile
|
124
125
|
- LICENSE.txt
|
125
126
|
- Makefile
|
@@ -171,9 +172,9 @@ require_paths:
|
|
171
172
|
- lib
|
172
173
|
required_ruby_version: !ruby/object:Gem::Requirement
|
173
174
|
requirements:
|
174
|
-
- - "
|
175
|
+
- - "~>"
|
175
176
|
- !ruby/object:Gem::Version
|
176
|
-
version: '
|
177
|
+
version: '2.3'
|
177
178
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
178
179
|
requirements:
|
179
180
|
- - ">="
|
@@ -181,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
182
|
version: '0'
|
182
183
|
requirements: []
|
183
184
|
rubyforge_project:
|
184
|
-
rubygems_version: 2.6.
|
185
|
+
rubygems_version: 2.6.14
|
185
186
|
signing_key:
|
186
187
|
specification_version: 4
|
187
188
|
summary: Ruby client for the IDnow API
|