<s> import requests <EOL> import slack <EOL> from slack . exception import SlackError , InvalidAuthError , NotAuthedError , AccountInactiveError , ChannelNotFoundError , ChannelArchivedError , NotInChannelError , RateLimitedError <EOL> def get ( method , params ) : <EOL> url = _build_url ( method ) <EOL> response = requests . get ( url , params = params , verify = True ) <EOL> return _parse_response ( response ) <EOL> def post ( method , data ) : <EOL> url = _build_url ( method ) <EOL> response = requests . post ( url , data = data , verify = True ) <EOL> return _parse_response ( response ) <EOL> def _parse_response ( response ) : <EOL> try : <EOL> response = response . json ( ) <EOL> except ValueError as e : <EOL> response = { '<STR_LIT>' : False , '<STR_LIT:error>' : e } <EOL> _raise_error_if_not_ok ( response ) <EOL> return response <EOL> def _build_url ( method ) : <EOL> return '<STR_LIT>' % ( slack . api_base_url , method ) <EOL> def _raise_error_if_not_ok ( response ) : <EOL> if response [ '<STR_LIT>' ] : <EOL> return <EOL> if response [ '<STR_LIT:error>' ] == '<STR_LIT>' : <EOL> raise InvalidAuthError ( ) <EOL> if response [ '<STR_LIT:error>' ] == '<STR_LIT>' : <EOL> raise NotAuthedError ( ) <EOL> if response [ '<STR_LIT:error>' ] == '<STR_LIT>' : <EOL> raise AccountInactiveError ( ) <EOL> if response [ '<STR_LIT:error>' ] == '<STR_LIT>' : <EOL> raise ChannelNotFoundError ( ) <EOL> if response [ '<STR_LIT:error>' ] == '<STR_LIT>' : <EOL> raise ChannelArchivedError ( ) <EOL> if response [ '<STR_LIT:error>' ] == '<STR_LIT>' : <EOL> raise NotInChannelError ( ) <EOL> if response [ '<STR_LIT:error>' ] == '<STR_LIT>' : <EOL> raise RateLimitedError ( ) <EOL> raise SlackError ( response [ '<STR_LIT:error>' ] ) </s>
