diff --git a/bfxapi/rest/BfxRestInterface.py b/bfxapi/rest/BfxRestInterface.py deleted file mode 100644 index 91d31a2..0000000 --- a/bfxapi/rest/BfxRestInterface.py +++ /dev/null @@ -1,13 +0,0 @@ -from typing import Optional - -from ._RestPublicEndpoints import _RestPublicEndpoints - -from ._RestAuthenticatedEndpoints import _RestAuthenticatedEndpoints - -class BfxRestInterface(object): - VERSION = 2 - - def __init__(self, host: str, API_KEY: Optional[str] = None, API_SECRET: Optional[str] = None): - self.public = _RestPublicEndpoints(host=host) - - self.auth = _RestAuthenticatedEndpoints(host=host, API_KEY=API_KEY, API_SECRET=API_SECRET) \ No newline at end of file diff --git a/bfxapi/rest/__init__.py b/bfxapi/rest/__init__.py index 0bf3d2e..7ee9fed 100644 --- a/bfxapi/rest/__init__.py +++ b/bfxapi/rest/__init__.py @@ -1 +1,3 @@ -from .BfxRestInterface import BfxRestInterface \ No newline at end of file +from .endpoints import BfxRestInterface, RestPublicEndpoints, RestAuthenticatedEndpoints + +NAME = "rest" \ No newline at end of file diff --git a/bfxapi/rest/endpoints/__init__.py b/bfxapi/rest/endpoints/__init__.py new file mode 100644 index 0000000..24a005d --- /dev/null +++ b/bfxapi/rest/endpoints/__init__.py @@ -0,0 +1,5 @@ +from .bfx_rest_interface import BfxRestInterface +from .rest_public_endpoints import RestPublicEndpoints +from .rest_authenticated_endpoints import RestAuthenticatedEndpoints + +NAME = "endpoints" \ No newline at end of file diff --git a/bfxapi/rest/endpoints/bfx_rest_interface.py b/bfxapi/rest/endpoints/bfx_rest_interface.py new file mode 100644 index 0000000..53f87b0 --- /dev/null +++ b/bfxapi/rest/endpoints/bfx_rest_interface.py @@ -0,0 +1,13 @@ +from typing import Optional + +from .rest_public_endpoints import RestPublicEndpoints + +from .rest_authenticated_endpoints import RestAuthenticatedEndpoints + +class BfxRestInterface(object): + VERSION = 2 + + def __init__(self, host: str, API_KEY: Optional[str] = None, API_SECRET: Optional[str] = None): + self.public = RestPublicEndpoints(host=host) + + self.auth = RestAuthenticatedEndpoints(host=host, API_KEY=API_KEY, API_SECRET=API_SECRET) \ No newline at end of file diff --git a/bfxapi/rest/_RestAuthenticatedEndpoints.py b/bfxapi/rest/endpoints/rest_authenticated_endpoints.py similarity index 98% rename from bfxapi/rest/_RestAuthenticatedEndpoints.py rename to bfxapi/rest/endpoints/rest_authenticated_endpoints.py index ab4b9bc..a207673 100644 --- a/bfxapi/rest/_RestAuthenticatedEndpoints.py +++ b/bfxapi/rest/endpoints/rest_authenticated_endpoints.py @@ -1,16 +1,16 @@ -from typing import List, Union, Literal, Optional, Any, cast +from typing import List, Union, Literal, Optional -from .types import * +from ..types import * -from . import serializers +from .. import serializers -from .enums import Config, Sort, OrderType, FundingOfferType +from ..enums import Sort, OrderType, FundingOfferType from decimal import Decimal from datetime import datetime -from ._Requests import _Requests +from ..middleware import Middleware -class _RestAuthenticatedEndpoints(_Requests): +class RestAuthenticatedEndpoints(Middleware): def get_wallets(self) -> List[Wallet]: return [ serializers.Wallet.parse(*sub_data) for sub_data in self._POST("auth/r/wallets") ] diff --git a/bfxapi/rest/_RestPublicEndpoints.py b/bfxapi/rest/endpoints/rest_public_endpoints.py similarity index 98% rename from bfxapi/rest/_RestPublicEndpoints.py rename to bfxapi/rest/endpoints/rest_public_endpoints.py index c3d2071..687a2f5 100644 --- a/bfxapi/rest/_RestPublicEndpoints.py +++ b/bfxapi/rest/endpoints/rest_public_endpoints.py @@ -1,15 +1,15 @@ from typing import List, Union, Literal, Optional, Any, cast -from .types import * +from ..types import * -from . import serializers +from .. import serializers -from .enums import Config, Sort +from ..enums import Config, Sort from decimal import Decimal -from ._Requests import _Requests +from ..middleware import Middleware -class _RestPublicEndpoints(_Requests): +class RestPublicEndpoints(Middleware): def conf(self, config: Config) -> Any: return self._GET(f"conf/{config}")[0] diff --git a/bfxapi/rest/middleware/__init__.py b/bfxapi/rest/middleware/__init__.py new file mode 100644 index 0000000..d7e276b --- /dev/null +++ b/bfxapi/rest/middleware/__init__.py @@ -0,0 +1,3 @@ +from .middleware import Middleware + +NAME = "middleware" \ No newline at end of file diff --git a/bfxapi/rest/_Requests.py b/bfxapi/rest/middleware/middleware.py similarity index 93% rename from bfxapi/rest/_Requests.py rename to bfxapi/rest/middleware/middleware.py index 70557cb..627c5cf 100644 --- a/bfxapi/rest/_Requests.py +++ b/bfxapi/rest/middleware/middleware.py @@ -3,15 +3,15 @@ import time, hmac, hashlib, json, requests from typing import TYPE_CHECKING, Optional, Any from http import HTTPStatus -from .enums import Error -from .exceptions import ResourceNotFound, RequestParametersError, InvalidAuthenticationCredentials, UnknownGenericError +from ..enums import Error +from ..exceptions import ResourceNotFound, RequestParametersError, InvalidAuthenticationCredentials, UnknownGenericError -from ..utils.JSONEncoder import JSONEncoder +from ...utils.JSONEncoder import JSONEncoder if TYPE_CHECKING: from requests.sessions import _Params -class _Requests(object): +class Middleware(object): def __init__(self, host: str, API_KEY: Optional[str] = None, API_SECRET: Optional[str] = None): self.host, self.API_KEY, self.API_SECRET = host, API_KEY, API_SECRET diff --git a/setup.py b/setup.py index 963f30a..54db508 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,11 @@ from distutils.core import setup setup( name="bitfinex-api-py", version="3.0.0", - packages=[ "bfxapi", "bfxapi.websocket", "bfxapi.rest", "bfxapi.utils" ], + packages=[ + "bfxapi", "bfxapi.utils", + "bfxapi.websocket", + "bfxapi.rest", "bfxapi.rest.endpoints", "bfxapi.rest.middleware", + ], url="https://github.com/bitfinexcom/bitfinex-api-py", license="OSI Approved :: Apache Software License", author="Bitfinex",