vchain_client 1.0.14 → 1.0.15

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 (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vchain_client.rb +31 -1
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bafd202de220a319373f61b7c67d9a82962a9646
4
- data.tar.gz: 99af50f58e81b259c6ae72501de871e922018f2b
3
+ metadata.gz: f7cee1ed6c6a5984dc6a2895676e516a9ec6eeaa
4
+ data.tar.gz: e6579fd0ab9f8d7460f7d46dd98f6b9625ba675a
5
5
  SHA512:
6
- metadata.gz: ba2a016b6fa357f4f32eed5f0dff857244a8a0a2bdda452a2cbc282c4dcb68a0afc3e2d7d684cb51cdebf1ec733a154aa696c5eb165af5ff92451e7bc2167efd
7
- data.tar.gz: 6690bdc4336482d4bafc5b0641c87f2cead67013356b3326e4e7309c078e8e4bffc8cee59b9a492067f974777e2c5ec4d7a746fa0774df9b72232a3ad90d1b71
6
+ metadata.gz: e94a3dd3e7327a2b007bf75588366ee8cbdd103f8f32cb356e1c6e31bb3e31d7c21f6391e27770919117df1fc46e95c5bc8facc99b875fd0dd7b6b34707c1f40
7
+ data.tar.gz: 2532de0a43e0de96ec538d27d1f13912fd0c33bb06aee3292789c765da8f8897cb8ad12cc51a8ecf2f74836b7f393a380899a4a97f73d480b73a496c9d47fd93
data/lib/vchain_client.rb CHANGED
@@ -46,6 +46,18 @@ module VChainClient
46
46
  }
47
47
  end
48
48
 
49
+ def get_credentials_fields(type)
50
+ if type == FIELD_TYPE_HASHED
51
+ return ["type", "citizenship", "number", "first_name", "last_name", "birthdate"]
52
+ end
53
+
54
+ if @log.error?
55
+ @log.error("[get_credentials_fields] unknown document type: '"+ type +"'")
56
+ end
57
+
58
+ return nil
59
+ end
60
+
49
61
  def get_credentials_hash(document)
50
62
  if document["type"] == FIELD_TYPE_HASHED
51
63
  what_to_hash = document["type"] + document["citizenship"] + document["number"] + document["first_name"] + document["last_name"] + document["birthdate"]
@@ -408,7 +420,25 @@ module VChainClient
408
420
  @log.debug("[check] recieved verifications")
409
421
  end
410
422
 
411
- credentials_hash = self.get_credentials_hash(document)
423
+ credentials_document = document
424
+
425
+ if res["status"] == "ERROR" || res["status"] == "error"
426
+ if res["error_reason_code"] == "DOCUMENT_POSSIBLE_MISTAKES"
427
+ credentials_document = {}
428
+
429
+ credentials_fields = self.get_credentials_fields(document["type"])
430
+
431
+ credentials_fields.each_with_index{ |field,index|
432
+ if document[field] != res_document["values"][field]
433
+ credentials_document[field] = res_document["values"][field]
434
+ else
435
+ credentials_document[field] = document[field]
436
+ end
437
+ }
438
+ end
439
+ end
440
+
441
+ credentials_hash = self.get_credentials_hash(credentials_document)
412
442
 
413
443
  if @log.debug?
414
444
  @log.debug("[check] credentials_hash: "+ credentials_hash)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vchain_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.14
4
+ version: 1.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aleksandr Gorelik