zohoProjects 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +15 -0
  2. data/Gemfile +4 -0
  3. data/Gemfile.lock +17 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +145 -0
  6. data/Rakefile +2 -0
  7. data/lib/projects/api/API.rb +57 -0
  8. data/lib/projects/api/BugsAPI.rb +135 -0
  9. data/lib/projects/api/DocumentsAPI.rb +145 -0
  10. data/lib/projects/api/EventsAPI.rb +115 -0
  11. data/lib/projects/api/FoldersAPI.rb +111 -0
  12. data/lib/projects/api/ForumsAPI.rb +198 -0
  13. data/lib/projects/api/MilestonesAPI.rb +159 -0
  14. data/lib/projects/api/PortalAPI.rb +41 -0
  15. data/lib/projects/api/ProjectsAPI.rb +203 -0
  16. data/lib/projects/api/TasklistsAPI.rb +113 -0
  17. data/lib/projects/api/TasksAPI.rb +153 -0
  18. data/lib/projects/api/TimesheetsAPI.rb +240 -0
  19. data/lib/projects/api/UsersAPI.rb +48 -0
  20. data/lib/projects/exception/ProjectsException.rb +50 -0
  21. data/lib/projects/model/Activity.rb +173 -0
  22. data/lib/projects/model/Bug.rb +701 -0
  23. data/lib/projects/model/Buglog.rb +56 -0
  24. data/lib/projects/model/Category.rb +70 -0
  25. data/lib/projects/model/Comment.rb +289 -0
  26. data/lib/projects/model/Document.rb +260 -0
  27. data/lib/projects/model/Event.rb +391 -0
  28. data/lib/projects/model/Folder.rb +110 -0
  29. data/lib/projects/model/Forum.rb +320 -0
  30. data/lib/projects/model/Generallog.rb +36 -0
  31. data/lib/projects/model/Log.rb +359 -0
  32. data/lib/projects/model/Milestone.rb +322 -0
  33. data/lib/projects/model/Owner.rb +54 -0
  34. data/lib/projects/model/Participant.rb +54 -0
  35. data/lib/projects/model/Portal.rb +273 -0
  36. data/lib/projects/model/Project.rb +593 -0
  37. data/lib/projects/model/Status.rb +168 -0
  38. data/lib/projects/model/Task.rb +497 -0
  39. data/lib/projects/model/Tasklist.rb +300 -0
  40. data/lib/projects/model/Tasklog.rb +56 -0
  41. data/lib/projects/model/Timelog.rb +134 -0
  42. data/lib/projects/model/TimelogList.rb +54 -0
  43. data/lib/projects/model/User.rb +94 -0
  44. data/lib/projects/model/Version.rb +194 -0
  45. data/lib/projects/parser/BugParser.rb +208 -0
  46. data/lib/projects/parser/DocumentParser.rb +197 -0
  47. data/lib/projects/parser/EventParser.rb +156 -0
  48. data/lib/projects/parser/FolderParser.rb +99 -0
  49. data/lib/projects/parser/ForumParser.rb +253 -0
  50. data/lib/projects/parser/MilestonesParser.rb +129 -0
  51. data/lib/projects/parser/PortalParser.rb +103 -0
  52. data/lib/projects/parser/ProjectParser.rb +318 -0
  53. data/lib/projects/parser/TaskParser.rb +293 -0
  54. data/lib/projects/parser/TasklistParser.rb +127 -0
  55. data/lib/projects/parser/TimesheetParser.rb +390 -0
  56. data/lib/projects/parser/UserParser.rb +63 -0
  57. data/lib/projects/service/ZohoProject.rb +174 -0
  58. data/lib/projects/util/ZohoHTTPClient.rb +205 -0
  59. data/lib/test/ProjectsTest.rb +321 -0
  60. data/lib/zohoProjects.rb +35 -0
  61. data/lib/zohoProjects/version.rb +3 -0
  62. data/zohoProjects.gemspec +86 -0
  63. metadata +135 -0
@@ -0,0 +1,127 @@
1
+ # $Id$
2
+ module Projects
3
+ module Parser
4
+
5
+ require 'json'
6
+ require File.dirname(__FILE__).chomp("/projects/parser") + '/projects/model/Tasklist'
7
+
8
+ # * Parse the JSON response into respective objects.
9
+
10
+ class TasklistParser
11
+ include Projects::Model
12
+
13
+ # * Parse the JSON response and make it into List of Tasklist object.
14
+ #
15
+ # ==== Parameters
16
+ #
17
+ # * response:: - This JSON response contains the details of task lists.
18
+ #
19
+ # ==== Returns
20
+ #
21
+ # * List of TaskList object.
22
+
23
+ def getTasklists(response)
24
+ tasklists_all_json = JSON.parse response
25
+ tasklists_all_array = tasklists_all_json["tasklists"]
26
+ tasklists_class_array = Array.new
27
+ for i in 0...tasklists_all_array.length
28
+ tasklists_class_array.push(jsonToTasklist(tasklists_all_array[i]))
29
+ end
30
+ return tasklists_class_array
31
+ end
32
+
33
+ # * Parse the JSON response and make it into Tasklist object.
34
+ #
35
+ # ==== Parameters
36
+ #
37
+ # * response:: - This JSON response contains the details of a task list.
38
+ #
39
+ # ==== Returns
40
+ #
41
+ # * Tasklist object.
42
+
43
+ def getTasklist(response)
44
+ tasklists_json = JSON.parse response
45
+ tasklists_array = tasklists_json["tasklists"]
46
+ return jsonToTasklist(tasklists_array[0])
47
+ end
48
+
49
+ # * Parse the JSONObject into Tasklist object.
50
+ #
51
+ # ==== Parameters
52
+ #
53
+ # * jsonObject:: - JSONObject contains the details of a task list.
54
+ #
55
+ # ==== Returns
56
+ #
57
+ # * Tasklist object.
58
+
59
+ def jsonToTasklist(jsonObject)
60
+ tasklist = Tasklist.new
61
+
62
+ if jsonObject.has_key?("id")
63
+ tasklist.setId(jsonObject["id"])
64
+ end
65
+ if jsonObject.has_key?("name")
66
+ tasklist.setName(jsonObject["name"])
67
+ end
68
+ if jsonObject.has_key?("completed")
69
+ tasklist.setCompleted(jsonObject["completed"])
70
+ end
71
+ if jsonObject.has_key?("created_time")
72
+ tasklist.setCreatedTime(jsonObject["created_time"])
73
+ end
74
+ if jsonObject.has_key?("created_time_format")
75
+ tasklist.setCreatedTimeFormat(jsonObject["created_time_format"])
76
+ end
77
+ if jsonObject.has_key?("created_time_long")
78
+ tasklist.setCreatedTimeLong(jsonObject["created_time_long"])
79
+ end
80
+ if jsonObject.has_key?("rolled")
81
+ tasklist.setRolled(jsonObject["rolled"])
82
+ end
83
+ if jsonObject.has_key?("sequence")
84
+ tasklist.setSequence(jsonObject["sequence"])
85
+ end
86
+ if jsonObject.has_key?("flag")
87
+ tasklist.setFlag(jsonObject["flag"])
88
+ end
89
+
90
+ if jsonObject.has_key?("link")
91
+ link = jsonObject["link"]
92
+
93
+ if link.has_key?("self")
94
+ tasklist.setURL(link["self"]["url"])
95
+ end
96
+ if link.has_key?("task")
97
+ tasklist.setTaskURL(link["task"]["url"])
98
+ end
99
+ end
100
+
101
+
102
+ if jsonObject.has_key?("milestone")
103
+ milestoneParser = MilestonesParser.new
104
+ milestone = jsonObject["milestone"]
105
+ tasklist.setMilestone(milestoneParser.jsonToMilestone(milestone))
106
+ end
107
+ return tasklist
108
+ end
109
+
110
+ # * Parse the JSON response and get the success message.
111
+ #
112
+ # ==== Parameters
113
+ #
114
+ # * response:: - This JSON response contains the success message.
115
+ #
116
+ # ==== Returns
117
+ #
118
+ # * String object.
119
+
120
+ def getResult(response)
121
+ jsonObject = JSON.parse response
122
+ result = jsonObject["response"]
123
+ return result
124
+ end
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,390 @@
1
+ # $Id$
2
+ module Projects
3
+ module Parser
4
+
5
+ require 'json'
6
+ require File.dirname(__FILE__).chomp("/projects/parser") + '/projects/model/Buglog'
7
+ require File.dirname(__FILE__).chomp("/projects/parser") + '/projects/model/Generallog'
8
+ require File.dirname(__FILE__).chomp("/projects/parser") + '/projects/model/Tasklog'
9
+ require File.dirname(__FILE__).chomp("/projects/parser") + '/projects/model/Timelog'
10
+ require File.dirname(__FILE__).chomp("/projects/parser") + '/projects/model/TimelogList'
11
+
12
+ # * Parse the JSON response into respective objects.
13
+
14
+ class TimesheetParser
15
+ include Projects::Model
16
+
17
+ # * Parse the JSON response and make it into TimelogList object.
18
+ #
19
+ # ==== Parameters
20
+ #
21
+ # * response:: - This JSON response contains the details of time logs.
22
+ #
23
+ # ==== Returns
24
+ #
25
+ # * TimelogList object.
26
+
27
+ def getTimeLogs(response)
28
+ timeLogs_json = JSON.parse response
29
+ timeLogs_array = timeLogs_json["timelogs"]
30
+ return jsonToTimelogList(timeLogs_array)
31
+ end
32
+
33
+ # * Parse the JSON response and make it into Tasklog object.
34
+ #
35
+ # ==== Parameters
36
+ #
37
+ # * response:: - This JSON response contains the details of a task log.
38
+ #
39
+ # ==== Returns
40
+ #
41
+ # * Tasklog object.
42
+
43
+ def getTasklog(response)
44
+ timeLogs_json = JSON.parse response
45
+ tasklogs_array = timeLogs_json["timelogs"]["tasklogs"]
46
+ return jsonToTasklog(tasklogs_array[0])
47
+ end
48
+
49
+ # * Parse the JSON response and make it into the Buglog object.
50
+ #
51
+ # ==== Parameters
52
+ #
53
+ # * response:: - This JSON response contains the details of bug log.
54
+ #
55
+ # ==== Returns
56
+ #
57
+ # * Buglog object.
58
+
59
+ def getBuglog(response)
60
+ timeLogs_json = JSON.parse response
61
+ buglogs_array = timeLogs_json["timelogs"]["buglogs"]
62
+ return jsonToBuglog(buglogs_array[0])
63
+ end
64
+
65
+ # * Parse the JSON response and make it into the Generallog object.
66
+ #
67
+ # ==== Parameters
68
+ #
69
+ # * response:: - This JSON response contains the details of a general log.
70
+ #
71
+ # ==== Returns
72
+ #
73
+ # * Generallog object.
74
+
75
+ def getGenerallog(response)
76
+ timeLogs_json = JSON.parse response
77
+ generallogs_array = timeLogs_json["timelogs"]["generallogs"]
78
+ return jsonToGenerallog(generallogs_array[0])
79
+ end
80
+
81
+ # * Parse the JSONObject into timlogList object.
82
+ #
83
+ # ==== Parameters
84
+ #
85
+ # * jsonObject:: - JSONObject contains the details of a time logs.
86
+ #
87
+ # ==== Returns
88
+ #
89
+ # * TimelogList object.
90
+
91
+ def jsonToTimelogList(jsonObject)
92
+ timelogList = TimelogList.new
93
+
94
+ if jsonObject.has_key?("grandtotal")
95
+ timelogList.setGrandtotal(jsonObject["grandtotal"])
96
+ end
97
+
98
+ if jsonObject.has_key?("role")
99
+ timelogList.setRole(jsonObject["role"])
100
+ end
101
+
102
+ if jsonObject.has_key?("date")
103
+
104
+ date = jsonObject["date"]
105
+
106
+ timelogObj = Timelog.new
107
+
108
+ for i in 0...date.length
109
+ dateObj = date[i]
110
+
111
+ if dateObj.has_key?("date_long")
112
+ timelogObj.setDateLong(dateObj["date_long"])
113
+ end
114
+ if dateObj.has_key?("display_format")
115
+ timelogObj.setDisplayFormat(dateObj["display_format"])
116
+ end
117
+ if dateObj.has_key?("total_hours")
118
+ timelogObj.setTotalHours(dateObj["total_hours"])
119
+ end
120
+
121
+ if dateObj.has_key?("buglogs")
122
+ buglogs = dateObj["buglogs"]
123
+
124
+ buglogList = Array.new
125
+
126
+ for j in 0...buglogs.length
127
+ buglog = buglogs[j]
128
+ buglogList.push(jsonToBuglog(buglog))
129
+ end
130
+
131
+ timelogObj.setBuglogs(buglogList)
132
+ end
133
+
134
+ if dateObj.has_key?("tasklogs")
135
+ tasklogs = dateObj["tasklogs"]
136
+
137
+ tasklogList = Array.new
138
+
139
+ for k in 0...tasklogs.length
140
+ tasklog = tasklogs[k]
141
+ tasklogList.push(jsonToTasklog(tasklog))
142
+ end
143
+
144
+ timelogObj.setTasklogs(tasklogList)
145
+ end
146
+
147
+ if dateObj.has_key?("generallogs")
148
+ generallogs = dateObj["generallogs"]
149
+
150
+ generallogList = Array.new
151
+
152
+ for l in 0...generallogs.length
153
+ generallog = generallogs[l]
154
+ generallogList.push(jsonToGenerallog(generallog))
155
+ end
156
+
157
+ timelogObj.setGenerallogs(generallogList)
158
+ end
159
+ timelogList.push(timelogObj)
160
+ end
161
+ end
162
+
163
+ return timelogList
164
+ end
165
+
166
+ # * Parse the JSONObject into Buglog object.
167
+ #
168
+ # ==== Parameters
169
+ #
170
+ # * jsonObject:: - JSONObject contains the details of a bug log.
171
+ #
172
+ # ==== Returns
173
+ #
174
+ # * Buglog object.
175
+
176
+ def jsonToBuglog(jsonObject)
177
+ buglog = Buglog.new
178
+
179
+ if jsonObject.has_key?("id")
180
+ buglog.setId(jsonObject["id"])
181
+ end
182
+ if jsonObject.has_key?("notes")
183
+ buglog.setNotes(jsonObject["notes"])
184
+ end
185
+ if jsonObject.has_key?("log_date")
186
+ buglog.setLogDate(jsonObject["log_date"])
187
+ end
188
+ if jsonObject.has_key?("log_date_long")
189
+ buglog.setLogDateLong(jsonObject["log_date_long"])
190
+ end
191
+ if jsonObject.has_key?("hours")
192
+ buglog.setHours(jsonObject["hours"])
193
+ end
194
+ if jsonObject.has_key?("minutes")
195
+ buglog.setMinutes(jsonObject["minutes"])
196
+ end
197
+ if jsonObject.has_key?("hours_display")
198
+ buglog.setHoursDisplay(jsonObject["hours_display"])
199
+ end
200
+ if jsonObject.has_key?("total_minutes")
201
+ buglog.setTotalMinutes(jsonObject["total_minutes"])
202
+ end
203
+ if jsonObject.has_key?("owner_id")
204
+ buglog.setOwnerId(jsonObject["owner_id"])
205
+ end
206
+ if jsonObject.has_key?("owner_name")
207
+ buglog.setOwnerName(jsonObject["owner_name"])
208
+ end
209
+ if jsonObject.has_key?("bill_status")
210
+ buglog.setBillStatus(jsonObject["bill_status"])
211
+ end
212
+
213
+ if jsonObject.has_key?("bug")
214
+ bug = jsonObject["bug"]
215
+
216
+ if bug.has_key?("id")
217
+ buglog.setBugId(bug["id"])
218
+ end
219
+ if bug.has_key?("title")
220
+ buglog.setTitle(bug["title"])
221
+ end
222
+ end
223
+
224
+ if jsonObject.has_key?("link")
225
+ link = jsonObject["link"]
226
+
227
+ if link.has_key?("self")
228
+ buglog.setURL(link["self"]["url"])
229
+ end
230
+ end
231
+
232
+ return buglog
233
+ end
234
+
235
+ # * Parse the JSONObject into Tasklog object.
236
+ #
237
+ # ==== Parameters
238
+ #
239
+ # * jsonObject:: - JSONObject contains the details of a task log.
240
+ #
241
+ # ==== Returns
242
+ #
243
+ # * Tasklog object.
244
+
245
+ def jsonToTasklog(jsonObject)
246
+ tasklog = Tasklog.new
247
+
248
+ if jsonObject.has_key?("id")
249
+ tasklog.setId(jsonObject["id"])
250
+ end
251
+ if jsonObject.has_key?("notes")
252
+ tasklog.setNotes(jsonObject["notes"])
253
+ end
254
+ if jsonObject.has_key?("log_date")
255
+ tasklog.setLogDate(jsonObject["log_date"])
256
+ end
257
+ if jsonObject.has_key?("log_date_format")
258
+ tasklog.setLogDateFormat(jsonObject["log_date_format"])
259
+ end
260
+ if jsonObject.has_key?("log_date_long")
261
+ tasklog.setLogDateLong(jsonObject["log_date_long"])
262
+ end
263
+ if jsonObject.has_key?("hours")
264
+ tasklog.setHours(jsonObject["hours"])
265
+ end
266
+ if jsonObject.has_key?("minutes")
267
+ tasklog.setMinutes(jsonObject["minutes"])
268
+ end
269
+ if jsonObject.has_key?("hours_display")
270
+ tasklog.setHoursDisplay(jsonObject["hours_display"])
271
+ end
272
+ if jsonObject.has_key?("total_minutes")
273
+ tasklog.setTotalMinutes(jsonObject["total_minutes"])
274
+ end
275
+ if jsonObject.has_key?("owner_id")
276
+ tasklog.setOwnerId(jsonObject["owner_id"])
277
+ end
278
+ if jsonObject.has_key?("owner_name")
279
+ tasklog.setOwnerName(jsonObject["owner_name"])
280
+ end
281
+ if jsonObject.has_key?("bill_status")
282
+ tasklog.setBillStatus(jsonObject["bill_status"])
283
+ end
284
+
285
+ if jsonObject.has_key?("task")
286
+ task = jsonObject["task"]
287
+
288
+ if task.has_key?("id")
289
+ tasklog.setTaskId(task["id"])
290
+ end
291
+ if task.has_key?("name")
292
+ tasklog.setTaskName(task["name"])
293
+ end
294
+ end
295
+
296
+ if jsonObject.has_key?("link")
297
+ link = jsonObject["link"]
298
+
299
+ if link.has_key?("self")
300
+ tasklog.setURL(link["self"]["url"])
301
+ end
302
+ end
303
+
304
+ return tasklog
305
+ end
306
+
307
+ # * Parse the JSONObject into Generallog object.
308
+ #
309
+ # ==== Parameters
310
+ #
311
+ # * jsonObject:: - JSONObject contains the details of a general log.
312
+ #
313
+ # ==== Returns
314
+ #
315
+ # * Generallog object.
316
+
317
+ def jsonToGenerallog(jsonObject)
318
+ generallog = Generallog.new
319
+
320
+ if jsonObject.has_key?("id")
321
+ generallog.setId(jsonObject["id"])
322
+ end
323
+ if jsonObject.has_key?("name")
324
+ generallog.setName(jsonObject["name"])
325
+ end
326
+ if jsonObject.has_key?("notes")
327
+ generallog.setNotes(jsonObject["notes"])
328
+ end
329
+ if jsonObject.has_key?("log_date")
330
+ generallog.setLogDate(jsonObject["log_date"])
331
+ end
332
+ if jsonObject.has_key?("log_date_format")
333
+ generallog.setLogDateFormat(jsonObject["log_date_format"])
334
+ end
335
+ if jsonObject.has_key?("log_date_long")
336
+ generallog.setLogDateLong(jsonObject["log_date_long"])
337
+ end
338
+ if jsonObject.has_key?("hours")
339
+ generallog.setHours(jsonObject["hours"])
340
+ end
341
+ if jsonObject.has_key?("minutes")
342
+ generallog.setMinutes(jsonObject["minutes"])
343
+ end
344
+ if jsonObject.has_key?("hours_display")
345
+ generallog.setHoursDisplay(jsonObject["hours_display"])
346
+ end
347
+ if jsonObject.has_key?("total_minutes")
348
+ generallog.setTotalMinutes(jsonObject["total_minutes"])
349
+ end
350
+ if jsonObject.has_key?("owner_id")
351
+ generallog.setOwnerId(jsonObject["owner_id"])
352
+ end
353
+ if jsonObject.has_key?("owner_name")
354
+ generallog.setOwnerName(jsonObject["owner_name"])
355
+ end
356
+ if jsonObject.has_key?("bill_status")
357
+ generallog.setBillStatus(jsonObject["bill_status"])
358
+ end
359
+
360
+
361
+ if jsonObject.has_key?("link")
362
+ link = jsonObject["link"]
363
+
364
+ if link.has_key?("self")
365
+ generallog.setURL(link["self"]["url"])
366
+ end
367
+ end
368
+
369
+ return generallog
370
+ end
371
+
372
+ # * Parse the JSON response and get the success message.
373
+ #
374
+ # ==== Parameters
375
+ #
376
+ # * response:: - This JSON response contains the success message.
377
+ #
378
+ # ==== Returns
379
+ #
380
+ # * String object.
381
+
382
+ def getResult(response)
383
+ jsonObject = JSON.parse response
384
+ result = jsonObject["response"]
385
+ return result
386
+ end
387
+
388
+ end
389
+ end
390
+ end