diff --git a/Pipfile b/Pipfile index 1290c3f..2fd82f2 100644 --- a/Pipfile +++ b/Pipfile @@ -13,6 +13,7 @@ pytest = "*" pytest-runner = "*" pytest-mock = "*" pytest-asyncio = "*" +pdoc3 = "*" [requires] python_version = "3.9.6" diff --git a/deriv_api/__init__.py b/deriv_api/__init__.py index 792d600..1e2b82a 100644 --- a/deriv_api/__init__.py +++ b/deriv_api/__init__.py @@ -1 +1,9 @@ # +__pdoc__ = { + 'deriv_api.cache' : False, + 'deriv_api.in_memory' : False, + 'deriv_api.errors' : False, + 'deriv_api.utils' : False, + 'deriv_api.subscription_manager' : False, + 'deriv_api.custom_future': False +} \ No newline at end of file diff --git a/deriv_api/deriv_api.py b/deriv_api/deriv_api.py index c9b81ab..fbe7cd2 100644 --- a/deriv_api/deriv_api.py +++ b/deriv_api/deriv_api.py @@ -14,26 +14,55 @@ level=logging.ERROR ) +__pdoc__ = { + 'deriv_api.deriv_api.DerivAPI.send': False, + 'deriv_api.deriv_api.DerivAPI.api_connect': False, + 'deriv_api.deriv_api.DerivAPI.get_url': False, + 'deriv_api.deriv_api.DerivAPI.parse_response': False, + 'deriv_api.deriv_api.DerivAPI.send_receive': False, + 'deriv_api.deriv_api.DerivAPI.wsconnection' : False, + 'deriv_api.deriv_api.DerivAPI.storage' : False +} class DerivAPI(DerivAPICalls): """ The minimum functionality provided by DerivAPI, provides direct calls to the API. `api.cache` is available if you want to use the cached data - example - apiFromEndpoint = deriv_api.DerivAPI({ endpoint: 'ws.binaryws.com', app_id: 1234 }); - - param {Object} options - param {WebSocket} options.connection - A ready to use connection - param {String} options.endpoint - API server to connect to - param {Number} options.app_id - Application ID of the API user - param {String} options.lang - Language of the API communication - param {String} options.brand - Brand name - param {Object} options.middleware - A middleware to call on certain API actions - - property {Cache} cache - Temporary cache default to {InMemory} - property {Cache} storage - If specified, uses a more persistent cache (local storage, etc.) + Examples + -------- + - Pass the arguments needed to create a connection: + >>> api = deriv_api.DerivAPI({ endpoint: 'ws://...', app_id: 1234 }); + + - create and use a previously opened connection: + >>> connection = await websockets.connect('ws://...') + >>> api = deriv_api.DerivAPI(connection=connection) + + Args: + options (dict): + + Parameters + ---------- + options.connection : websockets.WebSocketClientProtocol + A ready to use connection + options.endpoint : String + API server to connect to + options.app_id : String + Application ID of the API user + options.lang : String + Language of the API communication + options.brand : String + Brand name + options.middleware : String + A middleware to call on certain API actions + + Properties + cache : Cache + Temporary cache default to {InMemory} + storage : Cache + If specified, uses a more persistent cache (local storage, etc.) """ + wsconnection: Union[websockets.WebSocketClientProtocol, None] = None storage: Union[InMemory, Cache, str] = '' @@ -122,5 +151,7 @@ def parse_response(self, message: str) -> dict: return data async def disconnect(self) -> None: + """ To disconnect the websocket connection + """ self.shouldReconnect = False await self.wsconnection.close() diff --git a/deriv_api/deriv_api_calls.py b/deriv_api/deriv_api_calls.py index 6c3af9e..96cb091 100644 --- a/deriv_api/deriv_api_calls.py +++ b/deriv_api/deriv_api_calls.py @@ -14,11 +14,22 @@ class DerivAPICalls: async def account_closure(self, args=None): """ - param args {Dict} - param args.account_closure {Number}: Must be `1` - param args.passthrough {Any}: [Optional] Used to pass data through the websocket, which may be retrieved via the `echo_req` output field. - param args.reason {String}: Reason for closing off accounts. - param args.req_id {Number}: [Optional] Used to map request to response. + Args: + args (dict): + Parameters + ---------- + args.account_closure : Number + Must be 1 + + args.passthrough : Any [Optional] + Used to pass data through the websocket, which may be retrieved via the echo_req output field. + + args.reason : String + Reason for closing off accounts. + + args.req_id : Number [Optional] + Used to map request to response. + """ if args is None: @@ -6029,6 +6040,10 @@ async def process_request(self, all_args): raise ValueError(error) return await self.send(parsed_args) +__pdoc__ = { + 'parse_args' : False, + 'validate_args' : False +} def parse_args(all_args): """