@@ -0,0 +1,1639 @@
+try:%0A%09import simplejson as json%0Aexcept ImportError:%0A%09import json%0Aimport requests%0A%0Afrom scup.exceptions import *%0Afrom scup.auth import get_request_signature%0A%0A%0Aclass ScupAPI(object):%0A%09def __init__(self, private_key, public_key, url='http://api.scup.com/1.1', timeout=None):%0A%09%09%22%22%22%0A%09%09Initialize ScupAPI with user's private and public keys.%0A%0A%09%09:param private_key: User's private key, obtained by contacting a Scup representative.%0A%09%09:param public_key: User's public key, obtained by contacting a Scup representative.%0A%09%09%22%22%22%0A%0A%09%09self.private_key = private_key%0A%09%09self.public_key = public_key%0A%09%09self.url = url.strip('/')%0A%09%09self.timeout = timeout%0A%0A%09def _request(self, method, path, params):%0A%09%09if params:%0A%09%09%09for key in params:%0A%09%09%09%09value = params%5Bkey%5D%0A%09%09%09%09if isinstance(value, (list, dict, set)):%0A%09%09%09%09%09params%5Bkey%5D = json.dumps(value)%0A%0A%09%09# Generate auth params%0A%09%09time, signature = get_request_signature(self.private_key)%0A%0A%09%09# Add auth params to request%0A%09%09params%5B'time'%5D = time%0A%09%09params%5B'signature'%5D = signature%0A%0A%09%09try:%0A%09%09%09if method == 'GET':%0A%09%09%09%09response = self.session.request(%0A%09%09%09%09%09method %09%09%09%09%09= method,%0A%09%09%09%09%09url %09%09%09%09%09%09= self.url + path,%0A%09%09%09%09%09params %09%09%09%09%09= params,%0A%09%09%09%09%09allow_redirects = True,%0A%09%09%09%09%09timeout %09%09%09%09= self.timeout,%0A%09%09%09%09%09headers %09%09%09%09= self.headers%0A%09%09%09%09)%0A%09%09%09# TODO: implement other methods%0A%09%09%09if method in %5B'POST', 'PUT', 'DELETE'%5D:%0A%09%09%09%09raise Exception('TODO: implement other methods')%0A%0A%09%09except requests.RequestException as e:%0A%09%09%09raise HTTPError(e)%0A%0A%09%09result = self._parse(response.content)%0A%0A%09%09return result%0A%0A%09def _parse(self, data):%0A%09%09if type(data) == type(bytes()):%0A%09%09%09data = data.decode('utf-8')%0A%09%09data = json.loads(data)%0A%0A%09%09return data%0A%0A

implement initial ScupAPI class with base _request and _parse methods