* sending body data as prepared json to
- removing pointless asserts - removed unused param in Request.make
This commit is contained in:
parent
aaa1378af8
commit
84ac9883d1
@ -66,7 +66,6 @@ class Response:
|
|||||||
|
|
||||||
class Request:
|
class Request:
|
||||||
def __init__(self, method: str, url: str, params: dict):
|
def __init__(self, method: str, url: str, params: dict):
|
||||||
assert(domain[len(domain) - 1] != '/')
|
|
||||||
assert(method in ['get', 'post', 'delete'])
|
assert(method in ['get', 'post', 'delete'])
|
||||||
|
|
||||||
self.method = method
|
self.method = method
|
||||||
@ -77,21 +76,22 @@ class Request:
|
|||||||
# Lower driver for actuall making the request we are looking for
|
# Lower driver for actuall making the request we are looking for
|
||||||
method = method.lower()
|
method = method.lower()
|
||||||
|
|
||||||
|
params = json.dumps(self.params)
|
||||||
if method == 'get':
|
if method == 'get':
|
||||||
resp = requests.get(self.url, data=self.params)
|
resp = requests.get(self.url, data=params)
|
||||||
return Response(self.url, resp.body, resp.status_code, hope)
|
return Response(self.url, resp.text, resp.status_code, hope)
|
||||||
elif method == 'post':
|
elif method == 'post':
|
||||||
resp = requests.post(self.url, data=self.params)
|
resp = requests.post(self.url, data=self)
|
||||||
return Response(self.url, resp.body, resp.status_code, hope)
|
return Response(self.url, resp.text, resp.status_code, hope)
|
||||||
elif method == 'delete':
|
elif method == 'delete':
|
||||||
resp = requests.delete(self.url, data=self.params)
|
resp = requests.delete(self.url, data=params)
|
||||||
return Response(self.url, resp.body, resp.status_code, hope)
|
return Response(self.url, resp.text, resp.status_code, hope)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise RequestError('Invalid method passed')
|
raise RequestError('Invalid method passed')
|
||||||
|
|
||||||
|
|
||||||
def make(self, hope: int, auth: str) -> Response:
|
def make(self, hope: int) -> Response:
|
||||||
'''
|
'''
|
||||||
@param hope: int -> status code we hope to get back
|
@param hope: int -> status code we hope to get back
|
||||||
@return Response -> Wrapper around server http response
|
@return Response -> Wrapper around server http response
|
||||||
|
Loading…
Reference in New Issue
Block a user