-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement send input action #12
base: refactoring
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from dataclasses import dataclass, field | ||
from dataclasses import asdict, dataclass, field | ||
from enum import Enum | ||
from typing import BinaryIO, Dict, List, Optional, Union | ||
|
||
|
@@ -13,21 +13,21 @@ class PageType(SerializableEnum): | |
back = 'back' | ||
|
||
|
||
class ValidationInputType(SerializableEnum): | ||
class VerificationInputType(SerializableEnum): | ||
document_photo = 'document-photo' | ||
selfie_photo = 'selfie-photo' | ||
selfie_video = 'selfie-video' | ||
|
||
|
||
class ValidationType(SerializableEnum): | ||
class DocumentType(SerializableEnum): | ||
driving_license = 'driving-license' | ||
national_id = 'national-id' | ||
passport = 'passport' | ||
proof_of_residency = 'proof-of-residency' | ||
|
||
|
||
@dataclass | ||
class VerificationDocumentStep: | ||
class VerificationStep: | ||
id: str | ||
status: int | ||
error: Optional[str] = None | ||
|
@@ -39,7 +39,7 @@ class VerificationDocument: | |
country: str | ||
region: str | ||
photos: List[str] | ||
steps: List[VerificationDocumentStep] | ||
steps: List[VerificationStep] | ||
type: str | ||
fields: Optional[dict] = None | ||
|
||
|
@@ -48,8 +48,8 @@ class VerificationDocument: | |
class UserValidationFile: | ||
filename: str | ||
content: BinaryIO | ||
input_type: Union[str, ValidationInputType] | ||
validation_type: Union[str, ValidationType] = '' | ||
input_type: Union[str, VerificationInputType] | ||
validation_type: Union[str, DocumentType] = '' | ||
country: str = '' # alpha-2 code: https://www.iban.com/country-codes | ||
region: str = '' # 2-digit US State code (if applicable) | ||
group: int = 0 | ||
|
@@ -60,20 +60,78 @@ class UserValidationFile: | |
|
||
IdentityMetadata = Union[dict, List[str]] | ||
|
||
|
||
@dataclass | ||
class MediaInputOptions: | ||
fieldName: str | ||
fileData: Union[BinaryIO, str] | ||
|
||
|
||
@dataclass | ||
class InputData: | ||
filename: str | ||
|
||
|
||
@dataclass | ||
class PhotoInputData(InputData): | ||
type: DocumentType | ||
page: PageType | ||
country: str | ||
region: str = None | ||
|
||
|
||
@dataclass | ||
class SelfieVideoInputData(InputData): | ||
pass | ||
|
||
|
||
@dataclass | ||
class SelfiePhotoInputData(InputData): | ||
pass | ||
|
||
|
||
class Input(dict): | ||
def __init__( | ||
self, | ||
input_type: VerificationInputType, | ||
data: Union[PhotoInputData, SelfiePhotoInputData, SelfieVideoInputData], | ||
group: int = None | ||
): | ||
if group is not None: | ||
dict.__init__( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. any reason not to use super() here and in the else branch? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I need to serialize this structure with |
||
self, | ||
input_type=input_type, | ||
data=asdict(data), | ||
group=group, | ||
) | ||
else: | ||
dict.__init__( | ||
self, | ||
input_type=input_type, | ||
data=asdict(data), | ||
) | ||
|
||
|
||
@dataclass | ||
class SendInputRequest: | ||
files: List[MediaInputOptions] | ||
inputs: List[Input] | ||
|
||
|
||
@dataclass | ||
class IdentityStatusTypes(SerializableEnum): | ||
deleted = 'deleted', | ||
pending = 'pending', | ||
rejected = 'rejected', | ||
review_needed = 'reviewNeeded', | ||
running = 'running', | ||
verified = 'verified', | ||
deleted = 'deleted', | ||
pending = 'pending', | ||
rejected = 'rejected', | ||
review_needed = 'reviewNeeded', | ||
running = 'running', | ||
verified = 'verified', | ||
|
||
|
||
@dataclass | ||
class IdentityResource: | ||
id: str | ||
status: IdentityStatusTypes | ||
id: str | ||
status: IdentityStatusTypes | ||
|
||
|
||
@dataclass | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
interactions: | ||
- request: | ||
body: null | ||
headers: | ||
Accept: | ||
- '*/*' | ||
Accept-Encoding: | ||
- gzip, deflate | ||
Connection: | ||
- keep-alive | ||
Content-Length: | ||
- '0' | ||
User-Agent: | ||
- python-requests/2.22.0 | ||
content-type: | ||
- application/x-www-form-urlencoded | ||
method: POST | ||
uri: https://api.getmati.com/oauth | ||
response: | ||
body: | ||
string: '{"access_token": "ACCESS_TOKEN", "expiresIn": 3600, "payload": {"user": | ||
{"_id": "ID"}}}' | ||
headers: | ||
Connection: | ||
- keep-alive | ||
Content-Length: | ||
- '452' | ||
Content-Type: | ||
- application/json; charset=utf-8 | ||
Date: | ||
- Thu, 26 Dec 2019 13:57:28 GMT | ||
X-Request-Id: | ||
- b4663380-a927-4564-ade7-df32249d9ac4 | ||
status: | ||
code: 200 | ||
message: OK | ||
- request: | ||
body: | ||
string: '' | ||
headers: | ||
Accept: | ||
- '*/*' | ||
Accept-Encoding: | ||
- gzip, deflate | ||
Connection: | ||
- keep-alive | ||
User-Agent: | ||
- python-requests/2.22.0 | ||
method: POST | ||
uri: https://api.getmati.com/v2/identities/identityId/send-input | ||
response: | ||
body: | ||
string: '[{"result":true},{"result":true},{"result":true}]' | ||
headers: | ||
Access-Control-Allow-Origin: | ||
- '*' | ||
Connection: | ||
- keep-alive | ||
Content-Length: | ||
- '23' | ||
Content-Type: | ||
- application/json; charset=utf-8 | ||
Date: | ||
- Thu, 26 Dec 2019 14:09:44 GMT | ||
Etag: | ||
- W/"8f-ejjPa5NRLKui634I0HWy1uDz4OE" | ||
Strict-Transport-Security: | ||
- max-age=31536000; includeSubDomains; preload | ||
X-Frame-Options: | ||
- SAMEORIGIN | ||
X-Powered-By: | ||
- Express | ||
X-Xss-Protection: | ||
- 1; mode=block | ||
status: | ||
code: 201 | ||
message: OK | ||
|
||
version: 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about this, does there any other way to not pass group if is None?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks ok. you can also add
group
key after initializing the required keys to avoid code duplication I guessThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I will have to add group property for every instance?