From e7a3ece3e7b7466d00a76544b3de2f3f4f84525e Mon Sep 17 00:00:00 2001 From: AlexViquez Date: Wed, 7 Sep 2022 17:07:20 -0500 Subject: [PATCH 1/5] draft bank account validation --- cuenca/resources/bank_account_validation.py | 70 +++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 cuenca/resources/bank_account_validation.py diff --git a/cuenca/resources/bank_account_validation.py b/cuenca/resources/bank_account_validation.py new file mode 100644 index 00000000..38bfb8af --- /dev/null +++ b/cuenca/resources/bank_account_validation.py @@ -0,0 +1,70 @@ +import datetime as dt +from typing import ClassVar, Optional, cast + +from cuenca_validations.types import ( + BankAccountStatus, + BankAccountValidationRequest, + CurpField, + Rfc, +) + +from ..http import Session, session as global_session +from .base import Creatable, Retrievable + + +class BankAccountValidation(Creatable, Retrievable): + _resource: ClassVar = 'bank_account_validations' + + created_at: dt.datetime + account_number: Optional[str] = None + account_holder: Optional[str] = None + bank_code: Optional[str] = None + status: Optional[BankAccountStatus] = None + curp: Optional[CurpField] = None + rfc: Optional[Rfc] = None + + class Config: + fields = { + 'account_number': { + 'description': 'Account number for validation, can be CARD_NUMBER or CLABE' + }, + 'account_holder': { + 'description': 'The fullname of the owner from the account' + }, + 'bank_code': { + 'description': 'Code of the bank according to https://es.wikipedia.org/wiki/CLABE, this can ' + 'be retrived from our library https://github.com/cuenca-mx/clabe-python' + }, + 'status': { + 'description': 'Initial status is submitted, then if everthing its fine or not the status can be ' + 'succeeded or failed' + }, + } + schema_extra = { + 'example': { + 'id': 'CVNEUInh69SuKXXmK95sROwQ', + 'created_at': '2019-08-24T14:15:22Z', + 'account_number': '646180157098510917', + 'account_holder': 'Pedrito Sola', + 'bank_code': '90646', + 'status': 'succedded', + 'curp': 'GOCG650418HVZNML08', + 'rfc': 'GOCG650418HV9', + } + } + + @classmethod + def create( + cls, + account_number: str, + bank_code: str, + session: Session = global_session, + ) -> 'BankAccountValidation': + req = BankAccountValidationRequest( + account_number=account_number, + bank_code=bank_code, + ) + return cast( + 'BankAccountValidation', + cls._create(session=session, **req.dict()), + ) From 8dc298ee1bf30c12e80985f749f7098087977a38 Mon Sep 17 00:00:00 2001 From: AlexViquez Date: Wed, 7 Sep 2022 17:09:19 -0500 Subject: [PATCH 2/5] Line to long --- cuenca/resources/bank_account_validation.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cuenca/resources/bank_account_validation.py b/cuenca/resources/bank_account_validation.py index 38bfb8af..5f03c447 100644 --- a/cuenca/resources/bank_account_validation.py +++ b/cuenca/resources/bank_account_validation.py @@ -26,18 +26,20 @@ class BankAccountValidation(Creatable, Retrievable): class Config: fields = { 'account_number': { - 'description': 'Account number for validation, can be CARD_NUMBER or CLABE' + 'description': 'Account number for validation, ' + 'can be CARD_NUMBER or CLABE' }, 'account_holder': { 'description': 'The fullname of the owner from the account' }, 'bank_code': { - 'description': 'Code of the bank according to https://es.wikipedia.org/wiki/CLABE, this can ' - 'be retrived from our library https://github.com/cuenca-mx/clabe-python' + 'description': 'Code of the bank according to ' + 'https://es.wikipedia.org/wiki/CLABE, this can be retrived from our ' + 'library https://github.com/cuenca-mx/clabe-python' }, 'status': { - 'description': 'Initial status is submitted, then if everthing its fine or not the status can be ' - 'succeeded or failed' + 'description': 'Initial status is submitted, then if everthing ' + 'its fine or not the status can be succeeded or failed' }, } schema_extra = { From 95e6bb80af15c652fb52dcd92444e1a743b30fa7 Mon Sep 17 00:00:00 2001 From: AlexViquez Date: Wed, 7 Sep 2022 17:13:42 -0500 Subject: [PATCH 3/5] adding resource to init --- cuenca/resources/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cuenca/resources/__init__.py b/cuenca/resources/__init__.py index 3e4af59c..e43a9f6d 100644 --- a/cuenca/resources/__init__.py +++ b/cuenca/resources/__init__.py @@ -2,6 +2,7 @@ 'ApiKey', 'Account', 'Arpc', + 'BankAccountValidations', 'BalanceEntry', 'BillPayment', 'Card', @@ -41,6 +42,7 @@ from .api_keys import ApiKey from .arpc import Arpc from .balance_entries import BalanceEntry +from .bank_account_validations import BankAccountValidations from .bill_payments import BillPayment from .card_activations import CardActivation from .card_transactions import CardTransaction @@ -81,6 +83,7 @@ ApiKey, Account, Arpc, + BankAccountValidations, BalanceEntry, BillPayment, Card, From 22506b7edefe6daa55dcdec2aa50bd0f48e553e3 Mon Sep 17 00:00:00 2001 From: AlexViquez Date: Wed, 7 Sep 2022 17:15:29 -0500 Subject: [PATCH 4/5] other init --- cuenca/__init__.py | 2 ++ cuenca/resources/__init__.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cuenca/__init__.py b/cuenca/__init__.py index 6bb845d0..d10d5f64 100644 --- a/cuenca/__init__.py +++ b/cuenca/__init__.py @@ -4,6 +4,7 @@ 'Account', 'Arpc', 'BalanceEntry', + 'BankAccountValidations', 'BillPayment', 'Card', 'CardActivation', @@ -49,6 +50,7 @@ ApiKey, Arpc, BalanceEntry, + BankAccountValidations, BillPayment, Card, CardActivation, diff --git a/cuenca/resources/__init__.py b/cuenca/resources/__init__.py index e43a9f6d..65b57513 100644 --- a/cuenca/resources/__init__.py +++ b/cuenca/resources/__init__.py @@ -83,8 +83,8 @@ ApiKey, Account, Arpc, - BankAccountValidations, BalanceEntry, + BankAccountValidations, BillPayment, Card, CardActivation, From b06930036e14652f0577d5ac2e28e3d551c068ed Mon Sep 17 00:00:00 2001 From: rogeliolopez Date: Thu, 17 Nov 2022 18:24:50 -0600 Subject: [PATCH 5/5] Ajuste de model --- cuenca/resources/bank_account_validation.py | 79 +++++++++++---------- cuenca/version.py | 2 +- requirements.txt | 2 +- 3 files changed, 42 insertions(+), 41 deletions(-) diff --git a/cuenca/resources/bank_account_validation.py b/cuenca/resources/bank_account_validation.py index 5f03c447..1811b972 100644 --- a/cuenca/resources/bank_account_validation.py +++ b/cuenca/resources/bank_account_validation.py @@ -1,71 +1,72 @@ import datetime as dt from typing import ClassVar, Optional, cast +from clabe import Clabe from cuenca_validations.types import ( BankAccountStatus, + BankAccountValidationQuery, BankAccountValidationRequest, + Country, CurpField, + Gender, Rfc, + State, ) from ..http import Session, session as global_session -from .base import Creatable, Retrievable +from .base import Creatable, Queryable, Retrievable -class BankAccountValidation(Creatable, Retrievable): +class BankAccountValidation(Creatable, Retrievable, Queryable): _resource: ClassVar = 'bank_account_validations' + _query_params: ClassVar = BankAccountValidationQuery - created_at: dt.datetime - account_number: Optional[str] = None - account_holder: Optional[str] = None - bank_code: Optional[str] = None - status: Optional[BankAccountStatus] = None + updated_at: dt.datetime + status: BankAccountStatus + platform_id: str + clabe: Clabe + transfer_id: str + names: Optional[str] = None + first_surname: Optional[str] = None + second_surname: Optional[str] = None curp: Optional[CurpField] = None rfc: Optional[Rfc] = None + gender: Optional[Gender] = None + date_of_birth: Optional[dt.date] = None + state_of_birth: Optional[State] = None + nationality: Optional[Country] = None + country_of_birth: Optional[Country] = None class Config: - fields = { - 'account_number': { - 'description': 'Account number for validation, ' - 'can be CARD_NUMBER or CLABE' - }, - 'account_holder': { - 'description': 'The fullname of the owner from the account' - }, - 'bank_code': { - 'description': 'Code of the bank according to ' - 'https://es.wikipedia.org/wiki/CLABE, this can be retrived from our ' - 'library https://github.com/cuenca-mx/clabe-python' - }, - 'status': { - 'description': 'Initial status is submitted, then if everthing ' - 'its fine or not the status can be succeeded or failed' - }, - } schema_extra = { 'example': { - 'id': 'CVNEUInh69SuKXXmK95sROwQ', - 'created_at': '2019-08-24T14:15:22Z', - 'account_number': '646180157098510917', - 'account_holder': 'Pedrito Sola', - 'bank_code': '90646', - 'status': 'succedded', - 'curp': 'GOCG650418HVZNML08', - 'rfc': 'GOCG650418HV9', + 'id': 'BAbUFjZTUbR3Oqj3vvzHcwBg', + 'created_at': '2022-11-16T17:15:35.288128', + 'updated_at': '2022-11-16T17:15:35.288128', + 'status': 'succeeded', + 'platform_id': 'PT-123', + 'clabe': '127841000000000003', + 'transfer_id': 'TR-123', + 'names': 'José', + 'first_surname': 'López', + 'second_surname': 'Pérez', + 'curp': 'LOPJ900101HDFPRS04', + 'rfc': 'LOPJ9001016S5', + 'gender': 'male', + 'date_of_birth': '1990-01-01', + 'state_of_birth': 'DF', + 'nationality': 'MX', + 'country_of_birth': 'MX', } } @classmethod def create( cls, - account_number: str, - bank_code: str, + clabe: Clabe, session: Session = global_session, ) -> 'BankAccountValidation': - req = BankAccountValidationRequest( - account_number=account_number, - bank_code=bank_code, - ) + req = BankAccountValidationRequest(clabe=clabe) return cast( 'BankAccountValidation', cls._create(session=session, **req.dict()), diff --git a/cuenca/version.py b/cuenca/version.py index 2767bf41..3afd6383 100644 --- a/cuenca/version.py +++ b/cuenca/version.py @@ -1,3 +1,3 @@ -__version__ = '0.15.4' +__version__ = '0.15.5.dev0' CLIENT_VERSION = __version__ API_VERSION = '2020-03-19' diff --git a/requirements.txt b/requirements.txt index 95312c7c..17945b23 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ requests==2.27.1 -cuenca-validations==0.11.11 +cuenca-validations==0.11.12.dev2 dataclasses>=0.7;python_version<"3.7"