Esempio n. 1
0
    def _do_request(self, headers, body):
        try:
            request = http.Request(self._url,
                                   headers=headers,
                                   data=json.dumps(body).encode())

            response = http.urlopen(request).read()
        except Exception as e:
            raise exceptions.KanboardClientException(str(e))
        return self._parse_response(response)
Esempio n. 2
0
    def _parse_response(response):
        try:
            body = json.loads(response.decode())

            if 'error' in body:
                message = body.get('error').get('message')
                raise exceptions.KanboardClientException(message)

            return body.get('result')
        except ValueError:
            return None