idnow 1.0.0 → 2.3.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.
Files changed (48) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/gem-push.yml +67 -0
  3. data/.gitignore +1 -0
  4. data/.rubocop.yml +7 -14
  5. data/.travis.yml +4 -2
  6. data/CODE_OF_CONDUCT.md +13 -0
  7. data/Dockerfile +9 -0
  8. data/Gemfile +2 -0
  9. data/LICENSE.txt +1 -1
  10. data/Makefile +12 -1
  11. data/README.md +57 -12
  12. data/examples/idnow_automated_testing.rb +3 -1
  13. data/examples/idnow_download_identification.rb +3 -1
  14. data/examples/idnow_get_identification.rb +3 -1
  15. data/examples/idnow_upload_download_default_document.rb +3 -1
  16. data/idnow-client.gemspec +12 -10
  17. data/lib/idnow.rb +28 -9
  18. data/lib/idnow/API/authentication.rb +2 -0
  19. data/lib/idnow/API/automated_testing.rb +5 -3
  20. data/lib/idnow/API/document_definitions.rb +10 -7
  21. data/lib/idnow/API/download_documents.rb +4 -2
  22. data/lib/idnow/API/request_identifications.rb +3 -1
  23. data/lib/idnow/API/retrieve_identifications.rb +9 -6
  24. data/lib/idnow/API/upload_documents.rb +5 -2
  25. data/lib/idnow/client.rb +14 -9
  26. data/lib/idnow/configuration.rb +5 -8
  27. data/lib/idnow/exception.rb +2 -0
  28. data/lib/idnow/get_request.rb +2 -0
  29. data/lib/idnow/helpers.rb +3 -1
  30. data/lib/idnow/http_client.rb +12 -9
  31. data/lib/idnow/json_response.rb +3 -1
  32. data/lib/idnow/models/contact_data.rb +2 -0
  33. data/lib/idnow/models/document_definition.rb +2 -0
  34. data/lib/idnow/models/identification.rb +5 -2
  35. data/lib/idnow/models/identification_data.rb +20 -13
  36. data/lib/idnow/models/identification_document.rb +11 -18
  37. data/lib/idnow/models/identification_process.rb +4 -2
  38. data/lib/idnow/models/identification_request.rb +2 -0
  39. data/lib/idnow/models/login.rb +2 -0
  40. data/lib/idnow/models/login_data.rb +3 -1
  41. data/lib/idnow/models/user_data.rb +7 -0
  42. data/lib/idnow/modules/jsonable.rb +4 -1
  43. data/lib/idnow/post_binary_request.rb +2 -0
  44. data/lib/idnow/post_json_request.rb +2 -0
  45. data/lib/idnow/raw_response.rb +5 -3
  46. data/lib/idnow/sftp_client.rb +15 -3
  47. metadata +41 -37
  48. data/circle.yml +0 -7
@@ -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(SUCCESS SUCCESS_DATA_CHANGED).freeze
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)
@@ -23,7 +25,7 @@ module Idnow
23
25
  end
24
26
 
25
27
  def review_pending?
26
- result == 'REVIEW_PENDING'
28
+ result == 'REVIEW_PENDING' || result == 'FRAUD_SUSPICION_PENDING'
27
29
  end
28
30
  end
29
31
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Idnow
2
4
  class IdentificationRequest
3
5
  attr_accessor :id, :transaction_number
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Idnow
2
4
  class Login
3
5
  attr_accessor :auth_token
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'json'
2
4
 
3
5
  module Idnow
@@ -6,7 +8,7 @@ module Idnow
6
8
  @api_key = api_key
7
9
  end
8
10
 
9
- def to_json
11
+ def to_json(*_args)
10
12
  { apiKey: @api_key }.to_json
11
13
  end
12
14
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Idnow
2
4
  class UserData
3
5
  include Idnow::Jsonable
@@ -19,12 +21,17 @@ module Idnow
19
21
  @streetnumber = dig_value('address', 'streetnumber', data)
20
22
  @title = dig_value('title', data)
21
23
  @zipcode = dig_value('address', 'zipcode', data)
24
+ @raw_data = data
22
25
  end
23
26
 
24
27
  def address
25
28
  "#{street} #{streetnumber}, #{zipcode} #{city}, #{country}"
26
29
  end
27
30
 
31
+ def address_changed?
32
+ @raw_data['address'].values.any? { |field| field['status'] == 'CHANGE' }
33
+ end
34
+
28
35
  private
29
36
 
30
37
  def dig_value(*keys, data)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Idnow
2
4
  module Jsonable
3
5
  def to_h
@@ -12,7 +14,7 @@ module Idnow
12
14
  end
13
15
  end
14
16
 
15
- def to_json
17
+ def to_json(*_args)
16
18
  keys_without_underscores(to_h).to_json
17
19
  end
18
20
 
@@ -20,6 +22,7 @@ module Idnow
20
22
 
21
23
  def keys_without_underscores(obj)
22
24
  return obj unless obj.is_a?(Hash)
25
+
23
26
  obj.each_with_object({}) do |(k, v), result|
24
27
  result[k.to_s.delete('_')] = keys_without_underscores(v)
25
28
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'net/http'
2
4
 
3
5
  module Idnow
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # require 'json'
2
4
  require 'net/http'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Idnow
2
4
  class RawResponse
3
5
  attr_reader :raw
@@ -11,7 +13,7 @@ module Idnow
11
13
  def errors
12
14
  if valid_json?(@raw)
13
15
  json_data = JSON.parse(@raw)
14
- json_data['errors'] if json_data.class == Hash
16
+ json_data['errors'] if json_data.instance_of?(Hash)
15
17
  end
16
18
  end
17
19
 
@@ -23,9 +25,9 @@ module Idnow
23
25
 
24
26
  def valid_json?(json)
25
27
  JSON.parse(json)
26
- return true
28
+ true
27
29
  rescue JSON::ParserError
28
- return false
30
+ false
29
31
  end
30
32
  end
31
33
  end
@@ -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:, options: {})
6
8
  @host = URI.parse(host).host
7
9
  @username = username
8
10
  @password = password
11
+ @options = options
9
12
  end
10
13
 
11
14
  def download(file_name)
12
15
  data = nil
13
- Net::SFTP.start(@host, @username, password: @password) do |sftp|
14
- fail Idnow::Exception, "Invalid path. No identification file found under #{file_name}" if sftp.dir['.', file_name].empty?
16
+ options = @options.merge(password: @password)
17
+ Net::SFTP.start(@host, @username, options) do |sftp|
18
+ raise Idnow::Exception, "Invalid path. No identification file found under #{file_name}" unless file_exists(sftp, file_name)
19
+
15
20
  begin
16
21
  data = sftp.download!(file_name)
17
22
  rescue Net::SFTP::Exception => e
@@ -20,5 +25,12 @@ module Idnow
20
25
  end
21
26
  data
22
27
  end
28
+
29
+ private
30
+
31
+ def file_exists(sftp, file_name)
32
+ sftp.dir.entries('.').each { |entry| return true if file_name == entry.name }
33
+ false
34
+ end
23
35
  end
24
36
  end
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.0.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: 2016-05-04 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
@@ -25,105 +25,107 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.1'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rspec
28
+ name: factory_bot
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '3.3'
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: '3.3'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: webmock
42
+ name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '1.22'
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: '1.22'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: simplecov
56
+ name: rubocop
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '0.10'
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.10'
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: rubocop
70
+ name: shoulda-matchers
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: 0.36.0
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: 0.36.0
82
+ version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: factory_girl
84
+ name: simplecov
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '4.5'
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: '4.5'
96
+ version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: shoulda-matchers
98
+ name: webmock
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
- version: '3.1'
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: '3.1'
110
+ version: '0'
111
111
  description: Library to consume the IDnow API in Ruby, http://www.idnow.eu/developers
112
112
  email:
113
- - joan.martinez.ripoll@gmail.com
113
+ - joan.martinez@solarisbank.de
114
114
  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"
121
122
  - ".travis.yml"
123
+ - CODE_OF_CONDUCT.md
124
+ - Dockerfile
122
125
  - Gemfile
123
126
  - LICENSE.txt
124
127
  - Makefile
125
128
  - README.md
126
- - circle.yml
127
129
  - docs/IDnow_API.pdf
128
130
  - examples/idnow_automated_testing.rb
129
131
  - examples/idnow_download_identification.rb
@@ -172,15 +174,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
172
174
  requirements:
173
175
  - - ">="
174
176
  - !ruby/object:Gem::Version
175
- version: '0'
177
+ version: '2.5'
178
+ - - "<"
179
+ - !ruby/object:Gem::Version
180
+ version: '3.1'
176
181
  required_rubygems_version: !ruby/object:Gem::Requirement
177
182
  requirements:
178
183
  - - ">="
179
184
  - !ruby/object:Gem::Version
180
185
  version: '0'
181
186
  requirements: []
182
- rubyforge_project:
183
- rubygems_version: 2.4.5.1
187
+ rubygems_version: 3.0.3
184
188
  signing_key:
185
189
  specification_version: 4
186
190
  summary: Ruby client for the IDnow API
data/circle.yml DELETED
@@ -1,7 +0,0 @@
1
- machine:
2
- ruby:
3
- version: 2.2.3
4
-
5
- test:
6
- override:
7
- - make test