idnow 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 82db134ab8710048f63870b2f4c5735b4a4b2c2808481efedd2bd0816e63d3bb
4
- data.tar.gz: a021696004917135fe482aa575ef2fd18c8d27d8e3e46cd7737511012a733354
3
+ metadata.gz: 3caa1be49888278cacbd44efe6daaccaca538b747312243f55c4b529f4b060da
4
+ data.tar.gz: 9fdd7352d6dc258acbc7c36e1697eee0865791146390c530bc75476933da6aec
5
5
  SHA512:
6
- metadata.gz: e0be012fca98d2b9385292d99b50a33dc61889e7e9251ca3ce0c2f56c9b95f92b00a3960d8df66456e188129a5bf44701d9891856fe02466c9648002686cbfaa
7
- data.tar.gz: cc023ff9bf7703e4b987ef6b24b5af7745ef231f4ca1ef57d8dc57d5e15f20a07afaff5b5cc628b699e11443b195cfd632ef3e455a40c7aa399cf4f66717e8de
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/.rubocop.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  AllCops:
2
2
  DisplayCopNames: true
3
- TargetRubyVersion: 2.3
3
+ TargetRubyVersion: 2.5
4
+ NewCops: enable
4
5
 
5
6
  # This configuration was generated by
6
7
  # `rubocop --auto-gen-config`
@@ -27,13 +28,6 @@ Metrics/BlockLength:
27
28
  Metrics/AbcSize:
28
29
  Enabled: false
29
30
 
30
- # Offense count: 2
31
- # Cop supports --auto-correct.
32
- # Configuration parameters: EnforcedStyle, SupportedStyles.
33
- # SupportedStyles: braces, no_braces, context_dependent
34
- Style/BracesAroundHashParameters:
35
- Enabled: false
36
-
37
31
  # Offense count: 7
38
32
  Style/Documentation:
39
33
  Enabled: false
data/.travis.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.3.3
3
+ - 2.5.3
4
4
 
5
5
  script:
6
6
  - make test
data/Dockerfile CHANGED
@@ -1,12 +1,8 @@
1
- FROM ruby:2.3-alpine
1
+ FROM ruby:2.5
2
2
 
3
3
  RUN mkdir /gem
4
4
  WORKDIR /gem
5
5
 
6
- RUN apk update
7
- RUN apk add git build-base
8
- RUN gem install bundler
9
-
10
6
  COPY Gemfile idnow-client.gemspec /gem/
11
7
  RUN bundle install
12
8
 
data/Makefile CHANGED
@@ -5,3 +5,9 @@ rspec:
5
5
 
6
6
  rubocop:
7
7
  bundle exec rubocop
8
+
9
+ build:
10
+ docker build -t idnow-client .
11
+
12
+ dev: build
13
+ docker run --rm -it -v $$PWD:/gem idnow-client bash
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Idnow Client
2
2
 
3
- Library to consume the [IDnow API](http://www.idnow.eu/developers) in Ruby.
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
 
@@ -152,7 +152,22 @@ Idnow.client.download_default_document(document_identifier)
152
152
 
153
153
  ## Development & testing
154
154
 
155
- RSpec is used for testing.
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.
170
+
156
171
 
157
172
  ### Coverage report
158
173
 
@@ -167,6 +182,6 @@ COV=true make test
167
182
  To run the tests through docker, you can use the included `Dockerfile`:
168
183
 
169
184
  ```sh
170
- docker build . -t idnow-client
185
+ make build
171
186
  docker run -it idnow-client:latest make test
172
187
  ```
data/idnow-client.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'idnow'
5
- spec.version = '2.2.0'
5
+ spec.version = '2.3.0'
6
6
  spec.authors = ['Joan Martinez, Tobias Bielohlawek']
7
7
  spec.email = ['joan.martinez@solarisbank.de']
8
8
 
@@ -21,12 +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'
24
+ spec.required_ruby_version = '>= 2.5', '< 3.1'
25
25
 
26
- spec.add_development_dependency 'factory_bot', '~> 4.5'
27
- spec.add_development_dependency 'rspec', '~> 3.3'
28
- spec.add_development_dependency 'rubocop', '~> 0.54.0'
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'
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'
32
32
  end
data/lib/idnow.rb CHANGED
@@ -50,6 +50,7 @@ module Idnow
50
50
 
51
51
  def env=(env)
52
52
  raise ArgumentError, 'Please provide a valid enviroment, :test or :live' unless ENVIRONMENTS.keys.include?(env)
53
+
53
54
  @client = nil
54
55
  @env = env
55
56
  end
@@ -8,13 +8,13 @@ module Idnow
8
8
  def testing_start(transaction_number:)
9
9
  path = full_path_for("identifications/#{transaction_number}/start")
10
10
  request = Idnow::PostJsonRequest.new(path, {})
11
- execute(request, 'X-API_KEY' => @api_key, http_client: automated_testing_http_client)
11
+ execute(request, { 'X-API_KEY' => @api_key }, http_client: automated_testing_http_client)
12
12
  end
13
13
 
14
14
  def testing_request_video_chat(transaction_number:)
15
15
  path = full_path_for("identifications/#{transaction_number}/requestVideoChat")
16
16
  request = Idnow::PostJsonRequest.new(path, {})
17
- execute(request, 'X-API_KEY' => @api_key, http_client: automated_testing_http_client)
17
+ execute(request, { 'X-API_KEY' => @api_key }, http_client: automated_testing_http_client)
18
18
  end
19
19
  end
20
20
  end
@@ -8,7 +8,7 @@ module Idnow
8
8
 
9
9
  path = full_path_for('documentdefinitions')
10
10
  request = Idnow::PostJsonRequest.new(path, document_data)
11
- execute(request, 'X-API-LOGIN-TOKEN' => @auth_token)
11
+ execute(request, { 'X-API-LOGIN-TOKEN' => @auth_token })
12
12
  end
13
13
 
14
14
  def list_document_definitions
@@ -16,14 +16,15 @@ module Idnow
16
16
 
17
17
  path = full_path_for('documentdefinitions')
18
18
  request = Idnow::GetRequest.new(path)
19
- response = execute(request, 'X-API-LOGIN-TOKEN' => @auth_token)
19
+ response = execute(request, { 'X-API-LOGIN-TOKEN' => @auth_token })
20
20
  response.data.map do |data|
21
21
  Idnow::DocumentDefinition.new(data)
22
22
  end
23
23
  end
24
24
 
25
- def list_cached_document_definitions(refresh = false)
25
+ def list_cached_document_definitions(refresh = false) # rubocop:disable Style/OptionalBooleanParameter
26
26
  return @list_cached_document_definitions = list_document_definitions if refresh
27
+
27
28
  @list_cached_document_definitions ||= list_document_definitions
28
29
  end
29
30
  end
@@ -8,7 +8,7 @@ module Idnow
8
8
 
9
9
  path = full_path_for("documentdefinitions/#{document_definition_identifier}/data")
10
10
  request = Idnow::GetRequest.new(path, '')
11
- execute(request, 'X-API-LOGIN-TOKEN' => @auth_token)
11
+ execute(request, { 'X-API-LOGIN-TOKEN' => @auth_token })
12
12
  end
13
13
  end
14
14
  end
@@ -6,7 +6,7 @@ module Idnow
6
6
  def request_identification(transaction_number:, identification_data:)
7
7
  path = full_path_for("identifications/#{transaction_number}/start")
8
8
  request = Idnow::PostJsonRequest.new(path, identification_data)
9
- response = execute(request, 'X-API-KEY' => @api_key)
9
+ response = execute(request, { 'X-API-KEY' => @api_key })
10
10
  Idnow::IdentificationRequest.new(response.data, transaction_number, @target_host, @company_id)
11
11
  end
12
12
  end
@@ -11,10 +11,11 @@ module Idnow
11
11
  unless status.nil? || IDENTIFICATION_STATUSES.include?(status)
12
12
  raise Idnow::InvalidArguments, "Status #{status} not defined, possible options are: #{IDENTIFICATION_STATUSES.join(',')}"
13
13
  end
14
+
14
15
  partial_path = status.nil? ? 'identifications' : "identifications?#{status}=true"
15
16
  path = full_path_for(partial_path)
16
17
  request = Idnow::GetRequest.new(path)
17
- response = execute(request, 'X-API-LOGIN-TOKEN' => @auth_token)
18
+ response = execute(request, { 'X-API-LOGIN-TOKEN' => @auth_token })
18
19
  response.data['identifications'].map do |data|
19
20
  Idnow::Identification.new(data)
20
21
  end
@@ -25,7 +26,7 @@ module Idnow
25
26
 
26
27
  path = full_path_for("identifications/#{transaction_number}")
27
28
  request = Idnow::GetRequest.new(path)
28
- response = execute(request, 'X-API-LOGIN-TOKEN' => @auth_token)
29
+ response = execute(request, { 'X-API-LOGIN-TOKEN' => @auth_token })
29
30
  Idnow::Identification.new(response.data)
30
31
  end
31
32
 
@@ -17,8 +17,9 @@ module Idnow
17
17
 
18
18
  def upload_document(file_data, request_path)
19
19
  raise Idnow::AuthenticationException if @auth_token.nil?
20
+
20
21
  request = Idnow::PostBinaryRequest.new(request_path, file_data)
21
- execute(request, 'X-API-LOGIN-TOKEN' => @auth_token)
22
+ execute(request, { 'X-API-LOGIN-TOKEN' => @auth_token })
22
23
  end
23
24
  end
24
25
  end
data/lib/idnow/client.rb CHANGED
@@ -26,6 +26,7 @@ module Idnow
26
26
  raise 'Please set env to :test or :live' unless Idnow::ENVIRONMENTS.keys.include?(env)
27
27
  raise 'Please set your company_id' if company_id.nil?
28
28
  raise 'Please set your api_key' if api_key.nil?
29
+
29
30
  @host = Idnow.endpoint(env, :host)
30
31
  @target_host = Idnow.endpoint(env, :target_host)
31
32
  @company_id = company_id
@@ -10,9 +10,7 @@ module Idnow
10
10
  # config.company_id = company_id
11
11
  # end
12
12
 
13
- attr_accessor :api_key
14
-
15
- attr_accessor :company_id
13
+ attr_accessor :api_key, :company_id, :host, :api_version
16
14
 
17
15
  module Idnow
18
16
  module Host
@@ -20,8 +18,5 @@ module Idnow
20
18
  PRODUCTION = 'https://gateway.idnow.de'
21
19
  end
22
20
  end
23
- attr_accessor :host
24
-
25
- attr_accessor :api_version
26
21
  end
27
22
  end
data/lib/idnow/helpers.rb CHANGED
@@ -5,7 +5,7 @@ module Idnow
5
5
  PROJECT_ROOT = File.dirname(File.dirname(File.dirname(__FILE__)))
6
6
 
7
7
  module Factories
8
- Dir[File.join(PROJECT_ROOT, 'spec', 'support', 'factories', '*.rb')].each { |file| require(file) }
8
+ Dir[File.join(PROJECT_ROOT, 'spec', 'support', 'factories', '*.rb')].sort.each { |file| require(file) }
9
9
  end
10
10
  end
11
11
  end
@@ -9,22 +9,24 @@ module Idnow
9
9
  FEMALE = 'FEMALE'
10
10
  end
11
11
 
12
+ # rubocop:disable Naming/MethodName
12
13
  attr_accessor :birthplace, :birthname, :city, :custom1,
13
14
  :custom2, :custom3, :custom4, :custom5, :trackingid, :email, :firstname,
14
15
  :lastname, :mobilephone, :nationality, :street, :streetnumber, :title, :zipcode,
15
16
  :preferredLang
17
+ # rubocop:enable Naming/MethodName
16
18
 
17
19
  attr_reader :country, :gender
18
20
 
19
21
  def initialize(params = {})
20
- params.keys.each do |key|
22
+ params.each_key do |key|
21
23
  raise ArgumentError, "Attribute #{key} is not supported!" unless respond_to?(key.to_sym)
22
24
 
23
25
  send("#{key}=", params[key])
24
26
  end
25
27
  end
26
28
 
27
- def to_json
29
+ def to_json(*_args)
28
30
  result = {}
29
31
  instance_variables.each do |attribute|
30
32
  result[attribute.to_s.delete('@')] = instance_variable_get(attribute)
@@ -8,7 +8,7 @@ module Idnow
8
8
  @api_key = api_key
9
9
  end
10
10
 
11
- def to_json
11
+ def to_json(*_args)
12
12
  { apiKey: @api_key }.to_json
13
13
  end
14
14
  end
@@ -14,7 +14,7 @@ module Idnow
14
14
  end
15
15
  end
16
16
 
17
- def to_json
17
+ def to_json(*_args)
18
18
  keys_without_underscores(to_h).to_json
19
19
  end
20
20
 
@@ -22,6 +22,7 @@ module Idnow
22
22
 
23
23
  def keys_without_underscores(obj)
24
24
  return obj unless obj.is_a?(Hash)
25
+
25
26
  obj.each_with_object({}) do |(k, v), result|
26
27
  result[k.to_s.delete('_')] = keys_without_underscores(v)
27
28
  end
@@ -13,7 +13,7 @@ module Idnow
13
13
  def errors
14
14
  if valid_json?(@raw)
15
15
  json_data = JSON.parse(@raw)
16
- json_data['errors'] if json_data.class == Hash
16
+ json_data['errors'] if json_data.instance_of?(Hash)
17
17
  end
18
18
  end
19
19
 
@@ -16,6 +16,7 @@ module Idnow
16
16
  options = @options.merge(password: @password)
17
17
  Net::SFTP.start(@host, @username, options) do |sftp|
18
18
  raise Idnow::Exception, "Invalid path. No identification file found under #{file_name}" unless file_exists(sftp, file_name)
19
+
19
20
  begin
20
21
  data = sftp.download!(file_name)
21
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: 2.2.0
4
+ version: 2.3.0
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: 2020-08-24 00:00:00.000000000 Z
11
+ date: 2021-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-sftp
@@ -28,86 +28,86 @@ dependencies:
28
28
  name: factory_bot
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '4.5'
33
+ version: '0'
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: '4.5'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '3.3'
47
+ version: '0'
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: '3.3'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rubocop
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 0.54.0
61
+ version: '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: 0.54.0
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: shoulda-matchers
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '3.1'
75
+ version: '0'
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: '3.1'
82
+ version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: simplecov
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '0.10'
89
+ version: '0'
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: '0.10'
96
+ version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: webmock
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
- version: '1.22'
103
+ version: '0'
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: '1.22'
110
+ version: '0'
111
111
  description: Library to consume the IDnow API in Ruby, http://www.idnow.eu/developers
112
112
  email:
113
113
  - joan.martinez@solarisbank.de
@@ -115,6 +115,7 @@ executables: []
115
115
  extensions: []
116
116
  extra_rdoc_files: []
117
117
  files:
118
+ - ".github/workflows/gem-push.yml"
118
119
  - ".gitignore"
119
120
  - ".rspec"
120
121
  - ".rubocop.yml"
@@ -125,7 +126,6 @@ files:
125
126
  - LICENSE.txt
126
127
  - Makefile
127
128
  - README.md
128
- - circle.yml
129
129
  - docs/IDnow_API.pdf
130
130
  - examples/idnow_automated_testing.rb
131
131
  - examples/idnow_download_identification.rb
@@ -172,9 +172,12 @@ require_paths:
172
172
  - lib
173
173
  required_ruby_version: !ruby/object:Gem::Requirement
174
174
  requirements:
175
- - - "~>"
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ version: '2.5'
178
+ - - "<"
176
179
  - !ruby/object:Gem::Version
177
- version: '2.3'
180
+ version: '3.1'
178
181
  required_rubygems_version: !ruby/object:Gem::Requirement
179
182
  requirements:
180
183
  - - ">="
data/circle.yml DELETED
@@ -1,7 +0,0 @@
1
- machine:
2
- ruby:
3
- version: 2.3.3
4
-
5
- test:
6
- override:
7
- - make test