def __request(self, endpoint, method='GET', params=None, convJSON=False):
        """request - Returns dict of response from postcode.nl API.

        This method is called only by the EndpointMixin methods.
        """
        url = '%s/%s' % (self.api_url, endpoint)

        method = method.lower()
        params = params or {}
        if convJSON:
            params = json.dumps(params)

        func = getattr(self.client, method)
        request_args = {}
        if method == 'get':
            request_args['params'] = params
        else:
            request_args['data'] = params

        try:
            # Normally some valid HTTP-response will be the case
            # if not some exception regarding the request / connection has
            # occurred
            # this will be one of the exceptions of the request module
            # if so, we will a PostcodeError exception and pass the request
            # exception message
            response = func(url, **request_args)
        except requests.RequestException as e:
            raise PostcodeError("ERRrequest", {"exception": e.__doc__})

        content = response.content.decode('utf-8')

        content = json.loads(content)

        if response.status_code == 200:
            return content

        # Errors, otherwise we did not get here ...
        if 'exceptionId' in content:
            raise PostcodeError(content['exceptionId'], content)

        raise PostcodeError("UnknownExceptionFromPostcodeNl")
def __request ( self , endpoint , method = 'GET' , params = None , convJSON = False ) : url = '%s/%s' % ( self . api_url , endpoint ) method = method . lower ( ) params = params or { } if convJSON : params = json . dumps ( params ) func = getattr ( self . client , method ) request_args = { } if method == 'get' : request_args [ 'params' ] = params else : request_args [ 'data' ] = params try : response = func ( url , ** request_args ) except requests . RequestException as e : raise PostcodeError ( "ERRrequest" , { "exception" : e . __doc__ } ) content = response . content . decode ( 'utf-8' ) content = json . loads ( content ) if response . status_code == 200 : return content if 'exceptionId' in content : raise PostcodeError ( content [ 'exceptionId' ] , content ) raise PostcodeError ( "UnknownExceptionFromPostcodeNl" )
request - Returns dict of response from postcode.nl API.

        This method is called only by the EndpointMixin methods.