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 MindMeister API calls for maps. Additional information can
20 be found by this URL:
21 http://www.mindmeister.com/developers/explore
22
23 This product uses the MindMeister API but is not endorsed or certified
24 by MindMeister.
25 '''
26
27
28 import common
29 import parser
30 from objects import Map, FullMap, Revision
31 from diagnostic import MindException
32
34 '''
35 Returns the list of maps of the current user.
36
37 Arguments:
38 Optional (keyword) Arguments:
39 expand_people
40 include_folder
41 page
42 per_page
43 query
44
45 This function calls mm.maps.add MindMeister API method
46 More documentation can be found by this URL:
47 http://www.mindmeister.com/developers/explore_method?method=mm.maps.getList
48 '''
49 rawResult = common.performRequest("rest", token, method = "mm.maps.getList")
50
51 root = parser.parse(rawResult)
52 if root.attrib['stat'] != "ok":
53 raise MindException ('mm.maps.getList', root[0])
54 else:
55 return map (lambda curr: Map (curr), root[0])
56
57
59 '''
60 Creates a map.
61
62 Arguments:
63 Optional (keyword) Arguments:
64
65 This function calls mm.maps.add MindMeister API method
66 More documentation can be found by this URL:
67 http://www.mindmeister.com/developers/explore_method?method=mm.maps.add
68 '''
69 rawResult = common.performRequest ("rest", token, method="mm.maps.add")
70
71 root = parser.parse (rawResult)
72 if root.attrib['stat'] != "ok":
73 raise MindException('mm.maps.add', root[0])
74 else:
75 return Map(root[0])
76
77
79 '''
80 Deletes a map.
81
82 Arguments:
83 map_id
84 Optional (keyword) Arguments:
85
86 This function calls mm.maps.delete MindMeister API method
87 More documentation can be found by this URL:
88 http://www.mindmeister.com/developers/explore_method?method=mm.maps.delete
89 '''
90 rawResult = common.performRequest ("rest", token, method="mm.maps.delete", map_id = map_id)
91
92 root = parser.parse (rawResult)
93 if root.attrib['stat'] != "ok":
94 raise MindException ('mm.maps.delete', root[0])
95
97 '''
98 Duplicates a map.
99
100 Arguments:
101 map_id
102 Optional (keyword) Arguments:
103 revision
104
105 This function calls mm.maps.duplicate MindMeister API method
106 More documentation can be found by this URL:
107 http://www.mindmeister.com/developers/explore_method?method=mm.maps.duplicate
108 '''
109 rawResult = common.performRequest ("rest", token, method="mm.maps.duplicate", map_id = map_id)
110
111 root = parser.parse (rawResult)
112 if root.attrib['stat'] != "ok":
113 raise MindException ('mm.maps.duplicate', root[0])
114 else:
115 return Map(root[0])
116
117 -def getMap (token, map_id, **args):
118 '''
119 Get all ideas of a map.
120
121 Arguments:
122 map_id
123 Optional (keyword) Arguments:
124 expand_people
125 include_folder
126 include_theme
127 revision
128
129 This function calls mm.maps.getMap MindMeister API method
130 More documentation can be found by this URL:
131 http://www.mindmeister.com/developers/explore_method?method=mm.maps.getMap
132 '''
133 rawResult = common.performRequest ("rest", token, method="mm.maps.getMap", map_id = map_id, **args)
134
135 root = parser.parse (rawResult)
136 if root.attrib['stat'] != "ok":
137 raise MindException('mm.maps.getMap', root[0])
138 else:
139 return FullMap(root)
140
141 -def undo (token, map_id):
142 '''
143 Undo last modification on map.
144
145 Arguments:
146 map_id
147 Optional (keyword) Arguments:
148
149 This function calls mm.maps.undo MindMeister API method
150 More documentation can be found by this URL:
151 http://www.mindmeister.com/developers/explore_method?method=mm.maps.undo
152 '''
153 rawResult = common.performRequest ("rest", token, method="mm.maps.undo", map_id = map_id)
154
155 root = parser.parse (rawResult)
156 if root.attrib['stat'] != "ok":
157 raise MindException ('mm.maps.undo', root[0])
158
159 -def redo (token, map_id):
160 '''
161 Redo last modification on map.
162
163 Arguments:
164 map_id
165 Optional (keyword) Arguments:
166
167 This function calls mm.maps.redo MindMeister API method
168 More documentation can be found by this URL:
169 http://www.mindmeister.com/developers/explore_method?method=mm.maps.redo
170 '''
171 rawResult = common.performRequest ("rest", token, method="mm.maps.redo", map_id = map_id)
172
173 root = parser.parse (rawResult)
174 if root.attrib['stat'] != "ok":
175 raise MindException ('mm.maps.redo', root[0])
176
178 '''
179 Inserts a Geistesblitz in the default map.
180
181 Arguments:
182 title
183 Optional (keyword) Arguments:
184
185 This function calls mm.maps.insertGeistesblitz MindMeister API method
186 More documentation can be found by this URL:
187 http://www.mindmeister.com/developers/explore_method?method=mm.maps.insertGeistesblitz
188 '''
189 rawResult = common.performRequest ("rest", token, method="mm.maps.insertGeistesblitz", title = title)
190
191 root = parser.parse (rawResult)
192 if root.attrib['stat'] != "ok":
193 raise MindException ('mm.maps.insertGeistesblitz', root[0])
194
195 -def history (token, map_id, **args):
196 '''
197 Gets the revisions of a map.
198
199 Arguments:
200 map_id
201 Optional (keyword) Arguments:
202 only_last
203 show_redo
204
205 This function calls mm.maps.history MindMeister API method
206 More documentation can be found by this URL:
207 http://www.mindmeister.com/developers/explore_method?method=mm.maps.history
208 '''
209 rawResult = common.performRequest ("rest", token, method="mm.maps.history", map_id = map_id, **args)
210
211 root = parser.parse (rawResult)
212 if root.attrib['stat'] != "ok":
213 raise MindException ('mm.maps.history', root[0])
214 else:
215 return map (lambda curr: Revision(curr), root[0])
216