<s> from httplib2 import Http <EOL> from urllib import quote <EOL> from simplejson import dumps , loads <EOL> from settings import Settings <EOL> class Request ( object ) : <EOL> @ classmethod <EOL> def get ( self , path , parameters = { } ) : <EOL> parameters [ '<STR_LIT>' ] = Settings . public_token <EOL> query_string = '<STR_LIT:&>' . join ( [ k + '<STR_LIT:=>' + quote ( str ( v ) ) for ( k , v ) in parameters . items ( ) ] ) <EOL> path = "<STR_LIT>" % ( Settings . host , path , query_string , ) <EOL> return self . request ( path ) <EOL> @ classmethod <EOL> def post ( self , path , parameters = { } ) : <EOL> parameters [ '<STR_LIT>' ] = Settings . private_token <EOL> path = "<STR_LIT>" % ( Settings . host , path , ) <EOL> options = { <EOL> '<STR_LIT>' : '<STR_LIT:POST>' , <EOL> '<STR_LIT:body>' : dumps ( parameters ) , <EOL> '<STR_LIT>' : { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } <EOL> } <EOL> return self . request ( path , options ) <EOL> @ classmethod <EOL> def delete ( self , path ) : <EOL> path = "<STR_LIT>" % ( Settings . host , path , ) <EOL> options = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:body>' : dumps ( { '<STR_LIT>' : Settings . private_token } ) , <EOL> '<STR_LIT>' : { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } <EOL> } <EOL> return self . request ( path , options ) <EOL> @ classmethod <EOL> def request ( self , path , options = { } ) : <EOL> client = Http ( ) <EOL> if len ( options ) == <NUM_LIT:0> : <EOL> resp , content = client . request ( path ) <EOL> else : <EOL> resp , content = client . request ( <EOL> path , <EOL> options [ '<STR_LIT>' ] , <EOL> body = options [ '<STR_LIT:body>' ] , <EOL> headers = options [ '<STR_LIT>' ] <EOL> ) <EOL> try : <EOL> return loads ( content ) <EOL> except : <EOL> return content </s>
