11import requests
2+ from urllib3 .util import timeout
23from contentstack import config
34import urllib .parse
45import logging
@@ -10,12 +11,11 @@ def __init__(self, url_path, query=dict, local_headers=dict):
1011 self .url_path = url_path
1112 self ._query_prams = query
1213 self ._local_headers = local_headers
14+ self .url_path = config .Config ().get_endpoint (self .url_path )
1315 if 'environment' in self ._local_headers :
1416 self ._query_prams ['environment' ] = self ._local_headers ['environment' ]
15- self .url_path = config .Config ().get_endpoint (self .url_path )
1617
1718 def http_request (self ) -> dict :
18-
1919 self ._local_headers ['X-User-Agent' ] = self ._contentstack_user_agent ()
2020 self ._local_headers ['Content-Type' ] = 'application/json'
2121 response = requests .get (self .url_path , params = self ._query_prams , headers = self ._local_headers )
@@ -27,11 +27,21 @@ def http_request(self) -> dict:
2727 logging .info ('stack response' )
2828 return json_response ['stack' ]
2929 if 'content_types' in json_response :
30- logging .info ('content type response' )
30+ logging .info ('contenttypes response' )
3131 return json_response ['content_types' ]
3232 if 'items' in json_response :
3333 logging .info ('sync response' )
3434 return json_response ['items' ]
35+ if 'content_type' in json_response :
36+ logging .info ('content type response' )
37+ return json_response ['content_type' ]
38+ if 'entry' in json_response :
39+ logging .info ('entry response' )
40+ return json_response ['entry' ]
41+ if 'entries' in json_response :
42+ logging .info ('entries response' )
43+ return json_response ['entries' ]
44+
3545 else :
3646 error_response = response .json ()
3747 # error_message = error_response["error_message"]
0 commit comments