idnow 1.0.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/gem-push.yml +67 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +7 -14
- data/.travis.yml +4 -2
- data/CODE_OF_CONDUCT.md +13 -0
- data/Dockerfile +9 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +1 -1
- data/Makefile +12 -1
- data/README.md +57 -12
- 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 +12 -10
- data/lib/idnow.rb +28 -9
- data/lib/idnow/API/authentication.rb +2 -0
- data/lib/idnow/API/automated_testing.rb +5 -3
- data/lib/idnow/API/document_definitions.rb +10 -7
- data/lib/idnow/API/download_documents.rb +4 -2
- data/lib/idnow/API/request_identifications.rb +3 -1
- data/lib/idnow/API/retrieve_identifications.rb +9 -6
- data/lib/idnow/API/upload_documents.rb +5 -2
- data/lib/idnow/client.rb +14 -9
- data/lib/idnow/configuration.rb +5 -8
- data/lib/idnow/exception.rb +2 -0
- data/lib/idnow/get_request.rb +2 -0
- data/lib/idnow/helpers.rb +3 -1
- data/lib/idnow/http_client.rb +12 -9
- 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 +5 -2
- data/lib/idnow/models/identification_data.rb +20 -13
- data/lib/idnow/models/identification_document.rb +11 -18
- data/lib/idnow/models/identification_process.rb +4 -2
- data/lib/idnow/models/identification_request.rb +2 -0
- data/lib/idnow/models/login.rb +2 -0
- data/lib/idnow/models/login_data.rb +3 -1
- data/lib/idnow/models/user_data.rb +7 -0
- data/lib/idnow/modules/jsonable.rb +4 -1
- data/lib/idnow/post_binary_request.rb +2 -0
- data/lib/idnow/post_json_request.rb +2 -0
- data/lib/idnow/raw_response.rb +5 -3
- data/lib/idnow/sftp_client.rb +15 -3
- metadata +41 -37
- data/circle.yml +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3caa1be49888278cacbd44efe6daaccaca538b747312243f55c4b529f4b060da
|
4
|
+
data.tar.gz: 9fdd7352d6dc258acbc7c36e1697eee0865791146390c530bc75476933da6aec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3a64af1fd998df4db251c4ddf6d7b728e759024d4f9174fb3817c30c598234bcd0589f118d36fdf062ff86fad813dda5c1b825d0ae0f582cd3cb1acef7a5fb9
|
7
|
+
data.tar.gz: 9e355e9c36dbdab33c17b8715f9a36b11c3e985bc6370eada59ed034eb198d0d88f230003a668698bafc1567a6e648007f6f5b5e84f49ca06c0b0f621beb16b1
|
@@ -0,0 +1,67 @@
|
|
1
|
+
name: Ruby Gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
workflow_dispatch:
|
5
|
+
|
6
|
+
jobs:
|
7
|
+
build:
|
8
|
+
name: Build
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
permissions:
|
11
|
+
contents: read
|
12
|
+
packages: write
|
13
|
+
|
14
|
+
steps:
|
15
|
+
- uses: actions/checkout@v2
|
16
|
+
- name: Set up Ruby 2.5
|
17
|
+
uses: actions/setup-ruby@v1
|
18
|
+
with:
|
19
|
+
ruby-version: 2.5.x
|
20
|
+
|
21
|
+
- name: Build gem
|
22
|
+
run: |
|
23
|
+
gem build *.gemspec
|
24
|
+
- name: Upload gem
|
25
|
+
uses: actions/upload-artifact@v2
|
26
|
+
with:
|
27
|
+
name: idnow-client.gem
|
28
|
+
path: "*.gem"
|
29
|
+
|
30
|
+
publish:
|
31
|
+
name: Publish RubyGems
|
32
|
+
needs: build
|
33
|
+
runs-on: ubuntu-latest
|
34
|
+
steps:
|
35
|
+
- uses: actions/download-artifact@v2
|
36
|
+
with:
|
37
|
+
name: idnow-client.gem
|
38
|
+
- name: Set up Ruby 2.5
|
39
|
+
uses: actions/setup-ruby@v1
|
40
|
+
with:
|
41
|
+
ruby-version: 2.5.x
|
42
|
+
- name: Publish to RubyGems
|
43
|
+
run: gem push *.gem
|
44
|
+
env:
|
45
|
+
GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
|
46
|
+
|
47
|
+
publish_gpr:
|
48
|
+
name: Publish GPR
|
49
|
+
needs: build
|
50
|
+
runs-on: ubuntu-latest
|
51
|
+
steps:
|
52
|
+
- uses: actions/download-artifact@v2
|
53
|
+
with:
|
54
|
+
name: idnow-client.gem
|
55
|
+
- name: Set up Ruby 2.5
|
56
|
+
uses: actions/setup-ruby@v1
|
57
|
+
with:
|
58
|
+
ruby-version: 2.5.x
|
59
|
+
- name: Publish to GPR
|
60
|
+
run: |
|
61
|
+
mv *.gem idnow-client-2.3.0.gem
|
62
|
+
gem push --host https://rubygems.pkg.github.com/${OWNER} idnow-client-2.3.0.gem
|
63
|
+
env:
|
64
|
+
GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
|
65
|
+
OWNER: ${{github.repository_owner}}
|
66
|
+
|
67
|
+
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
AllCops:
|
2
2
|
DisplayCopNames: true
|
3
|
-
TargetRubyVersion: 2.
|
3
|
+
TargetRubyVersion: 2.5
|
4
|
+
NewCops: enable
|
4
5
|
|
5
6
|
# This configuration was generated by
|
6
7
|
# `rubocop --auto-gen-config`
|
@@ -19,14 +20,12 @@ Metrics/LineLength:
|
|
19
20
|
Metrics/MethodLength:
|
20
21
|
Max: 31
|
21
22
|
|
22
|
-
Metrics/
|
23
|
-
|
23
|
+
Metrics/BlockLength:
|
24
|
+
Max: 190
|
25
|
+
Exclude:
|
26
|
+
- 'spec/**/*.rb'
|
24
27
|
|
25
|
-
|
26
|
-
# Cop supports --auto-correct.
|
27
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
28
|
-
# SupportedStyles: braces, no_braces, context_dependent
|
29
|
-
Style/BracesAroundHashParameters:
|
28
|
+
Metrics/AbcSize:
|
30
29
|
Enabled: false
|
31
30
|
|
32
31
|
# Offense count: 7
|
@@ -35,9 +34,3 @@ Style/Documentation:
|
|
35
34
|
|
36
35
|
Style/GuardClause:
|
37
36
|
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
CHANGED
data/CODE_OF_CONDUCT.md
ADDED
@@ -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/Dockerfile
ADDED
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
data/Makefile
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. [![Build Status](https://travis-ci.com/Solarisbank/idnow-client.svg?branch=master)](https://travis-ci.com/Solarisbank/idnow-client)
|
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,38 @@ Idnow.client.upload_default_document(document_identifier, file_data)
|
|
132
150
|
Idnow.client.download_default_document(document_identifier)
|
133
151
|
```
|
134
152
|
|
153
|
+
## Development & testing
|
154
|
+
|
155
|
+
RSpec is used for testing. For easier development, the project is dockerized allowing development inisde the container. Make use of following make targets:
|
156
|
+
|
157
|
+
Create development container:
|
158
|
+
|
159
|
+
```
|
160
|
+
make build
|
161
|
+
```
|
162
|
+
|
163
|
+
Open development console
|
164
|
+
|
165
|
+
```
|
166
|
+
make dev
|
167
|
+
```
|
168
|
+
|
169
|
+
Inside the console, `rspec` or `bundle` can be executed.
|
135
170
|
|
136
|
-
## Development
|
137
171
|
|
138
|
-
|
172
|
+
### Coverage report
|
173
|
+
|
139
174
|
To enable code coverage check, set COV environment variable:
|
140
175
|
|
141
|
-
```
|
176
|
+
```sh
|
177
|
+
COV=true make test
|
178
|
+
```
|
179
|
+
|
180
|
+
### Testing with docker
|
142
181
|
|
182
|
+
To run the tests through docker, you can use the included `Dockerfile`:
|
183
|
+
|
184
|
+
```sh
|
185
|
+
make build
|
186
|
+
docker run -it idnow-client:latest make test
|
187
|
+
```
|
@@ -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 = '
|
5
|
+
spec.version = '2.3.0'
|
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.
|
25
|
-
|
26
|
-
spec.add_development_dependency '
|
27
|
-
spec.add_development_dependency '
|
28
|
-
spec.add_development_dependency '
|
29
|
-
spec.add_development_dependency 'shoulda-matchers'
|
24
|
+
spec.required_ruby_version = '>= 2.5', '< 3.1'
|
25
|
+
|
26
|
+
spec.add_development_dependency 'factory_bot'
|
27
|
+
spec.add_development_dependency 'rspec'
|
28
|
+
spec.add_development_dependency 'rubocop'
|
29
|
+
spec.add_development_dependency 'shoulda-matchers'
|
30
|
+
spec.add_development_dependency 'simplecov'
|
31
|
+
spec.add_development_dependency 'webmock'
|
30
32
|
end
|
data/lib/idnow.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'idnow/modules/jsonable'
|
2
4
|
require 'idnow/client'
|
3
5
|
|
@@ -23,14 +25,16 @@ require 'idnow/models/login_data'
|
|
23
25
|
require 'idnow/models/document_definition'
|
24
26
|
|
25
27
|
module Idnow
|
26
|
-
|
27
|
-
|
28
|
-
|
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'
|
29
32
|
end
|
30
33
|
|
31
|
-
|
32
|
-
|
33
|
-
|
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'
|
34
38
|
end
|
35
39
|
|
36
40
|
ENVIRONMENTS = {
|
@@ -45,7 +49,8 @@ module Idnow
|
|
45
49
|
}.freeze
|
46
50
|
|
47
51
|
def env=(env)
|
48
|
-
|
52
|
+
raise ArgumentError, 'Please provide a valid enviroment, :test or :live' unless ENVIRONMENTS.keys.include?(env)
|
53
|
+
|
49
54
|
@client = nil
|
50
55
|
@env = env
|
51
56
|
end
|
@@ -60,9 +65,23 @@ module Idnow
|
|
60
65
|
@api_key = api_key
|
61
66
|
end
|
62
67
|
|
68
|
+
def sftp_options=(sftp_options)
|
69
|
+
@client = nil
|
70
|
+
@sftp_options = sftp_options
|
71
|
+
end
|
72
|
+
|
73
|
+
def custom_environments=(custom_environments)
|
74
|
+
@client = nil
|
75
|
+
@custom_environments = custom_environments
|
76
|
+
end
|
77
|
+
|
78
|
+
def endpoint(env, host)
|
79
|
+
(@custom_environments || {}).dig(env, host) || Idnow::ENVIRONMENTS[env][host]
|
80
|
+
end
|
81
|
+
|
63
82
|
def client
|
64
|
-
@client ||= Idnow::Client.new(env: @env, company_id: @company_id, api_key: @api_key)
|
83
|
+
@client ||= Idnow::Client.new(env: @env, company_id: @company_id, api_key: @api_key, sftp_options: @sftp_options || {})
|
65
84
|
end
|
66
85
|
|
67
|
-
module_function :env=, :company_id=, :api_key=, :client
|
86
|
+
module_function :env=, :company_id=, :api_key=, :sftp_options=, :custom_environments=, :endpoint, :client
|
68
87
|
end
|