Skip to content

Commit

Permalink
Merge pull request #8 from alice-biometrics/feature/add-document-source
Browse files Browse the repository at this point in the history
Add optional argument source to add_document
  • Loading branch information
fgsalomon authored Jul 16, 2020
2 parents c164ba1 + feb3837 commit f50d3fe
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions alice/onboarding/document_source.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from enum import Enum


class DocumentSource(Enum):
file = "file"
camera = "camera"
5 changes: 5 additions & 0 deletions alice/onboarding/onboarding.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from meiga import Result, Success, Failure, isSuccess

from alice.config import Config
from alice.onboarding.document_source import DocumentSource
from alice.onboarding.onboarding_errors import OnboardingError
from alice.onboarding.user_info import UserInfo
from alice.onboarding.device_info import DeviceInfo
Expand Down Expand Up @@ -518,6 +519,7 @@ def add_document(
media_data: bytes,
side: str,
manual: bool = False,
source: DocumentSource = None,
fields: dict = None,
verbose: bool = False,
) -> Result[bool, OnboardingError]:
Expand All @@ -537,6 +539,8 @@ def add_document(
Side of the document [front, back or internal]
manual
If True defines manual document uploading
source
Source of the media: camera or file
fields
Fields to add regardless of the OCR process
verbose
Expand All @@ -554,6 +558,7 @@ def add_document(
media_data=media_data,
side=side,
manual=manual,
source=source,
fields=fields,
verbose=verbose,
)
Expand Down
7 changes: 7 additions & 0 deletions alice/onboarding/onboarding_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from requests import request, Response

from alice.auth.auth import Auth
from alice.onboarding.document_source import DocumentSource
from alice.onboarding.tools import timeit, print_intro, print_response, print_token

from alice.onboarding.user_info import UserInfo
Expand Down Expand Up @@ -542,6 +543,7 @@ def add_document(
media_data: bytes,
side: str,
manual: bool = False,
source: DocumentSource = None,
fields: dict = None,
verbose: bool = False,
) -> Response:
Expand All @@ -562,6 +564,8 @@ def add_document(
Side of the document [front or back]
manual
If True defines manual document uploading
source
Source of the media: camera or file
fields
Fields to add regardless of the OCR process
verbose
Expand All @@ -585,6 +589,9 @@ def add_document(
"fields": json.dumps(fields),
}

if source:
data["source"] = source.value

files = {"image": ("image", media_data)}

response = request(
Expand Down

0 comments on commit f50d3fe

Please sign in to comment.