Example #1
0
    def delete(self, url: str, headers: Dict) -> HTTPResponse:
        """Method to create a 'DELETE' API request and returns response.

        Args:
            url (String): Base URL for the API Request.
            headers (Dict): Headers passed with the API Request.
        Returns:
            response (HTTPResponse): HTTP Response after the API Request.
        """
        s = Session()
        request = Request('DELETE', url, headers=headers)
        prepared_req = request.prepare()

        response = s.send(prepared_req)
        http_response = HTTPResponse()
        http_response._response = response
        return http_response
Example #2
0
    def post(self, url: str, body: str, headers: Dict) -> HTTPResponse:
        """Method to create a 'POST' API request and returns response.

        Args:
            url (String): Base URL for the API Request.
            body (Dict): Data for the body passed with the API Request.
            headers (Dict): Headers passed with the API Request.
        Returns:
            response (HTTPResponse): HTTP Response after the API Request.
        """
        s = Session()
        request = Request('POST', url, data=body, headers=headers)
        prepared_req = request.prepare()

        response = s.send(prepared_req)
        http_response = HTTPResponse()
        http_response._response = response
        return http_response