Skip to content
Merged
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
528 changes: 528 additions & 0 deletions notbank_python_sdk/constants.py

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions notbank_python_sdk/core/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 8 additions & 0 deletions notbank_python_sdk/models/register_user_response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from dataclasses import dataclass
from uuid import UUID


@dataclass
class RegisterUserResponse:
user_id: UUID
token: str
35 changes: 33 additions & 2 deletions notbank_python_sdk/notbank_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@
from notbank_python_sdk.models.account_info import AccountInfo
from notbank_python_sdk.models.subaccount import Subaccounts
from notbank_python_sdk.models.product import Product
from notbank_python_sdk.models.withdrawal_id_response import WithdrawalIdResponse
from notbank_python_sdk.models.province import Province
from notbank_python_sdk.models.one_step_withdraw import OneStepWithdraw
from notbank_python_sdk.models.province import Province
from notbank_python_sdk.models.register_user_response import RegisterUserResponse
from notbank_python_sdk.models.withdrawal_id_response import WithdrawalIdResponse
from notbank_python_sdk.models.yield_product import YieldProduct
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
Expand Down Expand Up @@ -166,6 +167,8 @@
from notbank_python_sdk.requests_models.get_yield_products_request import GetYieldProductsRequest
from notbank_python_sdk.requests_models.deposit_to_yield_request import DepositToYieldRequest
from notbank_python_sdk.requests_models.withdraw_from_yield_request import WithdrawFromYieldRequest
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
Expand Down Expand Up @@ -1781,3 +1784,31 @@ def withdraw_from_yield(self, request: WithdrawFromYieldRequest) -> int:
parse_response_fn=lambda x: int(x),
request_type=RequestType.POST
)

# 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
)
2 changes: 2 additions & 0 deletions notbank_python_sdk/requests_models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,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 *
Expand Down
Original file line number Diff line number Diff line change
@@ -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
50 changes: 50 additions & 0 deletions notbank_python_sdk/requests_models/register_basic_user_request.py
Original file line number Diff line number Diff line change
@@ -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
47 changes: 47 additions & 0 deletions tests/test_register_advanced_user.py
Original file line number Diff line number Diff line change
@@ -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.PASSPORT,
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()
45 changes: 45 additions & 0 deletions tests/test_register_basic_user.py
Original file line number Diff line number Diff line change
@@ -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()