@@ -27,21 +27,11 @@ def __get_os_platform():
2727def user_agents ():
2828 header = {'sdk' : dict (name = contentstack .__package__ ,
2929 version = contentstack .__version__
30- ), 'os' : __get_os_platform , 'Content-Type' : 'application/json' }
30+ ), 'os' : __get_os_platform () , 'Content-Type' : 'application/json' }
3131 package = f"{ contentstack .__title__ } /{ contentstack .__version__ } "
3232 return {'User-Agent' : str (header ), "X-User-Agent" : package }
3333
3434
35- def get_api_data (response ):
36- try :
37- response .raise_for_status ()
38- except requests .exceptions .HTTPError as error :
39- print (f"Error: { error } " )
40- return None
41- else :
42- return response .json ()
43-
44-
4535class HTTPSConnection : # R0903: Too few public methods
4636 def __init__ (self , endpoint , headers , timeout , retry_strategy , live_preview ):
4737 if None not in (endpoint , headers ):
@@ -53,22 +43,6 @@ def __init__(self, endpoint, headers, timeout, retry_strategy, live_preview):
5343 self .retry_strategy = retry_strategy
5444 self .live_preview = live_preview
5545
56- def impl_live_preview (self ):
57- if self .live_preview ['enable' ]:
58- host = self .live_preview ['host' ]
59- authorization = self .live_preview ['authorization' ]
60- ct = self .live_preview ['content_type_uid' ]
61- entry_uid = self .live_preview ['entry_uid' ]
62- url = f'https://{ host } /v3/content_types/{ ct } /entries'
63- if entry_uid is not None :
64- url = f'{ url } /{ entry_uid } '
65- self .headers ['authorization' ] = authorization
66- lp_resp = get_request (self .session , url , headers = self .headers , timeout = self .timeout )
67- if lp_resp is not None and not 'error_code' in lp_resp :
68- return lp_resp
69- return None
70- return None
71-
7246 def get (self , url ):
7347 self .headers .update (user_agents ())
7448 adapter = HTTPAdapter (max_retries = self .retry_strategy )
0 commit comments