def _request(self, url, values=None):
        """ Send a request and read response.

            Sends a get request if values are None, post request otherwise.
        """
        if values:
            json_data = json.dumps(values)
            request = urllib2.Request(url, json_data.encode())
            request.add_header('content-type', 'application/json')
            request.add_header('authorization', self._auth)
            connection = urllib2.urlopen(request)
            response = connection.read()
            connection.close()
        else:
            request = urllib2.Request(url)
            request.add_header('authorization', self._auth)
            connection = urllib2.urlopen(request)
            response = connection.read()
            connection.close()

        try:
            result = json.loads(response.decode())
        except ValueError as exception:
            return {'errorCode': 1, 'message': str(exception)}

        return result
def _request ( self , url , values = None ) : if values : json_data = json . dumps ( values ) request = urllib2 . Request ( url , json_data . encode ( ) ) request . add_header ( 'content-type' , 'application/json' ) request . add_header ( 'authorization' , self . _auth ) connection = urllib2 . urlopen ( request ) response = connection . read ( ) connection . close ( ) else : request = urllib2 . Request ( url ) request . add_header ( 'authorization' , self . _auth ) connection = urllib2 . urlopen ( request ) response = connection . read ( ) connection . close ( ) try : result = json . loads ( response . decode ( ) ) except ValueError as exception : return { 'errorCode' : 1 , 'message' : str ( exception ) } return result
Send a request and read response.

            Sends a get request if values are None, post request otherwise.