Skip to content

Commit 49438ff

Browse files
Fix examples
1 parent ba85aab commit 49438ff

29 files changed

+220
-127
lines changed

Pipfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name = "pypi"
77
certifi = ">=2024.07.04"
88
six = ">=1.10"
99
python-dateutil = ">=2.8.2"
10-
urllib3 = ">= 1.25.3, < 3.0.0"
10+
urllib3 = ">=1.25.3, <3.0.0"
1111
vistir = ">=0.4.0, <=0.6.1"
1212
idna = "==3.7"
1313
requests = ">=2.32.3"

Pipfile.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/example-rcl.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
api.license = regula_license
2323

2424
params = ProcessParams(
25-
scenario=Scenario.FULL_PROCESS,
26-
result_type_output=[
25+
scenario=Scenario.FULLPROCESS,
26+
resultTypeOutput=[
2727
# actual results
2828
Result.STATUS, Result.AUTHENTICITY, Result.TEXT, Result.IMAGES,
2929
Result.DOCUMENT_TYPE, Result.DOCUMENT_TYPE_CANDIDATES, Result.IMAGE_QUALITY,
@@ -36,10 +36,7 @@
3636
)
3737
request = RecognitionRequest(
3838
process_params=params,
39-
container_list=ContainerList([
40-
LicenseRequest(license_),
41-
EncryptedRCLRequest(encrypted_rcl)
42-
])
39+
container_list=ContainerList(List = [LicenseRequest(license_), EncryptedRCLRequest(encrypted_rcl)])
4340
)
4441
response = api.process(request)
4542

example/example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
])
3939
response = api.process(request)
4040

41-
request_json = request.json # example for request & response raw json
42-
response_json = response.json
41+
request_json = request.to_json() # example for request & response raw json
42+
response_json = response.to_json()
4343

4444
# status examples
4545
response_status = response.status
Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,93 @@
11
from typing import Optional
22

3-
from regula.documentreader.webclient import gen, AuthenticityResultType
3+
from regula.documentreader.webclient.gen.models import AuthenticityCheckList as GenAuthenticityCheckList
4+
from regula.documentreader.webclient.gen.models import AuthenticityResultType, AuthenticityCheckResult
45
from regula.documentreader.webclient.ext.models.authenticity.fiber import FiberChecks
56
from regula.documentreader.webclient.ext.models.authenticity.ident import IdentChecks
67
from regula.documentreader.webclient.ext.models.authenticity.image_ident import ImageIdentChecks
78
from regula.documentreader.webclient.ext.models.authenticity.ocr_security_text import OCRSecurityTextChecks
89
from regula.documentreader.webclient.ext.models.authenticity.security_feature import SecurityFeatureChecks
910

1011

11-
class AuthenticityCheckList(gen.AuthenticityCheckList):
12+
class AuthenticityCheckList(GenAuthenticityCheckList):
1213

1314
@property
1415
def uv_luminescence_checks(self) -> Optional[SecurityFeatureChecks]:
15-
return self.__result_by_type(AuthenticityResultType.UV_LUMINESCENCE, SecurityFeatureChecks)
16+
result = self.__result_by_type(AuthenticityResultType.UV_LUMINESCENCE)
17+
return SecurityFeatureChecks.from_dict(result.to_dict())
1618

1719
@property
1820
def ir_b900_checks(self) -> Optional[SecurityFeatureChecks]:
19-
return self.__result_by_type(AuthenticityResultType.IR_B900, SecurityFeatureChecks)
21+
result = self.__result_by_type(AuthenticityResultType.IR_B900)
22+
return SecurityFeatureChecks.from_dict(result.to_dict())
2023

2124
@property
2225
def image_pattern_checks(self) -> Optional[IdentChecks]:
23-
return self.__result_by_type(AuthenticityResultType.IMAGE_PATTERN, IdentChecks)
26+
result = self.__result_by_type(AuthenticityResultType.IMAGE_PATTERN)
27+
return IdentChecks.from_dict(result.to_dict())
2428

2529
@property
2630
def axial_protection_checks(self) -> Optional[SecurityFeatureChecks]:
27-
return self.__result_by_type(AuthenticityResultType.AXIAL_PROTECTION, SecurityFeatureChecks)
31+
result = self.__result_by_type(AuthenticityResultType.AXIAL_PROTECTION)
32+
return SecurityFeatureChecks.from_dict(result.to_dict())
2833

2934
@property
3035
def uv_fiber_checks(self) -> Optional[FiberChecks]:
31-
return self.__result_by_type(AuthenticityResultType.UV_FIBERS, FiberChecks)
36+
result = self.__result_by_type(AuthenticityResultType.UV_FIBERS)
37+
return FiberChecks.from_dict(result.to_dict())
3238

3339
@property
3440
def ir_visibility_checks(self) -> Optional[IdentChecks]:
35-
return self.__result_by_type(AuthenticityResultType.IR_VISIBILITY, IdentChecks)
41+
result = self.__result_by_type(AuthenticityResultType.IR_VISIBILITY)
42+
return IdentChecks.from_dict(result.to_dict())
3643

3744
@property
3845
def ocr_security_text_checks(self) -> Optional[OCRSecurityTextChecks]:
39-
return self.__result_by_type(AuthenticityResultType.OCR_SECURITY_TEXT, OCRSecurityTextChecks)
46+
result = self.__result_by_type(AuthenticityResultType.OCR_SECURITY_TEXT)
47+
return OCRSecurityTextChecks.from_dict(result.to_dict())
4048

4149
@property
4250
def ipi_checks(self) -> Optional[ImageIdentChecks]:
43-
return self.__result_by_type(AuthenticityResultType.IPI, ImageIdentChecks)
51+
result = self.__result_by_type(AuthenticityResultType.IPI)
52+
return ImageIdentChecks.from_dict(result.to_dict())
4453

4554
@property
4655
def embed_image_checks(self) -> Optional[SecurityFeatureChecks]:
47-
return self.__result_by_type(AuthenticityResultType.PHOTO_EMBED_TYPE, SecurityFeatureChecks)
56+
result = self.__result_by_type(AuthenticityResultType.PHOTO_EMBED_TYPE)
57+
return SecurityFeatureChecks.from_dict(result.to_dict())
4858

4959
@property
5060
def holograms_checks(self) -> Optional[SecurityFeatureChecks]:
51-
return self.__result_by_type(AuthenticityResultType.HOLOGRAMS, SecurityFeatureChecks)
61+
result = self.__result_by_type(AuthenticityResultType.HOLOGRAMS)
62+
return SecurityFeatureChecks.from_dict(result.to_dict())
5263

5364
@property
5465
def photo_area_checks(self) -> Optional[SecurityFeatureChecks]:
55-
return self.__result_by_type(AuthenticityResultType.PHOTO_AREA, SecurityFeatureChecks)
66+
result = self.__result_by_type(AuthenticityResultType.PHOTO_AREA)
67+
return SecurityFeatureChecks.from_dict(result.to_dict())
5668

5769
@property
5870
def portrait_comparison_checks(self) -> Optional[IdentChecks]:
59-
return self.__result_by_type(AuthenticityResultType.PORTRAIT_COMPARISON, IdentChecks)
71+
result = self.__result_by_type(AuthenticityResultType.PORTRAIT_COMPARISON)
72+
return IdentChecks.from_dict(result.to_dict())
6073

6174
@property
6275
def barcode_format_checks(self) -> Optional[SecurityFeatureChecks]:
63-
return self.__result_by_type(AuthenticityResultType.BARCODE_FORMAT_CHECK, SecurityFeatureChecks)
76+
result = self.__result_by_type(AuthenticityResultType.BARCODE_FORMAT_CHECK)
77+
return SecurityFeatureChecks.from_dict(result.to_dict())
6478

6579
@property
6680
def kinegram_checks(self) -> Optional[IdentChecks]:
67-
return self.__result_by_type(AuthenticityResultType.KINEGRAM, IdentChecks)
81+
result = self.__result_by_type(AuthenticityResultType.KINEGRAM)
82+
return IdentChecks.from_dict(result.to_dict())
6883

6984
@property
7085
def letter_screen_checks(self) -> Optional[IdentChecks]:
71-
return self.__result_by_type(AuthenticityResultType.LETTER_SCREEN, IdentChecks)
86+
result = self.__result_by_type(AuthenticityResultType.LETTER_SCREEN)
87+
return IdentChecks.from_dict(result.to_dict())
7288

73-
def __result_by_type(self, authenticity_type: int, parent_class: type) -> Optional[gen.AuthenticityCheckResult]:
89+
def __result_by_type(self, authenticity_type: int) -> Optional[AuthenticityCheckResult]:
7490
for result in self.list:
7591
if result.type == authenticity_type:
76-
result.__class__ = parent_class
7792
return result
7893
return None
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from typing import List
22

3-
from regula.documentreader.webclient import gen
3+
from regula.documentreader.webclient.gen.models import FiberResult, AuthenticityCheckResult
44

55

6-
class FiberChecks(gen.AuthenticityCheckResult):
6+
class FiberChecks(AuthenticityCheckResult):
77

88
@property
9-
def list(self) -> List[gen.FiberResult]:
9+
def list(self) -> List[FiberResult]:
1010
# noinspection PyTypeChecker
1111
return super().list
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
from typing import List, Optional
1+
from typing import List
22

3-
from regula.documentreader.webclient import gen
3+
from regula.documentreader.webclient.gen.models import AuthenticityCheckResult, IdentResult
44

55

6-
class IdentChecks(gen.AuthenticityCheckResult):
6+
class IdentChecks(AuthenticityCheckResult):
7+
78
@property
8-
def list(self) -> List[gen.IdentResult]:
9+
def list(self) -> List[IdentResult]:
910
# noinspection PyTypeChecker
10-
return super().list
11+
return self.list
1112

1213
# element_type is SecurityFeatureType
13-
def checks_by_element(self, element_type: int) -> List[gen.IdentResult]:
14+
def checks_by_element(self, element_type: int) -> List[IdentResult]:
1415
return [check for check in self.list if check.element_type == element_type]
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
from typing import List
22

3-
from regula.documentreader.webclient import gen
3+
from regula.documentreader.webclient.gen.models import AuthenticityCheckResult, PhotoIdentResult
44

55

6-
class ImageIdentChecks(gen.AuthenticityCheckResult):
6+
class ImageIdentChecks(AuthenticityCheckResult):
7+
78
@property
8-
def list(self) -> List[gen.PhotoIdentResult]:
9+
def list(self) -> List[PhotoIdentResult]:
910
# noinspection PyTypeChecker
10-
return super().list
11+
return self.list
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from typing import List
22

3-
from regula.documentreader.webclient import gen
3+
from regula.documentreader.webclient.gen.models import AuthenticityCheckResult, OCRSecurityTextResult
44

55

6-
class OCRSecurityTextChecks(gen.AuthenticityCheckResult):
6+
class OCRSecurityTextChecks(AuthenticityCheckResult):
77

88
@property
9-
def list(self) -> List[gen.OCRSecurityTextResult]:
9+
def list(self) -> List[OCRSecurityTextResult]:
1010
# noinspection PyTypeChecker
11-
return super().list
11+
return self.list
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
from typing import List, Optional
22

3-
from regula.documentreader.webclient import gen
3+
from regula.documentreader.webclient.gen.models import AuthenticityCheckResult, SecurityFeatureResult
44

55

6-
class SecurityFeatureChecks(gen.AuthenticityCheckResult):
6+
class SecurityFeatureChecks(AuthenticityCheckResult):
7+
78
@property
8-
def list(self) -> List[gen.SecurityFeatureResult]:
9-
return super().list
9+
def list(self) -> List[SecurityFeatureResult]:
10+
# noinspection PyTypeChecker
11+
return self.list
1012

1113
# element_type is SecurityFeatureType
12-
def checks_by_element(self, element_type: int) -> List[gen.SecurityFeatureResult]:
14+
def checks_by_element(self, element_type: int) -> List[SecurityFeatureResult]:
1315
return [check for check in self.list if check.element_type == element_type]

0 commit comments

Comments
 (0)