Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions example/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from regula.documentreader.webclient import *

host = os.getenv("API_BASE_PATH", "https://api.regulaforensics.com")
regula_license = os.getenv("TEST_LICENSE", None) # optional, used here only for smoke test purposes

# read optional local license file
if os.path.isfile('regula.license') and os.access('regula.license', os.R_OK):
Expand All @@ -21,15 +20,14 @@
uv_page_0 = f.read()

with DocumentReaderApi(host) as api:
api.license = regula_license
api.api_client.default_headers = {
"X-CLIENT-KEY": "123",
"Authorization": "Bearer 123"
}
params = ProcessParams(already_cropped=True, scenario=Scenario.FULL_PROCESS)

# Add license to request
# request = RecognitionRequest(system_info=ProcessSystemInfo(license="license"), process_params=params, images=[
# request = RecognitionRequest(system_info=ProcessSystemInfo(license=base64.b64encode(regula_license).decode()), process_params=params, images=[
# RecognitionImage(image=white_page_0, light_index=Light.WHITE, page_index=0),
# ])

Expand Down
16 changes: 0 additions & 16 deletions regula/documentreader/webclient/ext/api/document_reader_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,9 @@ def __init__(self, host=None, debug=False, verify_ssl=True, api_client=None):
configuration = Configuration(host=host)
configuration.debug = debug
configuration.verify_ssl = verify_ssl

self.api_client = ApiClient(configuration=configuration)

super().__init__(self.api_client)

self.__license = None

def __enter__(self):
return self

Expand All @@ -36,19 +32,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
def set_configuration(self, configuration) -> None:
self.api_client.configuration = configuration

@property
def license(self) -> Base64String:
return self.__license

@license.setter
def license(self, value: Union[Base64String, bytes]):
if isinstance(value, bytes):
self.__license = base64.b64encode(value).decode("utf-8")
else:
self.__license = value

def process(self, process_request: ProcessRequest) -> RecognitionResponse:
process_request.system_info.license = self.license
return RecognitionResponse(self.api_process(process_request))

def deserialize_to_recognition_response(self, content: Union[bytes, bytearray, str]) -> RecognitionResponse:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,17 @@ def __init__(
else:
input_images.append(image)
super().__init__(
process_param=process_params, list=input_images,
system_info=system_info, tag=tag
process_param=process_params,
list=input_images,
system_info=system_info,
tag=tag
)
if container_list:
super().__init__(
process_param=process_params, container_list=container_list,
system_info=system_info, tag=tag
process_param=process_params,
container_list=container_list,
system_info=system_info,
tag=tag
)

@property
Expand Down
Loading