<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def call(self, method = '', params = None) : """ Call T411 API """

        
        # authentification request
        if method == 'auth' :
            req = requests.post(API_URL % method, data=params)

        # download torrent request
        elif 'download' in method:
            torrentid = os.path.basename(method)
            
            # build torrent's filename
            if 'directory' in params and params['directory'] is not None:
                torrentfile = os.path.join(params['directory'], params['filename'] + '.torrent')
            else:                    
                torrentfile =  params['filename'] + '.torrent'

            logging.info("Downloading torrent %s to file : %s"  %(torrentid, torrentfile))
            try:
                with open(torrentfile, 'wb') as handle:
                    req = requests.get(API_URL % method, 
                        headers={'Authorization': '%s' %self.user_credentials['token']})
                    
                    if req.status_code == requests.codes.OK:
                        torrent_data = None
                        try:
                            req_json = req.json()
                            if 'error' in req_json:
                                logging.error('Got an error response from t411 server: %s' %req_json['error'])
                        except ValueError:
                            # unable to jsonify it, we considere response is the torrent file.
                            # just download it
                            torrent_data = ''
                            for block in req.iter_content(1024):
                                if not block:
                                    break
                                handle.write(block)
                                torrent_data += block
                            
                            print("Download success. Torrent file saved to '%s'" % torrentfile)
                        return base64.b64encode(torrent_data)
                    else:
                        logging.error('Invalid response status_code : %s' (req.status_code)) 
            except Exception as e:
                logging.error('Download of torrent %s failed : %s' %(torrentid, e.message))
                raise T411Exception(e.message)     

        # other type requests : include Authorizaton credentials to the request
        else:
            req = requests.post(API_URL % method, data=params, 
                headers={'Authorization': self.user_credentials['token']}  )    

        if req.status_code == requests.codes.OK:
            return req.json()
        else :
            raise T411Exception('Error while sending %s request: HTTP %s' % \
                    (method, req.status_code))