77
88
99class Api :
10+ @classmethod
11+ def get_config (cls , config = None , ** kwargs ):
12+ if config is None :
13+ config = Config .GetDefaultConfig ()
14+ return config
15+
1016 @classmethod
1117 def _headers (cls , custom_headers ) -> dict :
1218 headers = {
@@ -23,12 +29,13 @@ def handle_api_response(response):
2329 raise ApiException (str (e ), response )
2430
2531 @classmethod
26- def get (cls , url_frag , auth , config , params = {}, ** kwargs ):
32+ def get (cls , url_frag , params = {}, config = None , ** kwargs ):
33+ config = cls .get_config (config )
2734 url_frag = url_frag .replace (f"/{ config .API_VERSION } " , "" )
2835 url = f"{ config .api_base_url ()} /{ url_frag .lstrip ('/' )} "
2936 response = requests .get (
3037 url ,
31- auth = auth ,
38+ auth = config . _auth () ,
3239 params = params ,
3340 headers = cls ._headers (kwargs .get ("headers" , {})),
3441 ** kwargs ,
@@ -37,43 +44,46 @@ def get(cls, url_frag, auth, config, params={}, **kwargs):
3744 return response .json ()
3845
3946 @classmethod
40- def post (cls , url_frag , auth , config , payload = {}, ** kwargs ):
47+ def post (cls , url_frag , payload = {}, config = None , ** kwargs ):
48+ config = cls .get_config (config )
4149 url_frag = url_frag .replace (f"/{ config .API_VERSION } " , "" )
4250 url = f"{ config .api_base_url ()} /{ url_frag .lstrip ('/' )} "
4351
4452 response = requests .post (
4553 url ,
4654 json = payload ,
47- auth = auth ,
55+ auth = config . _auth () ,
4856 headers = cls ._headers (kwargs .get ("headers" , {})),
4957 ** kwargs ,
5058 )
5159 cls .handle_api_response (response )
5260 return response .json ()
5361
5462 @classmethod
55- def put (cls , url_frag , auth , config , payload = {}, ** kwargs ):
63+ def put (cls , url_frag , payload = {}, config = None , ** kwargs ):
64+ config = cls .get_config (config )
5665 url_frag = url_frag .replace (f"/{ config .API_VERSION } " , "" )
5766 url = f"{ config .api_base_url ()} /{ url_frag .lstrip ('/' )} "
5867
5968 response = requests .put (
6069 url ,
6170 json = payload ,
62- auth = auth ,
71+ auth = config . _auth () ,
6372 headers = cls ._headers (kwargs .get ("headers" , {})),
6473 ** kwargs ,
6574 )
6675 cls .handle_api_response (response )
6776 return response .json ()
6877
6978 @classmethod
70- def delete (cls , url_frag , auth , config , params = {}, ** kwargs ):
79+ def delete (cls , url_frag , params = {}, config = None , ** kwargs ):
80+ config = cls .get_config (config )
7181 url_frag = url_frag .replace (f"/{ config .API_VERSION } " , "" )
7282 url = f"{ config .api_base_url ()} /{ url_frag .lstrip ('/' )} "
7383
7484 response = requests .delete (
7585 url ,
76- auth = auth ,
86+ auth = config . _auth () ,
7787 params = params ,
7888 headers = cls ._headers (kwargs .get ("headers" , {})),
7989 ** kwargs ,
0 commit comments