Skip to content

Commit 365af53

Browse files
stack code refactored
1 parent 35ce0e1 commit 365af53

File tree

4 files changed

+33
-32
lines changed

4 files changed

+33
-32
lines changed

contentstack/HTTPConnection.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class HTTPConnection:
1010

11-
def __init__(self, query=None):
11+
def __init__(self, query=None):
1212
self._query = query
1313

1414
def get_query_request(self):
@@ -27,13 +27,14 @@ def get_group_request(self):
2727
return self.__http_request()
2828

2929
def __http_request(self):
30-
encoded_query = urllib.parse.urlencode(self.__query)
31-
self._local_headers['Content-Type'] ='application/json'.format()
32-
self._local_headers['X-User-Agent'] = config.Config.SDK_VERSION
33-
response = requests.post(config.Config.get_host(), encoded_query, self.__local_headers)
30+
pass
31+
# encoded_query = urllib.parse.urlencode(self.__query)
32+
# self._local_headers['Content-Type'] = 'application/json/{0}'.format(config.Config.SDK_VERSION)
33+
# self._local_headers['X-User-Agent'] = config.Config.SDK_VERSION
34+
# response = requests.post(config.Config.get_host(), encoded_query, self._local_headers)
35+
# print(response.json)
3436

35-
print(response.json)
3637

37-
38-
connection: HTTPConnection = HTTPConnection(local_headers={'dwd','wdq'},query={'dwwd':'dwdwq'})
38+
_param = {'param1': 'param1 value', 'param2': 'param2 value', 'param3': 'param3 value'}
39+
connection: HTTPConnection = HTTPConnection(_param)
3940
connection.get_entry_request()

contentstack/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from .HTTPConnection import HTTPConnection
1212
from .stack import Stack
1313

14-
__author__ = 'contentstack GmbH (Shailesh Mishra)'
14+
__author__ = 'contentstack - (www.github.con/contentstack)'
1515
__email__ = 'shailesh.mishra@contentstack.com'
1616
__version__ = '0.0.1'
1717
__endpoint__ = 'cdn.contentstack.io'

contentstack/config.py

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,38 +29,33 @@
2929
class Config(object):
3030

3131
SDK_VERSION = '[0.0.1]'
32-
SDK_NAME = 'contentstack-python'
3332

3433
def __init__(self):
35-
self.host_url = 'cdn.contentstack.io'
36-
self.api_version = 'v3'
37-
self.environment = None
38-
self.http_protocol = 'https://'
34+
self.host_url: str = 'cdn.contentstack.io'
35+
self.api_version: str = 'v3'
36+
self.http_protocol: str = 'https://'
3937

40-
def set_host(self, host_url='cdn.contentstack.io'):
41-
logging.info("set host")
38+
def set_host(self, host_url=None):
39+
logging.info("set host", host_url)
4240
if host_url is not None:
4341
self.host_url = host_url
44-
return self
45-
46-
def set_environment(self, environment):
47-
logging.info("set environment")
48-
if environment is not None:
49-
self.environment = environment
50-
return self
42+
return self
5143

5244
def get_host(self):
53-
logging.info('getting host url')
45+
logging.info('getting host url', self.host_url)
5446
return self.host_url
5547

5648
def get_version(self):
57-
logging.info('getting api version')
49+
logging.info('getting api version', self.api_version)
5850
return self.api_version
5951

60-
def get_environment(self):
61-
logging.info('get environment')
62-
return self.environment
63-
6452
def get_http_protocol(self):
65-
logging.info('get http protocol')
53+
logging.info('get http protocol', self.http_protocol)
6654
return self.http_protocol
55+
56+
def _get_endpoint(self):
57+
api_version: str = self.get_version()
58+
host_url = self.get_host()
59+
http_protocol = self.get_http_protocol()
60+
config_url = "{0}{1}/{2}/".format(http_protocol, host_url, api_version)
61+
return config_url

setup.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
from setuptools import setup
22

3+
package = 'contentstack'
4+
requirements = [
5+
'requests>=2.20.0,<3.0',
6+
'python-dateutil'
7+
]
38
setup(
49
name='contentstack-python',
510
version='',
6-
packages=['doc', 'tests'],
11+
packages=['contentstack', 'doc', 'tests'],
712
url='',
813
license='',
914
author='shailesh-mishra',
1015
author_email='',
11-
description=''
16+
description='', install_requires=['requests']
1217
)

0 commit comments

Comments
 (0)