Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,41 @@


class DeclaredData:
"""The personal details provided by the applicant.

Maps IdvDeclaredData. The identity verification requests take the larger
IdvIdentityDeclaredData shape and keep their own copy of this class.
"""
# The applicant's name.
# [Required]
# min 2 characters, max 255 characters
# Example: Hannah Bret
name: str
# The applicant's birth date.
# [Optional]
# Format: yyyy-MM-dd
# Example: 1994-10-15
birth_date: str


class AddressDocumentVerificationRequest:
"""Request body for POST /address-document-verifications."""
# The applicant's unique identifier.
# [Required]
# ^aplt_\w+$
applicant_id: str
# Your configuration ID.
# [Required]
# ^usj_[a-z2-7]{26}$
user_journey_id: str
# The personal details provided by the applicant.
# [Optional]
declared_data: DeclaredData


class AddressDocumentVerificationAttemptRequest:
"""Request body for POST /address-document-verifications/{id}/attempts."""
# The address document image to verify, as a binary upload.
# [Required]
# Format: binary
document: str
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from checkout_sdk.authorization_type import AuthorizationType
from checkout_sdk.checkout_configuration import CheckoutConfiguration
from checkout_sdk.client import Client
from checkout_sdk.identities.entities import AttemptAssetsQueryFilter, AttemptsQueryFilter
from checkout_sdk.identities.addressdocumentverification.addressdocumentverification import (
AddressDocumentVerificationRequest, AddressDocumentVerificationAttemptRequest
)
Expand All @@ -14,50 +15,133 @@ class AddressDocumentVerificationClient(Client):
__ANONYMIZE_PATH = 'anonymize'
__ATTEMPTS_PATH = 'attempts'
__PDF_REPORT_PATH = 'pdf-report'
__ASSETS_PATH = 'assets'

def __init__(self, api_client: ApiClient, configuration: CheckoutConfiguration):
super().__init__(api_client=api_client,
configuration=configuration,
authorization_type=AuthorizationType.SECRET_KEY_OR_OAUTH)

def create_address_document_verification(self, request: AddressDocumentVerificationRequest):
"""Create an address document verification.
Beta.

Args:
request: The address document verification to create.
Returns:
ResponseWrapper with the created verification.
"""
return self._api_client.post(self.__ADDRESS_DOCUMENT_VERIFICATIONS_PATH,
self._sdk_authorization(),
request)

def get_address_document_verification(self, address_document_verification_id: str):
"""Get the details of an address document verification.
Beta.

Args:
address_document_verification_id: The address document verification's unique identifier.
Returns:
ResponseWrapper with the verification details.
"""
return self._api_client.get(
self.build_path(self.__ADDRESS_DOCUMENT_VERIFICATIONS_PATH, address_document_verification_id),
self._sdk_authorization())

def anonymize_address_document_verification(self, address_document_verification_id: str):
"""Anonymize an address document verification and its attempts.
Beta.

Args:
address_document_verification_id: The address document verification's unique identifier.
Returns:
ResponseWrapper with the anonymized verification.
"""
return self._api_client.post(
self.build_path(self.__ADDRESS_DOCUMENT_VERIFICATIONS_PATH, address_document_verification_id,
self.__ANONYMIZE_PATH),
self._sdk_authorization())

def create_address_document_verification_attempt(self, address_document_verification_id: str,
request: AddressDocumentVerificationAttemptRequest):
"""Create an attempt for an address document verification, uploading the document image.
Beta.

Args:
address_document_verification_id: The address document verification's unique identifier.
request: The attempt to create, carrying the document image.
Returns:
ResponseWrapper with the created attempt.
"""
return self._api_client.post(
self.build_path(self.__ADDRESS_DOCUMENT_VERIFICATIONS_PATH, address_document_verification_id,
self.__ATTEMPTS_PATH),
self._sdk_authorization(),
request)

def get_address_document_verification_attempts(self, address_document_verification_id: str):
def get_address_document_verification_attempts(self, address_document_verification_id: str,
query: AttemptsQueryFilter = None):
"""Get the details of all attempts for a specific address document verification.

Results are paginated. Beta.

Args:
address_document_verification_id: The address document verification's unique identifier.
query: Optional skip and limit pagination parameters.
Returns:
ResponseWrapper with the paginated attempt list.
"""
return self._api_client.get(
self.build_path(self.__ADDRESS_DOCUMENT_VERIFICATIONS_PATH, address_document_verification_id,
self.__ATTEMPTS_PATH),
self._sdk_authorization())
self._sdk_authorization(),
query)

def get_address_document_verification_attempt(self, address_document_verification_id: str, attempt_id: str):
"""Get the details of a single address document verification attempt.
Beta.

Args:
address_document_verification_id: The address document verification's unique identifier.
attempt_id: The attempt's unique identifier.
Returns:
ResponseWrapper with the attempt details.
"""
return self._api_client.get(
self.build_path(self.__ADDRESS_DOCUMENT_VERIFICATIONS_PATH, address_document_verification_id,
self.__ATTEMPTS_PATH, attempt_id),
self._sdk_authorization())

def get_address_document_verification_report(self, address_document_verification_id: str):
"""Get the PDF report for an address document verification.
Beta.

Args:
address_document_verification_id: The address document verification's unique identifier.
Returns:
ResponseWrapper carrying pdf_report, the pre-signed URL to the PDF.
"""
return self._api_client.get(
self.build_path(self.__ADDRESS_DOCUMENT_VERIFICATIONS_PATH, address_document_verification_id,
self.__PDF_REPORT_PATH),
self._sdk_authorization())

def get_address_document_verification_attempt_assets(self, address_document_verification_id: str,
attempt_id: str,
query: AttemptAssetsQueryFilter = None):
"""Get the assets (the document image) uploaded for an address document verification attempt.

Results are paginated. Beta.

Args:
address_document_verification_id: The address document verification's unique identifier.
attempt_id: The attempt's unique identifier.
query: Optional skip and limit pagination parameters.
Returns:
ResponseWrapper with the paginated asset list.
"""
return self._api_client.get(
self.build_path(self.__ADDRESS_DOCUMENT_VERIFICATIONS_PATH, address_document_verification_id,
self.__ATTEMPTS_PATH, attempt_id, self.__ASSETS_PATH),
self._sdk_authorization(),
query)
90 changes: 90 additions & 0 deletions checkout_sdk/identities/entities.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,93 @@
from __future__ import absolute_import

from enum import Enum


class IdvDocumentType(str, Enum):
"""The type of identity document, for the identity verification endpoints.

Deliberately separate from checkout_sdk.common.enums.DocumentType, which the accounts
endpoints use. The two share no values and even spell the licence differently: accounts sends
'driving_license', identity verification sends 'Driving licence'. Modelling them as one type
would send values the API rejects.
"""
DRIVING_LICENCE = 'Driving licence'
ID = 'ID'
OTHER = 'Other'
PASSPORT = 'Passport'
RESIDENCE_PERMIT = 'Residence Permit'
TRAVEL_DOCUMENT = 'Travel Document'
VISA = 'Visa'


class AttemptsQueryFilter:
"""Pagination for the list-attempts endpoints."""
# The number of attempts to skip.
# [Optional]
# Default: 0
skip: int
# The maximum number of attempts to return.
# [Optional]
# Default: 10
limit: int


class AttemptAssetsQueryFilter:
"""Pagination for the attempt-assets endpoints."""
# The number of assets to skip.
# [Optional]
# Default: 0
skip: int
# The maximum number of assets to return.
# [Optional]
# Default: 10
limit: int


class PhoneNumber:
"""The applicant's mobile phone number, if sharing the attempt URL via SMS."""
# The international phone country code. This is a dialling prefix, not an ISO country code.
# [Required]
# ^\+(\d+)$
# Example: +33
country_code: str
# The applicant's mobile number, without the country code.
# [Required]
# ^\d{1,14}$
# Example: 5555550102
number: str


class IdvAddress:
"""The applicant's address."""
# The first line of the address.
# [Optional]
# max 250 characters
# Example: 123 Main Street
address_line1: str
# The second line of the address.
# [Optional]
# max 250 characters
# Example: Apt 4B
address_line2: str
# The city or town.
# [Optional]
# max 50 characters
# Example: London
city: str
# The state, county, or province.
# [Optional]
# max 50 characters
# Example: Greater London
state: str
# The postal or ZIP code.
# [Optional]
# max 50 characters
# Example: SW1A 1AA
zip: str
# The two-letter ISO country code of the address.
# [Optional]
# Standard: ISO 3166-1 alpha-2 country code
# max 2 characters
# Example: GB
country: str
32 changes: 32 additions & 0 deletions checkout_sdk/identities/faceauthentication/faceauthentication.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,48 @@
from __future__ import absolute_import

from checkout_sdk.identities.entities import PhoneNumber


class ClientInformation:
"""The applicant's details for a face authentication attempt.

Maps FavClientInformation. Deliberately smaller than the identity verification copy in
checkout_sdk.identities.identityverification: the face authentication attempt schema does not
declare pre_selected_document_issuing_country or pre_selected_document_type, so sending them
here would be a request the API rejects.
"""
# The applicant's residence country.
# [Optional]
# Standard: ISO 3166-1 alpha-2 country code
# ^[A-Z]{2}
# Example: FR
pre_selected_residence_country: str
# The language you want to use for the user interface.
# [Optional]
# Format: IETF BCP 47 language tag
# Example: en-US
pre_selected_language: str


class FaceAuthenticationRequest:
"""Request body for POST /face-authentications."""
# The applicant's unique identifier.
# [Required]
applicant_id: str
# Your configuration ID.
# [Optional]
user_journey_id: str


class FaceAuthenticationAttemptRequest:
"""Request body for POST /face-authentications/{id}/attempts."""
# The URL to redirect the applicant to after the attempt.
# [Required]
# Format: uri
redirect_url: str
# The applicant's mobile phone number, if sharing the attempt URL via SMS.
# [Optional]
phone_number: PhoneNumber
# The applicant's details.
# [Optional]
client_information: ClientInformation
Loading
Loading