|
| 1 | +from typing import TypedDict, Optional, Literal, List, Dict |
| 2 | + |
| 3 | +from method.resource import MethodResponse, Resource |
| 4 | +from method.configuration import Configuration |
| 5 | + |
| 6 | +OpalModesLiterals = Literal[ |
| 7 | + 'identity_verification', |
| 8 | + 'connect', |
| 9 | + 'card_connect', |
| 10 | + 'account_verification', |
| 11 | + 'transactions' |
| 12 | +] |
| 13 | + |
| 14 | + |
| 15 | +SkipPIILiterals = Literal[ |
| 16 | + 'name', |
| 17 | + 'dob', |
| 18 | + 'address', |
| 19 | + 'ssn_4' |
| 20 | +] |
| 21 | + |
| 22 | + |
| 23 | +AccountFiltersAccountTypesLiterals = Literal[ |
| 24 | + 'credit_card', |
| 25 | + 'auto_loan', |
| 26 | + 'mortgage', |
| 27 | + 'personal_loan', |
| 28 | + 'student_loan' |
| 29 | +] |
| 30 | + |
| 31 | + |
| 32 | +SelectionTypeLiterals = Literal['single', 'multiple', 'all'] |
| 33 | + |
| 34 | + |
| 35 | +class OpalAccountFiltersInclude(TypedDict): |
| 36 | + account_types: List[AccountFiltersAccountTypesLiterals] |
| 37 | + |
| 38 | + |
| 39 | +class OpalAccountFiltersExclude(TypedDict): |
| 40 | + account_types: List[AccountFiltersAccountTypesLiterals] |
| 41 | + mch_ids: List[str] |
| 42 | + unverified_account_numbers: bool |
| 43 | + |
| 44 | + |
| 45 | +class ConnectAccountFilters(TypedDict): |
| 46 | + include: OpalAccountFiltersInclude |
| 47 | + exclude: OpalAccountFiltersExclude |
| 48 | + |
| 49 | + |
| 50 | +class CardConnectAccountFiltersExclude(TypedDict): |
| 51 | + mch_ids: List[str] |
| 52 | + unverified_account_numbers: bool |
| 53 | + |
| 54 | + |
| 55 | +class CardConnectAccountFilters(TypedDict): |
| 56 | + exclude: CardConnectAccountFiltersExclude |
| 57 | + |
| 58 | + |
| 59 | +class OpalIdentityVerificationCreateOpts(TypedDict): |
| 60 | + skip_pii: List[SkipPIILiterals] |
| 61 | + |
| 62 | + |
| 63 | +class OpalConnectCreateOpts(TypedDict): |
| 64 | + skip_pii: List[SkipPIILiterals] |
| 65 | + selection_type: SelectionTypeLiterals |
| 66 | + account_filters: ConnectAccountFilters |
| 67 | + |
| 68 | + |
| 69 | +class OpalCardConnectCreateOpts(TypedDict): |
| 70 | + skip_pii: List[SkipPIILiterals] |
| 71 | + selection_type: SelectionTypeLiterals |
| 72 | + account_filters: CardConnectAccountFilters |
| 73 | + |
| 74 | + |
| 75 | +class OpalAccountVerificationCreateOpts(TypedDict): |
| 76 | + account_id: str |
| 77 | + |
| 78 | + |
| 79 | +class OpalTransactionsCreateOpts(TypedDict): |
| 80 | + transactions: Dict[str, any] |
| 81 | + |
| 82 | + |
| 83 | +class OpalTokenCreateOpts(TypedDict): |
| 84 | + mode: OpalModesLiterals |
| 85 | + entity_id: str |
| 86 | + identity_verification: Optional[OpalIdentityVerificationCreateOpts] |
| 87 | + connect: Optional[OpalConnectCreateOpts] |
| 88 | + card_connect: Optional[OpalCardConnectCreateOpts] |
| 89 | + account_verification: Optional[OpalAccountVerificationCreateOpts] |
| 90 | + transactions: Optional[OpalTransactionsCreateOpts] |
| 91 | + |
| 92 | + |
| 93 | +class OpalToken(TypedDict): |
| 94 | + token: str |
| 95 | + valid_until: str |
| 96 | + session_id: str |
| 97 | + |
| 98 | + |
| 99 | +class OpalTokenResource(Resource): |
| 100 | + def __init__(self, config: Configuration): |
| 101 | + super(OpalTokenResource, self).__init__(config.add_path('token')) |
| 102 | + |
| 103 | + def create(self, opts: OpalTokenCreateOpts) -> MethodResponse[OpalToken]: |
| 104 | + return super(OpalTokenResource, self)._create(opts) |
0 commit comments