jumio_rock 0.0.4 → 0.0.5

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: 8887ebde29d1462542f4ad9bbc69c80b8eb3bd21
4
- data.tar.gz: 6e02112fb7693ef33ef0a707b7508485fc10dbd6
3
+ metadata.gz: a60671a450c3f4fd1c97074fb54e6a8d8f2980ca
4
+ data.tar.gz: 56bb957d129d3798962785b96017fb7af10d96bd
5
5
  SHA512:
6
- metadata.gz: a07760676ac92092b737cdabe9fd50f5d3e4aa2bf3506acb70ff60193bb8a0b40f93a8f457d235160153db77853a21c5ca5d085b4e4f9021d1c9559922f5ece8
7
- data.tar.gz: 297615a42c25282f0cf1652293d57cec15761ce90694b96555f68a43070e561b0ca0c6665772457d8ff88a01c8538aa28afc2366f21ea3f248a0174bd7fd23ae
6
+ metadata.gz: 124232aacd54ce5c04eeab823d63c56e6f6842cdedf02d23d111f453e929685d31ca69e456a4e705799685bd83f6f6d36e697592e21e4ec42dabf2323b1ca114
7
+ data.tar.gz: a5c31725e6924ad5e3e8bbd85e68ba5f8caa150fba77a126c8d6e57ab8747d4620bc8403db9fe2a9797353d6bc4bc99752f6a5183c34f7627cd2175011e436a0
@@ -1,13 +1,14 @@
1
1
  module JumioRock
2
2
  class Client
3
3
  attr_reader :authorization_token
4
- attr_accessor :api_url, :init_embed_url, :init_redirect_url, :multi_document_url
5
-
4
+ attr_accessor :api_url, :init_embed_url, :init_redirect_url, :multi_document_url, :retrieval_url
5
+
6
6
  def initialize
7
7
  @api_url = conf.api_url
8
8
  @init_embed_url = conf.init_embed_url
9
9
  @init_redirect_url = conf.init_redirect_url
10
10
  @multi_document_url = conf.multi_document_url
11
+ @retrieval_url = conf.retrieval_url
11
12
  @initialization_type = nil
12
13
  end
13
14
 
@@ -42,6 +43,12 @@ module JumioRock
42
43
  response
43
44
  end
44
45
 
46
+ def retrieve(scan_reference)
47
+ @initialization_type = :retrieveirb
48
+ url = File.join(retrieval_url, scan_reference.to_s).to_s
49
+ get(url)
50
+ end
51
+
45
52
  def iframe(locale = "en")
46
53
  iframe_html(locale, js_type)
47
54
  end
@@ -76,7 +83,7 @@ module JumioRock
76
83
 
77
84
  private
78
85
 
79
- def js_type
86
+ def js_type
80
87
  raise "Client not initialized (init_embed or init_multidocument)" unless @initialization_type
81
88
  @initialization_type == :multi ? "initMDM" : "initVerify"
82
89
  end
@@ -98,12 +105,23 @@ module JumioRock
98
105
  OpenStruct.new JSON.parse(response.body)
99
106
  end
100
107
 
108
+ def get(url)
109
+ connection = Excon.new(url, user: conf.api_token, password: conf.api_secret)
110
+
111
+ response = connection.request(
112
+ method: 'GET',
113
+ headers: headers
114
+ )
115
+
116
+ OpenStruct.new JSON.parse(response.body)
117
+ end
118
+
101
119
  def conf
102
120
  Configuration.configuration
103
121
  end
104
122
 
105
123
  def headers
106
- {
124
+ {
107
125
  'Accept' => 'application/json',
108
126
  'Content-Type' => 'application/json',
109
127
  'User-Agent' => "#{conf.company_name} #{conf.app_name}/#{conf.version}"
@@ -111,4 +129,4 @@ module JumioRock
111
129
  end
112
130
 
113
131
  end
114
- end
132
+ end
@@ -1,6 +1,7 @@
1
1
  module JumioRock
2
2
  class Configuration
3
- attr_accessor :app_name, :company_name, :version, :api_url, :api_token, :api_secret, :init_redirect_url, :init_embed_url, :multi_document_url
3
+ attr_accessor :app_name, :company_name, :version, :api_url, :api_token, :api_secret, :init_redirect_url, :init_embed_url, :multi_document_url,
4
+ :retrieval_url
4
5
 
5
6
  def initialize
6
7
  self.company_name = 'YOURCOMPANYNAME'
@@ -10,6 +11,7 @@ module JumioRock
10
11
  self.init_redirect_url = "https://netverify.com/api/netverify/v2/initiateNetverifyRedirect"
11
12
  self.init_embed_url = "https://netverify.com/api/netverify/v2/initiateNetverify"
12
13
  self.multi_document_url = "https://netverify.com/api/netverify/v2/createDocumentAcquisition"
14
+ self.retrieval_url = "https://netverify.com/api/netverify/v2/scans"
13
15
  end
14
16
 
15
17
  def self.configuration
@@ -21,4 +23,4 @@ module JumioRock
21
23
  end
22
24
 
23
25
  end
24
- end
26
+ end
@@ -1,3 +1,3 @@
1
1
  module JumioRock
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -56,6 +56,16 @@ describe JumioRock::Client do
56
56
  assert_equal response.clientRedirectUrl, "https://[your-domain-prefix].netverify.com/v2?authorizationToken=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
57
57
  end
58
58
 
59
+ it 'retrieve scan status' do
60
+ stub_retrieval_request
61
+
62
+ client = JumioRock::Client.new
63
+ response = client.retrieve("scan_id")
64
+
65
+ assert_equal response.scanReference, "scan_id"
66
+ assert_equal response.status, "DONE"
67
+ end
68
+
59
69
  it "success response" do
60
70
  params = parse_post(success_api_response)
61
71
  pp = JumioRock::PostParser.new(params)
@@ -46,6 +46,12 @@ def stub_redirect_request
46
46
  to_return(:status => 200, :body => json_redirect_response, :headers => {})
47
47
  end
48
48
 
49
+ def stub_retrieval_request
50
+ stub_request(:get, "https://username:password@netverify.com/api/netverify/v2/scans/scan_id").
51
+ with(headers: {'Accept'=>'application/json', 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=', 'Content-Type'=>'application/json', 'Host'=>'netverify.com:443', 'User-Agent'=>"YOURCOMPANYNAME YOURAPPLICATIONNAME/#{JumioRock::VERSION}"}).
52
+ to_return(:status => 200, :body => json_retrieval_response, :headers => {})
53
+ end
54
+
49
55
  def jumio_conf
50
56
  JumioRock::Configuration.configuration
51
57
  end
@@ -90,6 +96,16 @@ def json_redirect_response
90
96
  EOF
91
97
  end
92
98
 
99
+ def json_retrieval_response
100
+ <<-EOF
101
+ {
102
+ "timestamp": "2014-08-13T12:08:02.068Z",
103
+ "scanReference": "scan_id",
104
+ "status": "DONE"
105
+ }
106
+ EOF
107
+ end
108
+
93
109
  def success_api_response
94
110
  "idExpiry=2022-12-31&idType=PASSPORT&idDob=1990-01-01&idCheckSignature=OK&idCheckDataPositions=OK&idCheckHologram=OK&idCheckMicroprint=OK&idCheckDocumentValidation=OK&idCountry=USA&idScanSource=WEB_UPLOAD&idFirstName=FIRSTNAME&verificationStatus=APPROVED_VERIFIED&jumioIdScanReference=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&personalNumber=N%2FA&merchantIdScanReference=YOURIDSCANREFERENCE&idCheckSecurityFeatures=OK&idCheckMRZcode=OK&idScanImage=https%3A%2F%2Fnetverify.com%2Frecognition%2Fv1%2Fidscan%2Fxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx%2Ffront&callBackType=NETVERIFYID&clientIp=xxx.xxx.xxx.xxx&idLastName=LASTNAME&idAddress=%7B%22country%22%3A%22USA%22%2C%22state%22%3A%22OH%22%7D&idScanStatus=SUCCESS&idNumber=P1234"
95
111
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jumio_rock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michele Minazzato
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-05 00:00:00.000000000 Z
11
+ date: 2016-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon