From b24796b959cfc364fe1504a13c835ad1d14ba9d2 Mon Sep 17 00:00:00 2001 From: Jose Guerrero Date: Tue, 19 May 2026 21:08:23 -0400 Subject: [PATCH 1/2] feat: implement basic and advanced user registration methods --- notbank_python_sdk/constants.py | 528 ++++++++++++++++++ notbank_python_sdk/core/endpoints.py | 3 + .../models/register_user_response.py | 8 + notbank_python_sdk/notbank_client.py | 31 + .../requests_models/__init__.py | 2 + .../register_advanced_user_request.py | 51 ++ .../register_basic_user_request.py | 50 ++ tests/test_register_advanced_user.py | 47 ++ tests/test_register_basic_user.py | 45 ++ 9 files changed, 765 insertions(+) create mode 100644 notbank_python_sdk/models/register_user_response.py create mode 100644 notbank_python_sdk/requests_models/register_advanced_user_request.py create mode 100644 notbank_python_sdk/requests_models/register_basic_user_request.py create mode 100644 tests/test_register_advanced_user.py create mode 100644 tests/test_register_basic_user.py diff --git a/notbank_python_sdk/constants.py b/notbank_python_sdk/constants.py index 84ccb77..ae28147 100644 --- a/notbank_python_sdk/constants.py +++ b/notbank_python_sdk/constants.py @@ -118,3 +118,531 @@ class QuoteOperation(IntEnum): BUY = 1 SELL = 2 CONVERSION = 3 + + +class Gender(IntEnum): + WOMAN = 0 + MAN = 1 + + +class IdentityType(IntEnum): + DNI = 1 + EXTRANJERO = 2 + NUIP = 3 + NIP = 4 + PEP = 5 + CC = 6 + CE = 7 + PASAPORTE = 8 + + +class Profession(str, Enum): + TRADER = "trader" + INVESTOR = "investor" + STUDENT = "student" + HOUSEWIFE = "housewife" + ACCOUNTANT = "accountant" + ACTOR_ACTRESS = "actor_actress" + AIR_HOSTESS = "air_hostess" + ARCHAEOLOGIST = "archaeologist" + ARCHITECT = "architect" + ASTRONAUT = "astronaut" + BAKER = "baker" + BIOLOGIST = "biologist" + BRICKLAYER = "bricklayer" + DRIVER = "driver" + BUSINESSMAN = "businessman" + BUTCHER = "butcher" + CARETAKER_JANITOR_PORTER = "caretaker_janitor_porter" + CARPENTER = "carpenter" + CASHIER = "cashier" + CLEANER = "cleaner" + CLOWN = "clown" + COBBLER = "cobbler" + COOK_CHEF = "cook_chef" + CHEMIST = "chemist" + DANCER = "dancer" + DECORATOR = "decorator" + DENTIST = "dentist" + DESIGNER = "designer" + PHYSICIAN = "physician" + DRESSMAKER = "dressmaker" + DUSTMAN = "dustman" + ECONOMIST = "economist" + ELECTRICIAN = "electrician" + ENGINEER = "engineer" + FARMER = "farmer" + FIREMAN = "fireman" + FISHERMAN = "fisherman" + FLORIST = "florist" + FRUITERER = "fruiterer" + GARDENER = "gardener" + GEOLOGIST = "geologist" + HAIRDRESSER = "hairdresser" + JEWELLER = "jeweller" + JOURNALIST = "journalist" + JUDGE = "judge" + LAWYER = "lawyer" + LIBRARIAN = "librarian" + LIFE_GUARD = "life_guard" + MAILMAN_POSTMAN = "mailman_postman" + MECHANIC = "mechanic" + METEOROLOGIST = "meteorologist" + CRYPTOCURRENCY_MINER = "cryptocurrency_miner" + MINERAL_MINER = "mineral_miner" + MODEL = "model" + NANNY_NURSEMAID = "nanny_nursemaid" + NUN = "nun" + NURSE = "nurse" + PAINTER = "painter" + PASTRY_COOK = "pastry_cook" + PHARMACIST = "pharmacist" + PHOTOGRAPHER = "photographer" + PHYSICIST = "physicist" + PLUMBER = "plumber" + POLICEMAN_POLICEWOMAN = "policeman_policewoman" + POLITICIAN = "politician" + PRIEST = "priest" + PROFESSOR_TEACHER = "professor_teacher" + PROGRAMMER = "programmer" + PSYCHIATRIST = "psychiatrist" + PSYCHOLOGIST = "psychologist" + RECEPTIONIST = "receptionist" + RESEARCHER_SCIENTIST = "researcher_scientist" + SAILOR = "sailor" + SALESMAN = "salesman" + SECRETARY = "secretary" + SHOP_ASSISTANT = "shop_assistant" + SINGER = "singer" + SOCIAL_WORKER = "social_worker" + SPORTSMAN = "sportsman" + SURGEON = "surgeon" + TAXI_DRIVER = "taxi_driver" + TELEPHONE_OPERATOR = "telephone_operator" + TRAVEL_AGENT = "travel_agent" + VETERINARIAN = "veterinarian" + WAITER_WAITRESS = "waiter_waitress" + WRITER = "writer" + DELIVERYMAN = "deliveryman" + UBER_DRIVER = "uber_driver" + PILOT = "pilot" + ADMINISTRATIVE = "administrative" + PUBLIC_SERVANT = "public_servant" + OTHER = "other" + CUSTOMER_CARE = "customer_care" + MILITARY = "military" + MANAGER_OFFICIER = "manager_officier" + + +class CivilStatus(str, Enum): + SOLTERO = "soltero" + CASADO = "casado" + CONVIVIENTE = "conviviente" + DIVORCIADO = "divorciado" + VIUDO = "viudo" + + +class ArProvince(IntEnum): + BUENOS_AIRES = 1 + SANTA_FE = 2 + CORDOBA = 3 + MENDOZA = 4 + ENTRE_RIOS = 5 + SANTIAGO_DEL_ESTERO = 6 + SAN_JUAN = 7 + SAN_LUIS = 8 + LA_RIOJA = 9 + CATAMARCA = 10 + JUJUY = 11 + SALTA = 12 + FORMOSA = 13 + CHACO = 14 + CORRIENTES = 15 + MISIONES = 16 + TUCUMAN = 17 + LA_PAMPA = 18 + NEUQUEN = 19 + CHUBUT = 20 + RIO_NEGRO = 21 + SANTA_CRUZ = 22 + TIERRA_DEL_FUEGO = 23 + CIUDAD_AUTONOMA_DE_BUENOS_AIRES = 43 + + +class BrState(str, Enum): + RONDONIA = "RO" + ACRE = "AC" + AMAZONAS = "AM" + RORAIMA = "RR" + PARA = "PA" + AMAPA = "AP" + TOCANTINS = "TO" + MARANHAO = "MA" + PIAUI = "PI" + CEARA = "CE" + RIO_GRANDE_DO_NORTE = "RN" + PARAIBA = "PB" + PERNAMBUCO = "PE" + ALAGOAS = "AL" + SERGIPE = "SE" + BAHIA = "BA" + MINAS_GERAIS = "MG" + ESPIRITO_SANTO = "ES" + RIO_DE_JANEIRO = "RJ" + SAO_PAULO = "SP" + PARANA = "PR" + SANTA_CATARINA = "SC" + RIO_GRANDE_DO_SUL = "RS" + MATO_GROSSO_DO_SUL = "MS" + MATO_GROSSO = "MT" + GOIAS = "GO" + DISTRITO_FEDERAL = "DF" + + +class ChileanCommune(str, Enum): + ARICA = "Arica" + CAMARONES = "Camarones" + GENERAL_LAGOS = "General Lagos" + PUTRE = "Putre" + ALTO_HOSPICIO = "Alto Hospicio" + CAMINA = "Camiña" + COLCHANE = "Colchane" + HUARA = "Huara" + IQUIQUE = "Iquique" + PICA = "Pica" + POZO_ALMONTE = "Pozo Almonte" + ANTOFAGASTA = "Antofagasta" + CALAMA = "Calama" + MARIA_ELENA = "María Elena" + MEJILLONES = "Mejillones" + OLLAGUE = "Ollagüe" + SAN_PEDRO_DE_ATACAMA = "San Pedro de Atacama" + SIERRA_GORDA = "Sierra Gorda" + TALTAL = "Taltal" + TOCOPILLA = "Tocopilla" + ALTO_DEL_CARMEN = "Alto del Carmen" + CALDERA = "Caldera" + CHANERAL = "Chañaral" + COPIAPO = "Copiapó" + DIEGO_DE_ALMAGRO = "Diego de Almagro" + FREIRINA = "Freirina" + HUASCO = "Huasco" + TIERRA_AMARILLA = "Tierra Amarilla" + VALLENAR = "Vallenar" + ANDACOLLO = "Andacollo" + CANELA = "Canela" + COMBARBALA = "Combarbalá" + COQUIMBO = "Coquimbo" + ILLAPEL = "Illapel" + LA_HIGUERA = "La Higuera" + LA_SERENA = "La Serena" + LOS_VILOS = "Los Vilos" + MONTE_PATRIA = "Monte Patria" + OVALLE = "Ovalle" + PAIGUANO = "Paiguano" + PUNITAQUI = "Punitaqui" + RIO_HURTADO = "Río Hurtado" + SALAMANCA = "Salamanca" + VICUNA = "Vicuña" + ALGARROBO = "Algarrobo" + CABILDO = "Cabildo" + CALERA = "Calera" + CALLE_LARGA = "Calle Larga" + CARTAGENA = "Cartagena" + CASABLANCA = "Casablanca" + CATEMU = "Catemu" + CONCON = "Concón" + EL_QUISCO = "El Quisco" + EL_TABO = "El Tabo" + HIJUELAS = "Hijuelas" + ISLA_DE_PASCUA = "Isla de Pascua" + JUAN_FERNANDEZ = "Juan Fernández" + LA_CRUZ = "La Cruz" + LA_LIGUA = "La Ligua" + LIMACHE = "Limache" + LLAILLAY = "Llaillay" + LOS_ANDES = "Los Andes" + NOGALES = "Nogales" + OLMUE = "Olmué" + PANQUEHUE = "Panquehue" + PAPUDO = "Papudo" + PETORCA = "Petorca" + PUCHUNCAVI = "Puchuncaví" + PUTAENDO = "Putaendo" + QUILLOTA = "Quillota" + QUILPUE = "Quilpué" + QUINTERO = "Quintero" + RINCONADA = "Rinconada" + SAN_ANTONIO = "San Antonio" + SAN_ESTEBAN = "San Esteban" + SAN_FELIPE = "San Felipe" + SANTA_MARIA = "Santa María" + SANTO_DOMINGO = "Santo Domingo" + VALPARAISO = "Valparaíso" + VILLA_ALEMANA = "Villa Alemana" + VINA_DEL_MAR = "Viña del Mar" + ZAPALLAR = "Zapallar" + ALHUE = "Alhué" + BUIN = "Buin" + CALERA_DE_TANGO = "Calera de Tango" + CERRILLOS = "Cerrillos" + CERRO_NAVIA = "Cerro Navia" + COLINA = "Colina" + CONCHALI = "Conchalí" + CURACAVI = "Curacaví" + EL_BOSQUE = "El Bosque" + EL_MONTE = "El Monte" + ESTACION_CENTRAL = "Estación Central" + HUECHURABA = "Huechuraba" + INDEPENDENCIA = "Independencia" + ISLA_DE_MAIPO = "Isla de Maipo" + LA_CISTERNA = "La Cisterna" + LA_FLORIDA = "La Florida" + LA_GRANJA = "La Granja" + LA_PINTANA = "La Pintana" + LA_REINA = "La Reina" + LAMPA = "Lampa" + LAS_CONDES = "Las Condes" + LO_BARNECHEA = "Lo Barnechea" + LO_ESPEJO = "Lo Espejo" + LO_PRADO = "Lo Prado" + MACUL = "Macul" + MAIPU = "Maipú" + MARIA_PINTO = "María Pinto" + MELIPILLA = "Melipilla" + NUNOA = "Ñuñoa" + PADRE_HURTADO = "Padre Hurtado" + PAINE = "Paine" + PEDRO_AGUIRRE_CERDA = "Pedro Aguirre Cerda" + PENAFLOR = "Peñaflor" + PENALOLEN = "Peñalolén" + PIRQUE = "Pirque" + PROVIDENCIA = "Providencia" + PUDAHUEL = "Pudahuel" + PUENTE_ALTO = "Puente Alto" + QUILICURA = "Quilicura" + QUINTA_NORMAL = "Quinta Normal" + RECOLETA = "Recoleta" + RENCA = "Renca" + SAN_BERNARDO = "San Bernardo" + SAN_JOAQUIN = "San Joaquín" + SAN_JOSE_DE_MAIPO = "San José de Maipo" + SAN_MIGUEL = "San Miguel" + SAN_PEDRO = "San Pedro" + SAN_RAMON = "San Ramón" + SANTIAGO = "Santiago" + TALAGANTE = "Talagante" + TILTIL = "Tiltil" + VITACURA = "Vitacura" + CHIMBARONGO = "Chimbarongo" + CHEPICA = "Chépica" + CODEGUA = "Codegua" + COINCO = "Coinco" + COLTAUCO = "Coltauco" + DONIHUE = "Doñihue" + GRANEROS = "Graneros" + LA_ESTRELLA = "La Estrella" + LAS_CABRAS = "Las Cabras" + LITUECHE = "Litueche" + LOLOL = "Lolol" + MACHALI = "Machalí" + MALLOA = "Malloa" + MARCHIHUE = "Marchihue" + NANCAGUA = "Nancagua" + NAVIDAD = "Navidad" + OLIVAR = "Olivar" + PALMILLA = "Palmilla" + PAREDONES = "Paredones" + PERALILLO = "Peralillo" + PEUMO = "Peumo" + PICHIDEGUA = "Pichidegua" + PICHILEMU = "Pichilemu" + PLACILLA = "Placilla" + PUMANQUE = "Pumanque" + QUINTA_DE_TILCOCO = "Quinta de Tilcoco" + RANCAGUA = "Rancagua" + RENGO = "Rengo" + REQUINOA = "Requínoa" + SAN_FERNANDO = "San Fernando" + SAN_FRANCISCO_DE_MOSTAZAL = "San Francisco de Mostazal" + SAN_VICENTE_DE_TAGUA_TAGUA = "San Vicente de Tagua Tagua" + SANTA_CRUZ = "Santa Cruz" + CAUQUENES = "Cauquenes" + CHANCO = "Chanco" + COLBUN = "Colbún" + CONSTITUCION = "Constitución" + CUREPTO = "Curepto" + CURICO = "Curicó" + EMPEDRADO = "Empedrado" + HUALANE = "Hualañé" + LICANTEN = "Licantén" + LINARES = "Linares" + LONGAVI = "Longaví" + MAULE = "Maule" + MOLINA = "Molina" + PARRAL = "Parral" + PELARCO = "Pelarco" + PELLUHUE = "Pelluhue" + PENCAHUE = "Pencahue" + RAUCO = "Rauco" + RETIRO = "Retiro" + ROMERAL = "Romeral" + RIO_CLARO = "Río Claro" + SAGRADA_FAMILIA = "Sagrada Familia" + SAN_CLEMENTE = "San Clemente" + SAN_JAVIER_DE_LONCOMILLA = "San Javier de Loncomilla" + SAN_RAFAEL = "San Rafael" + TALCA = "Talca" + TENO = "Teno" + VICHUQUEN = "Vichuquén" + VILLA_ALEGRE = "Villa Alegre" + YERBAS_BUENAS = "Yerbas Buenas" + BULNES = "Bulnes" + CHILLAN_VIEJO = "Chillán Viejo" + CHILLAN = "Chillán" + COBQUECURA = "Cobquecura" + COELEMU = "Coelemu" + COIHUECO = "Coihueco" + EL_CARMEN = "El Carmen" + NINHUE = "Ninhue" + NIQUEN = "Ñiquén" + PEMUCO = "Pemuco" + PINTO = "Pinto" + PORTEZUELO = "Portezuelo" + QUILLON = "Quillón" + QUIRIHUE = "Quirihue" + RANQUIL = "Ránquil" + SAN_CARLOS = "San Carlos" + SAN_FABIAN = "San Fabián" + SAN_IGNACIO = "San Ignacio" + SAN_NICOLAS = "San Nicolás" + TREGUACO = "Treguaco" + YUNGAY = "Yungay" + ALTO_BIOBIO = "Alto Biobío" + ANTUCO = "Antuco" + ARAUCO = "Arauco" + CABRERO = "Cabrero" + CANETE = "Cañete" + CHIGUAYANTE = "Chiguayante" + CONCEPCION = "Concepción" + CONTULMO = "Contulmo" + CORONEL = "Coronel" + CURANILAHUE = "Curanilahue" + FLORIDA = "Florida" + HUALPEN = "Hualpén" + HUALQUI = "Hualqui" + LAJA = "Laja" + LEBU = "Lebu" + LOS_ALAMOS = "Los Álamos" + LOS_ANGELES = "Los Ángeles" + LOTA = "Lota" + MULCHEN = "Mulchén" + NACIMIENTO = "Nacimiento" + NEGRETE = "Negrete" + PENCO = "Penco" + QUILACO = "Quilaco" + QUILLECO = "Quilleco" + SAN_PEDRO_DE_LA_PAZ = "San Pedro de la Paz" + SAN_ROSENDO = "San Rosendo" + SANTA_BARBARA = "Santa Bárbara" + SANTA_JUANA = "Santa Juana" + TALCAHUANO = "Talcahuano" + TIRUA = "Tirúa" + TOME = "Tomé" + TUCAPEL = "Tucapel" + YUMBEL = "Yumbel" + ANGOL = "Angol" + CARAHUE = "Carahue" + CHOLCHOL = "Cholchol" + COLLIPULLI = "Collipulli" + CUNCO = "Cunco" + CURACAUTIN = "Curacautín" + CURARREHUE = "Curarrehue" + ERCILLA = "Ercilla" + FREIRE = "Freire" + GALVARINO = "Galvarino" + GORBEA = "Gorbea" + LAUTARO = "Lautaro" + LONCOCHE = "Loncoche" + LONQUIMAY = "Lonquimay" + LOS_SAUCES = "Los Sauces" + LUMACO = "Lumaco" + MELIPEUCO = "Melipeuco" + NUEVA_IMPERIAL = "Nueva Imperial" + PADRE_LAS_CASAS = "Padre las Casas" + PERQUENCO = "Perquenco" + PITRUFQUEN = "Pitrufquén" + PUCON = "Pucón" + PUREN = "Purén" + RENAICO = "Renaico" + SAAVEDRA = "Saavedra" + TEMUCO = "Temuco" + TEODORO_SCHMIDT = "Teodoro Schmidt" + TOLTEN = "Toltén" + TRAIGUEN = "Traiguén" + VICTORIA = "Victoria" + VILCUN = "Vilcún" + VILLARRICA = "Villarrica" + CORRAL = "Corral" + FUTRONO = "Futrono" + LA_UNION = "La Unión" + LAGO_RANCO = "Lago Ranco" + LANCO = "Lanco" + LOS_LAGOS = "Los Lagos" + MARIQUINA = "Mariquina" + MAFIL = "Máfil" + PAILLACO = "Paillaco" + PANGUIPULLI = "Panguipulli" + RIO_BUENO = "Río Bueno" + VALDIVIA = "Valdivia" + ANCUD = "Ancud" + CALBUCO = "Calbuco" + CASTRO = "Castro" + CHAITEN = "Chaitén" + CHONCHI = "Chonchi" + COCHAMO = "Cochamó" + CURACO_DE_VELEZ = "Curaco de Vélez" + DALCAHUE = "Dalcahue" + FRESIA = "Fresia" + FRUTILLAR = "Frutillar" + FUTALEUFU = "Futaleufú" + HUALAIHUE = "Hualaihué" + LLANQUIHUE = "Llanquihue" + LOS_MUERMOS = "Los Muermos" + MAULLIN = "Maullín" + OSORNO = "Osorno" + PALENA = "Palena" + PUERTO_MONTT = "Puerto Montt" + PUERTO_OCTAY = "Puerto Octay" + PUERTO_VARAS = "Puerto Varas" + PUQUELDON = "Puqueldón" + PURRANQUE = "Purranque" + PUYEHUE = "Puyehue" + QUEILEN = "Queilén" + QUELLON = "Quellón" + QUEMCHI = "Quemchi" + QUINCHAO = "Quinchao" + RIO_NEGRO = "Río Negro" + SAN_JUAN_DE_LA_COSTA = "San Juan de la Costa" + SAN_PABLO = "San Pablo" + AISEN = "Aisén" + CHILE_CHICO = "Chile Chico" + CISNES = "Cisnes" + COCHRANE = "Cochrane" + COIHAIQUE = "Coihaique" + GUAITECAS = "Guaitecas" + LAGO_VERDE = "Lago Verde" + OHIGGINS = "O'Higgins" + RIO_IBANEZ = "Río Ibáñez" + TORTEL = "Tortel" + ANTARTICA = "Antártica" + CABO_DE_HORNOS = "Cabo de Hornos (Ex Navarino)" + LAGUNA_BLANCA = "Laguna Blanca" + NATALES = "Natales" + PORVENIR = "Porvenir" + PRIMAVERA = "Primavera" + PUNTA_ARENAS = "Punta Arenas" + RIO_VERDE = "Río Verde" + SAN_GREGORIO = "San Gregorio" + TIMAUKEL = "Timaukel" + TORRES_DEL_PAINE = "Torres del Paine" diff --git a/notbank_python_sdk/core/endpoints.py b/notbank_python_sdk/core/endpoints.py index 2122cb3..11387df 100644 --- a/notbank_python_sdk/core/endpoints.py +++ b/notbank_python_sdk/core/endpoints.py @@ -83,6 +83,9 @@ class Endpoints(str, Enum): GET_LEVEL1 = "GetLevel1" GET_ENUMS = "GetEnums" + # caas + ACCOUNT_REGISTER = "account/register" + # user GET_USER_ACCOUNTS = "GetUserAccounts" GET_USER_DEVICES = "GetUserDevices" diff --git a/notbank_python_sdk/models/register_user_response.py b/notbank_python_sdk/models/register_user_response.py new file mode 100644 index 0000000..9dcdbb4 --- /dev/null +++ b/notbank_python_sdk/models/register_user_response.py @@ -0,0 +1,8 @@ +from dataclasses import dataclass +from uuid import UUID + + +@dataclass +class RegisterUserResponse: + user_id: UUID + token: str diff --git a/notbank_python_sdk/notbank_client.py b/notbank_python_sdk/notbank_client.py index 88e79ff..58a1b89 100644 --- a/notbank_python_sdk/notbank_client.py +++ b/notbank_python_sdk/notbank_client.py @@ -61,6 +61,7 @@ from notbank_python_sdk.models.subaccount import Subaccount, Subaccounts from notbank_python_sdk.models.product import Product from notbank_python_sdk.models.withdrawal_id_response import WithdrawalIdResponse +from notbank_python_sdk.models.register_user_response import RegisterUserResponse from notbank_python_sdk.parsing import build_subscription_handler, parse_response_fn, parse_response_list_fn, parse_report_response_fn from notbank_python_sdk.requests_models.add_whitelisted_address_request import AddWhitelistedAddressRequest from notbank_python_sdk.requests_models.authenticate_request import AuthenticateRequest @@ -158,6 +159,8 @@ from notbank_python_sdk.requests_models.get_account_info_request import GetAccountInfoRequest from notbank_python_sdk.requests_models.get_product_request import GetProductRequest from notbank_python_sdk.requests_models.get_products_request import GetProductsRequest +from notbank_python_sdk.requests_models.register_basic_user_request import RegisterBasicUserRequest +from notbank_python_sdk.requests_models.register_advanced_user_request import RegisterAdvancedUserRequest from notbank_python_sdk.notbank_client_cache import NotbankClientCache from notbank_python_sdk.websocket.callback_identifier import CallbackIdentifier from notbank_python_sdk.websocket.subscription import Subscription, Unsubscription @@ -1684,3 +1687,31 @@ def get_subaccounts(self, request: GetSubaccountsRequest = GetSubaccountsRequest Subaccounts, from_pascal_case=False), request_type=RequestType.GET ) + + # caas - user registration + + def register_basic_user(self, request: RegisterBasicUserRequest) -> RegisterUserResponse: + """ + https://docs.notbank.exchange/#register-a-basic-user + """ + return self._client_connection.request( + endpoint=Endpoints.ACCOUNT_REGISTER, + endpoint_category=EndpointCategory.NB, + request_data=to_nb_dict(request), + parse_response_fn=parse_response_fn( + RegisterUserResponse, from_pascal_case=False, overrides={"user_id": "userId"}), + request_type=RequestType.POST + ) + + def register_advanced_user(self, request: RegisterAdvancedUserRequest) -> RegisterUserResponse: + """ + https://docs.notbank.exchange/#register-an-advanced-user + """ + return self._client_connection.request( + endpoint=Endpoints.ACCOUNT_REGISTER, + endpoint_category=EndpointCategory.NB, + request_data=to_nb_dict(request), + parse_response_fn=parse_response_fn( + RegisterUserResponse, from_pascal_case=False, overrides={"user_id": "userId"}), + request_type=RequestType.POST + ) diff --git a/notbank_python_sdk/requests_models/__init__.py b/notbank_python_sdk/requests_models/__init__.py index 84b9ec7..57a65d6 100644 --- a/notbank_python_sdk/requests_models/__init__.py +++ b/notbank_python_sdk/requests_models/__init__.py @@ -71,6 +71,8 @@ from notbank_python_sdk.requests_models.oms_fees_request import * from notbank_python_sdk.requests_models.oms_fees_request import * from notbank_python_sdk.requests_models.order_book import * +from notbank_python_sdk.requests_models.register_advanced_user_request import * +from notbank_python_sdk.requests_models.register_basic_user_request import * from notbank_python_sdk.requests_models.remove_user_report_ticket import * from notbank_python_sdk.requests_models.resend_verification_code_whitelisted_address_request import * from notbank_python_sdk.requests_models.schedule_product_delta_activity_report import * diff --git a/notbank_python_sdk/requests_models/register_advanced_user_request.py b/notbank_python_sdk/requests_models/register_advanced_user_request.py new file mode 100644 index 0000000..8748e96 --- /dev/null +++ b/notbank_python_sdk/requests_models/register_advanced_user_request.py @@ -0,0 +1,51 @@ +from dataclasses import dataclass +from typing import Optional + +from notbank_python_sdk.constants import ( + ArProvince, + BrState, + ChileanCommune, + CivilStatus, + Gender, + IdentityType, + Profession, +) + + +@dataclass +class RegisterAdvancedUserRequest: + first_name: str + last_name: str + phone_number: str + profession: Profession + gender: Gender + birthdate: str + citizenship: str + identity_type: IdentityType + identity_number: str + identity_country: str + address_country: str + address_city: str + address_street: str + address_postal_code: str + pep: bool + subject_comply: bool + is_public_servant: bool + # AR-only + address_province: Optional[ArProvince] = None + # BR-only + address_district: Optional[str] = None + address_number: Optional[str] = None + address_state: Optional[BrState] = None + address_complement: Optional[str] = None + # CL-only + address_comune: Optional[ChileanCommune] = None + # PE-only + civil_status: Optional[CivilStatus] = None + spouse_name: Optional[str] = None + pep_position: Optional[str] = None + pep_institution: Optional[str] = None + pep_links_description: Optional[str] = None + is_pep_family_member: Optional[bool] = None + pep_family_member_name: Optional[str] = None + pep_family_member_relation: Optional[str] = None diff --git a/notbank_python_sdk/requests_models/register_basic_user_request.py b/notbank_python_sdk/requests_models/register_basic_user_request.py new file mode 100644 index 0000000..fc33079 --- /dev/null +++ b/notbank_python_sdk/requests_models/register_basic_user_request.py @@ -0,0 +1,50 @@ +from dataclasses import dataclass +from typing import Optional + +from notbank_python_sdk.constants import ( + ArProvince, + BrState, + ChileanCommune, + CivilStatus, + Gender, + IdentityType, + Profession, +) + + +@dataclass +class RegisterBasicUserRequest: + first_name: str + last_name: str + phone_number: str + profession: Profession + gender: Gender + birthdate: str + citizenship: str + identity_type: IdentityType + identity_number: str + identity_country: str + address_country: str + address_city: str + address_street: str + address_postal_code: str + # AR-only + address_province: Optional[ArProvince] = None + subject_comply: Optional[bool] = None + # BR-only + address_district: Optional[str] = None + address_number: Optional[str] = None + address_state: Optional[BrState] = None + address_complement: Optional[str] = None + # CL-only + address_comune: Optional[ChileanCommune] = None + # PE-only + civil_status: Optional[CivilStatus] = None + spouse_name: Optional[str] = None + pep: Optional[bool] = None + pep_position: Optional[str] = None + pep_institution: Optional[str] = None + pep_links_description: Optional[str] = None + is_pep_family_member: Optional[bool] = None + pep_family_member_name: Optional[str] = None + pep_family_member_relation: Optional[str] = None diff --git a/tests/test_register_advanced_user.py b/tests/test_register_advanced_user.py new file mode 100644 index 0000000..3d968c2 --- /dev/null +++ b/tests/test_register_advanced_user.py @@ -0,0 +1,47 @@ +import unittest + +from notbank_python_sdk.constants import Gender, IdentityType, Profession +from notbank_python_sdk.models.register_user_response import RegisterUserResponse +from notbank_python_sdk.notbank_client import NotbankClient +from notbank_python_sdk.requests_models import RegisterAdvancedUserRequest +from tests import test_helper + + +class TestRegisterAdvancedUser(unittest.TestCase): + + @classmethod + def setUpClass(cls): + connection = test_helper.new_rest_client_connection( + test_helper.print_message_in, test_helper.print_message_out) + cls.credentials = test_helper.load_credentials() + test_helper.authenticate_connection(connection, cls.credentials) + cls.client = NotbankClient(connection) + + def test_register_advanced_user(self): + response = self.client.register_advanced_user(RegisterAdvancedUserRequest( + first_name="Juan", + last_name="Perez", + phone_number="+56911111111", + profession=Profession.TRADER, + gender=Gender.MAN, + birthdate="01/01/1990", + citizenship="CL", + identity_type=IdentityType.PASAPORTE, + identity_number="P12345678", + identity_country="CL", + address_country="CL", + address_city="Santiago", + address_street="Calle 1", + address_postal_code="8320000", + pep=False, + subject_comply=False, + is_public_servant=False, + )) + self.assertIsNotNone(response) + self.assertIsInstance(response, RegisterUserResponse) + self.assertIsNotNone(response.user_id) + self.assertIsNotNone(response.token) + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/test_register_basic_user.py b/tests/test_register_basic_user.py new file mode 100644 index 0000000..bebb32c --- /dev/null +++ b/tests/test_register_basic_user.py @@ -0,0 +1,45 @@ +import unittest + +from notbank_python_sdk.constants import ChileanCommune, Gender, IdentityType, Profession +from notbank_python_sdk.models.register_user_response import RegisterUserResponse +from notbank_python_sdk.notbank_client import NotbankClient +from notbank_python_sdk.requests_models import RegisterBasicUserRequest +from tests import test_helper + + +class TestRegisterBasicUser(unittest.TestCase): + + @classmethod + def setUpClass(cls): + connection = test_helper.new_rest_client_connection( + test_helper.print_message_in, test_helper.print_message_out) + cls.credentials = test_helper.load_credentials() + test_helper.authenticate_connection(connection, cls.credentials) + cls.client = NotbankClient(connection) + + def test_register_basic_user(self): + response = self.client.register_basic_user(RegisterBasicUserRequest( + first_name="Juan", + last_name="Perez", + phone_number="+5511999999999", + profession=Profession.TRADER, + gender=Gender.MAN, + birthdate="01/01/1990", + citizenship="CL", + identity_type=IdentityType.DNI, + identity_number="26988728-1", + identity_country="CL", + address_country="CL", + address_city="Santiago", + address_street="Calle 1", + address_postal_code="8320000", + address_comune=ChileanCommune.SANTIAGO, + )) + self.assertIsNotNone(response) + self.assertIsInstance(response, RegisterUserResponse) + self.assertIsNotNone(response.user_id) + self.assertIsNotNone(response.token) + + +if __name__ == "__main__": + unittest.main() From 17ddbbd5f0253b6e611cddd5607cf140af854e78 Mon Sep 17 00:00:00 2001 From: Jose Guerrero Date: Fri, 22 May 2026 16:22:54 -0400 Subject: [PATCH 2/2] refactor: rename IdentityType and CivilStatus members to English --- notbank_python_sdk/constants.py | 14 +++++++------- tests/test_register_advanced_user.py | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/notbank_python_sdk/constants.py b/notbank_python_sdk/constants.py index 5ef82d2..a1fb133 100644 --- a/notbank_python_sdk/constants.py +++ b/notbank_python_sdk/constants.py @@ -188,13 +188,13 @@ class Gender(IntEnum): class IdentityType(IntEnum): DNI = 1 - EXTRANJERO = 2 + FOREIGNER = 2 NUIP = 3 NIP = 4 PEP = 5 CC = 6 CE = 7 - PASAPORTE = 8 + PASSPORT = 8 class Profession(str, Enum): @@ -296,11 +296,11 @@ class Profession(str, Enum): class CivilStatus(str, Enum): - SOLTERO = "soltero" - CASADO = "casado" - CONVIVIENTE = "conviviente" - DIVORCIADO = "divorciado" - VIUDO = "viudo" + SINGLE = "soltero" + MARRIED = "casado" + COHABITING = "conviviente" + DIVORCED = "divorciado" + WIDOWED = "viudo" class ArProvince(IntEnum): diff --git a/tests/test_register_advanced_user.py b/tests/test_register_advanced_user.py index 3d968c2..67ecb37 100644 --- a/tests/test_register_advanced_user.py +++ b/tests/test_register_advanced_user.py @@ -26,7 +26,7 @@ def test_register_advanced_user(self): gender=Gender.MAN, birthdate="01/01/1990", citizenship="CL", - identity_type=IdentityType.PASAPORTE, + identity_type=IdentityType.PASSPORT, identity_number="P12345678", identity_country="CL", address_country="CL",