29401f60e583 — Tyler G. Hicks-Wright 12 years ago
Add templates.
2 files changed, 30 insertions(+), 0 deletions(-)

A => api_class.mustache
A => trello_api.mustache
A => api_class.mustache +15 -0
@@ 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}}

          
A => trello_api.mustache +15 -0
@@ 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')