11import json
2+ from typing import Optional
23
34import requests
45
1011
1112class HttpClient :
1213
13- def __init__ (self , api_key : str , secret_key : str , window : int = None ):
14+ def __init__ (self , api_key : str , api_secret : str , window : Optional [ int ] = None ):
1415 self .api_key = api_key
15- self .secret_key = secret_key
16+ self .api_secret = api_secret
1617 self .window = window
1718 self .session_is_open = False
18- self .session = None
19- self ._init_session ()
20-
21- def _init_session (self ):
22- assert self .session_is_open == False
2319 session = requests .session ()
2420 session .headers .update ({'User-Agent' : 'cryptomarket/python' })
2521 self .session = session
@@ -29,10 +25,10 @@ def close_session(self):
2925 self .session .close ()
3026 self .session_is_open = False
3127
32- def authorize (self ):
28+ def reset_authorization (self ):
3329 assert self .session_is_open == True
3430 self .session .auth = HmacAuth (
35- self .api_key , self .secret_key , window = self .window )
31+ self .api_key , self .api_secret , window = self .window )
3632
3733 def get (self , endpoint , params = None ):
3834 response = self .session .get (api_url + endpoint , params = params )
@@ -59,7 +55,7 @@ def delete(self, endpoint, params=None):
5955
6056 def _handle_response (self , response ):
6157 """Internal helper for handling API responses from the CryptoMarket server.
62- Raises the appropriate exceptions when necessary; otherwise, returns the
58+ Raises the appropriate exceptions when necessary; otherwise, return the
6359 response.
6460 """
6561 if not str (response .status_code ).startswith ('2' ):
0 commit comments