mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-19 06:44:22 +01:00
Organize rest sub-package. Create new endpoints and middleware sub-packages. Rename class Requests to Middleware.
This commit is contained in:
@@ -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)
|
|
||||||
@@ -1 +1,3 @@
|
|||||||
from .BfxRestInterface import BfxRestInterface
|
from .endpoints import BfxRestInterface, RestPublicEndpoints, RestAuthenticatedEndpoints
|
||||||
|
|
||||||
|
NAME = "rest"
|
||||||
5
bfxapi/rest/endpoints/__init__.py
Normal file
5
bfxapi/rest/endpoints/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
from .bfx_rest_interface import BfxRestInterface
|
||||||
|
from .rest_public_endpoints import RestPublicEndpoints
|
||||||
|
from .rest_authenticated_endpoints import RestAuthenticatedEndpoints
|
||||||
|
|
||||||
|
NAME = "endpoints"
|
||||||
13
bfxapi/rest/endpoints/bfx_rest_interface.py
Normal file
13
bfxapi/rest/endpoints/bfx_rest_interface.py
Normal file
@@ -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)
|
||||||
@@ -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 decimal import Decimal
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from ._Requests import _Requests
|
from ..middleware import Middleware
|
||||||
|
|
||||||
class _RestAuthenticatedEndpoints(_Requests):
|
class RestAuthenticatedEndpoints(Middleware):
|
||||||
def get_wallets(self) -> List[Wallet]:
|
def get_wallets(self) -> List[Wallet]:
|
||||||
return [ serializers.Wallet.parse(*sub_data) for sub_data in self._POST("auth/r/wallets") ]
|
return [ serializers.Wallet.parse(*sub_data) for sub_data in self._POST("auth/r/wallets") ]
|
||||||
|
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
from typing import List, Union, Literal, Optional, Any, cast
|
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 decimal import Decimal
|
||||||
|
|
||||||
from ._Requests import _Requests
|
from ..middleware import Middleware
|
||||||
|
|
||||||
class _RestPublicEndpoints(_Requests):
|
class RestPublicEndpoints(Middleware):
|
||||||
def conf(self, config: Config) -> Any:
|
def conf(self, config: Config) -> Any:
|
||||||
return self._GET(f"conf/{config}")[0]
|
return self._GET(f"conf/{config}")[0]
|
||||||
|
|
||||||
3
bfxapi/rest/middleware/__init__.py
Normal file
3
bfxapi/rest/middleware/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from .middleware import Middleware
|
||||||
|
|
||||||
|
NAME = "middleware"
|
||||||
@@ -3,15 +3,15 @@ import time, hmac, hashlib, json, requests
|
|||||||
from typing import TYPE_CHECKING, Optional, Any
|
from typing import TYPE_CHECKING, Optional, Any
|
||||||
|
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
from .enums import Error
|
from ..enums import Error
|
||||||
from .exceptions import ResourceNotFound, RequestParametersError, InvalidAuthenticationCredentials, UnknownGenericError
|
from ..exceptions import ResourceNotFound, RequestParametersError, InvalidAuthenticationCredentials, UnknownGenericError
|
||||||
|
|
||||||
from ..utils.JSONEncoder import JSONEncoder
|
from ...utils.JSONEncoder import JSONEncoder
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from requests.sessions import _Params
|
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):
|
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
|
self.host, self.API_KEY, self.API_SECRET = host, API_KEY, API_SECRET
|
||||||
|
|
||||||
6
setup.py
6
setup.py
@@ -3,7 +3,11 @@ from distutils.core import setup
|
|||||||
setup(
|
setup(
|
||||||
name="bitfinex-api-py",
|
name="bitfinex-api-py",
|
||||||
version="3.0.0",
|
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",
|
url="https://github.com/bitfinexcom/bitfinex-api-py",
|
||||||
license="OSI Approved :: Apache Software License",
|
license="OSI Approved :: Apache Software License",
|
||||||
author="Bitfinex",
|
author="Bitfinex",
|
||||||
|
|||||||
Reference in New Issue
Block a user