idnow 1.1.0 → 1.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
  SHA1:
3
- metadata.gz: 57e72a956f1a026c9297ba8199cc07b3e943fcc1
4
- data.tar.gz: 86c6851ce341282bac0092a96321d8d437f1c870
3
+ metadata.gz: f7636a8ddecbc36e100f54413150590a4ace73ea
4
+ data.tar.gz: 7457d857840d07698651ad9353a72dd8e08a9cfc
5
5
  SHA512:
6
- metadata.gz: 458341cdac882f348728b17556f33f6ac6faddd3b9aeae4eb88b7e0c0706ff03cdddc6d5cc0489703b0eda9ea5225e76a1b0eb96d79addc72cd05124108d158c
7
- data.tar.gz: 8ed1b3ff93ce58a1f559ff614343c6aa3022ebe50f9c9159c6e133c28291f06d9703af8ce3b15bf917f96f444fe5e6e33af8b70ffd2b1715e87ce14c4c6bfdd5
6
+ metadata.gz: cc4b30834b1f450d9c9e56e43c3fabb37f6029760f25bd0178c06dd48e7bf5358b6dbee6b4243eb1d863828adfb8724dd334bf5ebcb9b64506e28edd1d2ed09a
7
+ data.tar.gz: ecded6e3fc954b139141d84c88aa6fdf64aa95773aefef95cfa30b720bab12b97313d451ca503e4b1532c025577ad3f92d052e421c6f415b0b4d6fb1a1c612a1
data/.gitignore CHANGED
@@ -10,3 +10,4 @@
10
10
  /spec/reports/
11
11
  /tmp/
12
12
  tags
13
+ .*.sw?
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ - 2.3.1
5
+
6
+ script:
7
+ - make test
data/Makefile CHANGED
@@ -1,2 +1,7 @@
1
- test:
1
+ test: rspec
2
+
3
+ rspec:
2
4
  bundle exec rspec
5
+
6
+ rubocop:
7
+ bundle exec rubocop
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 = '1.1.0'
5
+ spec.version = '1.3.0'
6
6
  spec.authors = ['Joan Martinez, Tobias Bielohlawek']
7
7
  spec.email = ['joan.martinez.ripoll@gmail.com']
8
8
 
data/lib/idnow.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'idnow/modules/jsonable'
2
3
  require 'idnow/client'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Idnow
2
3
  module API
3
4
  module AutomatedTesting
data/lib/idnow/client.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'idnow/API/authentication'
2
3
  require 'idnow/API/automated_testing' # shouldn't be included by default
3
4
  require 'idnow/API/request_identifications'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Idnow
2
3
  class Configuration
3
4
  # TODO: This class is not being used right now, but its aim is to be able for the developers
@@ -1,26 +1,27 @@
1
1
  module Idnow
2
2
  class HttpClient
3
- def initialize(host:)
4
- @uri = URI.parse(host)
3
+ def initialize(host:, read_timout_sec: 30)
4
+ @uri = URI.parse(host)
5
+ @read_timeout = read_timout_sec
5
6
  end
6
7
 
7
8
  def execute(request, headers = {})
8
9
  headers.each do |k, v|
9
10
  request[k] = v
10
11
  end
11
- begin
12
- client.request(request)
13
- rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
14
- Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
15
- raise Idnow::ConnectionException, e
16
- end
12
+
13
+ client.request(request)
14
+ rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
15
+ Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
16
+ raise Idnow::ConnectionException, e
17
17
  end
18
18
 
19
19
  private
20
20
 
21
21
  def client
22
22
  Net::HTTP.new(@uri.host, @uri.port).tap do |http|
23
- http.use_ssl = true
23
+ http.read_timeout = @read_timeout
24
+ http.use_ssl = true
24
25
  end
25
26
  end
26
27
  end
@@ -1,5 +1,5 @@
1
1
  require 'forwardable'
2
- require 'pry'
2
+
3
3
  module Idnow
4
4
  class Identification
5
5
  extend Forwardable
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'json'
2
3
 
3
4
  module Idnow
@@ -23,7 +23,7 @@ module Idnow
23
23
  end
24
24
 
25
25
  def review_pending?
26
- result == 'REVIEW_PENDING'
26
+ result == 'REVIEW_PENDING' || result == 'FRAUD_SUSPICION_PENDING'
27
27
  end
28
28
  end
29
29
  end
@@ -19,12 +19,17 @@ module Idnow
19
19
  @streetnumber = dig_value('address', 'streetnumber', data)
20
20
  @title = dig_value('title', data)
21
21
  @zipcode = dig_value('address', 'zipcode', data)
22
+ @raw_data = data
22
23
  end
23
24
 
24
25
  def address
25
26
  "#{street} #{streetnumber}, #{zipcode} #{city}, #{country}"
26
27
  end
27
28
 
29
+ def address_changed?
30
+ @raw_data['address'].values.any? { |field| field['status'] == 'CHANGE' }
31
+ end
32
+
28
33
  private
29
34
 
30
35
  def dig_value(*keys, data)
@@ -11,7 +11,7 @@ module Idnow
11
11
  def download(file_name)
12
12
  data = nil
13
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?
14
+ fail Idnow::Exception, "Invalid path. No identification file found under #{file_name}" unless file_exists(sftp, file_name)
15
15
  begin
16
16
  data = sftp.download!(file_name)
17
17
  rescue Net::SFTP::Exception => e
@@ -20,5 +20,12 @@ module Idnow
20
20
  end
21
21
  data
22
22
  end
23
+
24
+ private
25
+
26
+ def file_exists(sftp, file_name)
27
+ sftp.dir.entries('.').each { |entry| return true if file_name == entry.name }
28
+ false
29
+ end
23
30
  end
24
31
  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.1.0
4
+ version: 1.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-07-04 00:00:00.000000000 Z
11
+ date: 2016-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-sftp
@@ -118,6 +118,7 @@ files:
118
118
  - ".gitignore"
119
119
  - ".rspec"
120
120
  - ".rubocop.yml"
121
+ - ".travis.yml"
121
122
  - CODE_OF_CONDUCT.md
122
123
  - Gemfile
123
124
  - LICENSE.txt
@@ -180,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
181
  version: '0'
181
182
  requirements: []
182
183
  rubyforge_project:
183
- rubygems_version: 2.4.5.1
184
+ rubygems_version: 2.6.6
184
185
  signing_key:
185
186
  specification_version: 4
186
187
  summary: Ruby client for the IDnow API