Trello » TrelloPy
Clone URL:  
Pushed to one repository · View In Graph Contained in tip

Add templates.

Changeset 29401f60e583

Parent 9a7d8ef3a0c5

by Profile picture of User 10Tyler G. Hicks-Wright <tghw@fogcreek.com>

Changes to 2 files · Browse files at 29401f60e583 Showing diff from parent 9a7d8ef3a0c5 Diff from another changeset...

Change 1 of 1 Show Entire File api_class.mustache Stacked
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
@@ -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}}
Change 1 of 1 Show Entire File trello_api.mustache Stacked
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
@@ -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')