# HG changeset patch # User Tyler G. Hicks-Wright # Date 1332371944 21600 # Wed Mar 21 17:19:04 2012 -0600 # Node ID 29401f60e583d1ffe95d8704314b9d5a307cc192 # Parent 9a7d8ef3a0c5e6f4f5a1d00e80908876f26baf0b Add templates. diff --git a/api_class.mustache b/api_class.mustache new file mode 100644 --- /dev/null +++ b/api_class.mustache @@ -0,0 +1,15 @@ +import json +import requests + +class {{class_name}}(object): + def __init__(self, apikey, token=None): + self._apikey = apikey + self._token = token + + {{#methods}} + def {{name}}(self, {{def_args}}): + resp = requests.{{method}}({{url}}, {{args}}) + resp.raise_for_status() + return json.loads(resp.content) + + {{/methods}} diff --git a/trello_api.mustache b/trello_api.mustache new file mode 100644 --- /dev/null +++ b/trello_api.mustache @@ -0,0 +1,15 @@ +from urllib import quote_plus +{{#sections}} +from .{{module}} import {{class}} +{{/sections}} + +class TrelloApi(object): + def __init__(self, apikey, token=None): + self._apikey = apikey + self._token = token + {{#sections}} + self.{{module}} = {{class}}(apikey, token) + {{/sections}} + + def get_token_url(self, app_name, expires='30days', write_access=True): + return 'https://trello.com/1/authorize?key=%s&name=%s&expiration=%s&response_type=token&scope=%s' % (self._apikey, quote_plus(app_name), expires, 'read,write' if write_access else 'read')