1 '''
2 Copyright 2012 Alexey Kravets <mr.kayrick@gmail.com>
3
4 This file is part of PythonMindmeister.
5
6 PythonMindmeister is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 PythonMindmeister is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with PythonMindmeister. If not, see <http://www.gnu.org/licenses/>.
18
19 This file contains internal PythonMindmeister function, which perform correct
20 calls to the mindmeister.org API interface.
21 Additional information can be found by this URL:
22 http://www.mindmeister.com/developers/authentication
23
24 This product uses the MindMeister API but is not endorsed or certified
25 by MindMeister.
26 '''
27
28
29 from repr import repr
30
31 '''
32 Base URL to be used to access mindmeister API services.
33 '''
34 BaseUrl = "http://www.mindmeister.com/services"
35
36 from hashlib import md5
37 from urllib2 import urlopen, build_opener, ProxyHandler
38 from urllib import quote
39
41 '''
42 Calculate API signature of the parameters list.
43
44 Arguments:
45 secret -- shared secret to be used for calculation.
46 Optional (keyword) Arguments -- any arguments.
47 '''
48 builder = secret
49 keys = params.keys()
50 keys.sort()
51 for iter in keys:
52 if params[iter] == None:
53 continue
54 builder = builder + iter + str (params[iter])
55 return md5(builder).hexdigest()
56
58 '''
59 Create URL with request for mindmeister API.
60
61 Arguments:
62 service -- service mindmeister service to use.
63 secret -- shared secret
64 Optional (keyword) Arguments -- any service parameters
65 '''
66 builder = BaseUrl + "/" + service + "?"
67 for iter in params.keys():
68 if params[iter] == None:
69 continue
70 builder = builder + iter + "=" + str (params[iter]) + "&"
71 if secret != None:
72 api_sig = calculateApiSig(secret, **params)
73 return builder + "api_sig=" + api_sig
74 else:
75 return builder
76
93
112