zohoProjects 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,318 @@
1
+ # $Id$
2
+ module Projects
3
+ module Parser
4
+
5
+ require 'json'
6
+ require File.dirname(__FILE__).chomp("/projects/parser") + '/projects/model/Project'
7
+ require File.dirname(__FILE__).chomp("/projects/parser") + '/projects/model/Activity'
8
+ require File.dirname(__FILE__).chomp("/projects/parser") + '/projects/model/Status'
9
+
10
+ # * Parse the JSON response into respective objects.
11
+
12
+ class ProjectParser
13
+ include Projects::Model
14
+ # * Parse the JSON response and make it into List of Project object.
15
+ #
16
+ # ==== Parameters
17
+ #
18
+ # * response:: - This JSON response contains the details of Projects.
19
+ #
20
+ # ==== Returns
21
+ #
22
+ # * List of Project object.
23
+
24
+ def getProjects(response)
25
+ projects_all_json = JSON.parse response
26
+ projects_all_array = projects_all_json["projects"]
27
+ projects_class_array = Array.new
28
+ for i in 0...projects_all_array.length
29
+ projects_class_array.push(jsonToProject(projects_all_array[i]))
30
+ end
31
+ return projects_class_array
32
+ end
33
+
34
+ # * Parse the JSON response and make it into Project object.
35
+ #
36
+ # ==== Parameters
37
+ #
38
+ # * response:: - This JSON response contains the details of a Project.
39
+ #
40
+ # ==== Returns
41
+ #
42
+ # * Project object.
43
+
44
+ def getProject(project)
45
+ project_json = JSON.parse project
46
+ project_array = project_json["projects"]
47
+ return jsonToProject(project_array[0])
48
+ end
49
+
50
+ # * Parse the JSONObject into Project object.
51
+ #
52
+ # ==== Parameters
53
+ #
54
+ # * jsonObject:: - JSONObject contains the details of a project.
55
+ #
56
+ # ==== Returns
57
+ #
58
+ # * Project object.
59
+
60
+ def jsonToProject(jsonObject)
61
+ project = Project.new
62
+
63
+ if jsonObject.has_key?("id")
64
+ project.setId(jsonObject["id"])
65
+ end
66
+ if jsonObject.has_key?("name")
67
+ project.setName(jsonObject["name"])
68
+ end
69
+ if jsonObject.has_key?("status")
70
+ project.setStatus(jsonObject["status"])
71
+ end
72
+ if jsonObject.has_key?("created_date")
73
+ project.setCreatedDate(jsonObject["created_date"])
74
+ end
75
+ if jsonObject.has_key?("created_date_format")
76
+ project.setCreatedDateFormat(jsonObject["created_date_format"])
77
+ end
78
+ if jsonObject.has_key?("created_date_long")
79
+ project.setCreatedDateLong(jsonObject["created_date_long"])
80
+ end
81
+ if jsonObject.has_key?("description")
82
+ project.setDescription(jsonObject["description"])
83
+ end
84
+ if jsonObject.has_key?("owner_name")
85
+ project.setOwnerName(jsonObject["owner_name"])
86
+ end
87
+ if jsonObject.has_key?("owner_id")
88
+ project.setOwnerId(jsonObject["owner_id"])
89
+ end
90
+
91
+ if jsonObject.has_key?("task_count")
92
+ taskCount = jsonObject["task_count"]
93
+ if taskCount.has_key?("open")
94
+ project.setOpenTaskCount(taskCount["open"])
95
+ end
96
+ if taskCount.has_key?("closed")
97
+ project.setClosedTaskCount(taskCount["closed"])
98
+ end
99
+ end
100
+
101
+ if jsonObject.has_key?("milestone_count")
102
+ milestoneCount = jsonObject["milestone_count"]
103
+ if milestoneCount.has_key?("open")
104
+ project.setOpenMilestoneCount(milestoneCount["open"])
105
+ end
106
+ if milestoneCount.has_key?("closed")
107
+ project.setClosedMilestoneCount(milestoneCount["closed"])
108
+ end
109
+ end
110
+
111
+ if jsonObject.has_key?("bug_count")
112
+ bugCount = jsonObject["bug_count"]
113
+ if bugCount.has_key?("open")
114
+ project.setOpenBugCount(bugCount["open"])
115
+ end
116
+ if bugCount.has_key?("closed")
117
+ project.setClosedBugCount(bugCount["closed"])
118
+ end
119
+ end
120
+
121
+ if jsonObject.has_key?("link")
122
+ link = jsonObject["link"]
123
+
124
+ if link.has_key?("self")
125
+ project.setURL(link["self"]["url"])
126
+ end
127
+ if link.has_key?("activity")
128
+ project.setActivityURL(link["activity"]["url"])
129
+ end
130
+ if link.has_key?("milestone")
131
+ project.setMilestoneURL(link["milestone"]["url"])
132
+ end
133
+ if link.has_key?("tasklist")
134
+ project.setTasklistURL(link["tasklist"]["url"])
135
+ end
136
+ if link.has_key?("task")
137
+ project.setTaskURL(link["task"]["url"])
138
+ end
139
+ if link.has_key?("bug")
140
+ project.setBugURL(link["bug"]["url"])
141
+ end
142
+ if link.has_key?("timesheet")
143
+ project.setTimesheetURL(link["timesheet"]["url"])
144
+ end
145
+ if link.has_key?("status")
146
+ project.setStatusURL(link["status"]["url"])
147
+ end
148
+ if link.has_key?("event")
149
+ project.setEventURL(link["event"]["url"])
150
+ end
151
+ if link.has_key?("document")
152
+ project.setDocumentURL(link["document"]["url"])
153
+ end
154
+ if link.has_key?("folder")
155
+ project.setFolderURL(link["folder"]["url"])
156
+ end
157
+ if link.has_key?("forum")
158
+ project.setForumURL(link["forum"]["url"])
159
+ end
160
+ if link.has_key?("user")
161
+ project.setUserURL(link["user"]["url"])
162
+ end
163
+ end
164
+
165
+ return project
166
+ end
167
+
168
+ # * Parse the JSON response and make it into List of Activity object.
169
+ #
170
+ # ==== Parameters
171
+ #
172
+ # * response:: - This JSON response contains the details of a activities.
173
+ #
174
+ # ==== Returns
175
+ #
176
+ # * List of Activity object.
177
+
178
+ def getActivities(response)
179
+ activities_all_json = JSON.parse response
180
+ activities_all_array = activities_all_json["activities"]
181
+ activity_class_array = Array.new
182
+ for i in 0...activities_all_array.length
183
+ activity_class_array.push(jsonToActivity(activities_all_array[i]))
184
+ end
185
+ return activity_class_array
186
+ end
187
+
188
+ # * Parse the JSONObject into Activity object.
189
+ #
190
+ # ==== Parameters
191
+ #
192
+ # * jsonObject:: - JSONObject contains the details of a activity.
193
+ #
194
+ # ==== Returns
195
+ #
196
+ # * Activity object.
197
+
198
+ def jsonToActivity(jsonObject)
199
+ activity = Activity.new
200
+
201
+ if jsonObject.has_key?("id")
202
+ activity.setId(jsonObject["id"])
203
+ end
204
+ if jsonObject.has_key?("name")
205
+ activity.setName(jsonObject["name"])
206
+ end
207
+ if jsonObject.has_key?("state")
208
+ activity.setState(jsonObject["state"])
209
+ end
210
+ if jsonObject.has_key?("activity_by")
211
+ activity.setActivityBy(jsonObject["activity_by"])
212
+ end
213
+ if jsonObject.has_key?("time_long")
214
+ activity.setTimeLong(jsonObject["time_long"])
215
+ end
216
+ if jsonObject.has_key?("display_time")
217
+ activity.setDisplayTime(jsonObject["display_time"])
218
+ end
219
+ if jsonObject.has_key?("time")
220
+ activity.setTime(jsonObject["time"])
221
+ end
222
+ if jsonObject.has_key?("activity_for")
223
+ activity.setActivityFor(jsonObject["activity_for"])
224
+ end
225
+
226
+ return activity
227
+
228
+ end
229
+
230
+ # * Parse the JSON response and make it into List of Status object.
231
+ #
232
+ # ==== Parameters
233
+ #
234
+ # * response:: - This JSON response contains the details of a statuses.
235
+ #
236
+ # ==== Returns
237
+ #
238
+ # * List of Status object.
239
+
240
+ def getStatuses(response)
241
+ statuses_all_json = JSON.parse response
242
+ statuses_all_array = statuses_all_json["statuses"]
243
+ statuses_class_array = Array.new
244
+ for i in 0...statuses_all_array.length
245
+ statuses_class_array.push(jsonToStatus(statuses_all_array[i]))
246
+ end
247
+ return statuses_class_array
248
+ end
249
+
250
+ # * Parse the JSON response and make it into Status object.
251
+ #
252
+ # ==== Parameters
253
+ #
254
+ # * response:: - This JSON response contains the details of a status.
255
+ #
256
+ # * Status object.
257
+
258
+ def getStatus(response)
259
+ status_json = JSON.parse response
260
+ status_array = status_json["statuses"]
261
+ return jsonToStatus(status_array[0])
262
+ end
263
+
264
+ # * Parse the JSONObject into Status object.
265
+ #
266
+ # * jsonObject:: - JSONObject contains the details of a status.
267
+ #
268
+ # ==== Returns
269
+ #
270
+ # * Status object.
271
+
272
+ def jsonToStatus(jsonObject)
273
+ status = Status.new
274
+
275
+ if jsonObject.has_key?("id")
276
+ status.setId(jsonObject["id"])
277
+ end
278
+ if jsonObject.has_key?("content")
279
+ status.setContent(jsonObject["content"])
280
+ end
281
+ if jsonObject.has_key?("posted_by")
282
+ status.setPostedBy(jsonObject["posted_by"])
283
+ end
284
+ if jsonObject.has_key?("posted_person")
285
+ status.setPostedPerson(jsonObject["posted_person"])
286
+ end
287
+ if jsonObject.has_key?("posted_time")
288
+ status.setPostedTime(jsonObject["posted_time"])
289
+ end
290
+ if jsonObject.has_key?("posted_time_long")
291
+ status.setPostedTimeLong(jsonObject["posted_time_long"])
292
+ end
293
+ if jsonObject.has_key?("posted_time_format")
294
+ status.setPostedTimeFormat(jsonObject["posted_time_format"])
295
+ end
296
+
297
+ return status;
298
+ end
299
+
300
+ # * Parse the JSON response and get the success message.
301
+ #
302
+ # ==== Parameters
303
+ #
304
+ # * response:: - This JSON response contains the success message.
305
+ #
306
+ # ==== Returns
307
+ #
308
+ # * String object.
309
+
310
+ def getResult(response)
311
+ jsonObject = JSON.parse response
312
+ result = jsonObject["response"]
313
+ return result
314
+ end
315
+
316
+ end
317
+ end
318
+ end
@@ -0,0 +1,293 @@
1
+ # $Id$
2
+ module Projects
3
+ module Parser
4
+
5
+ require 'json'
6
+ require File.dirname(__FILE__).chomp("/projects/parser") + '/projects/model/Task'
7
+ require File.dirname(__FILE__).chomp("/projects/parser") + '/projects/model/Comment'
8
+ require File.dirname(__FILE__).chomp("/projects/parser") + '/projects/model/Owner'
9
+ require File.dirname(__FILE__).chomp("/projects/parser") + '/projects/model/Tasklist'
10
+
11
+ # * Parse the JSON response into respective objects.
12
+
13
+ class TaskParser
14
+ include Projects::Model
15
+ # * Parse the JSON response and make it into List of Task object.
16
+ #
17
+ # ==== Parameters
18
+ #
19
+ # * response:: - This JSON response contains the details of tasks.
20
+ #
21
+ # ==== Returns
22
+ #
23
+ # * List of Task object.
24
+
25
+ def getTasks(response)
26
+ tasks_all_json = JSON.parse response
27
+ tasks_all_array = tasks_all_json["tasks"]
28
+ tasks_class_array = Array.new
29
+ for i in 0...tasks_all_array.length
30
+ tasks_class_array.push(jsonToTask(tasks_all_array[i]))
31
+ end
32
+ return tasks_class_array
33
+ end
34
+
35
+ # * Parse the JSON response and make it into Task object.
36
+ #
37
+ # ==== Parameters
38
+ #
39
+ # * response:: - This JSON response contains the details of a task.
40
+ #
41
+ # ==== Returns
42
+ #
43
+ # * Task object.
44
+
45
+ def getTask(response)
46
+ tasks_json = JSON.parse response
47
+ tasks_array = tasks_json["tasks"]
48
+ return jsonToTask(tasks_array[0])
49
+ end
50
+
51
+ # * Parse the JSONObject into Task object.
52
+ #
53
+ # ==== Parameters
54
+ #
55
+ # * jsonObject:: - JSONObject contains the details of a task.
56
+ #
57
+ # ==== Returns
58
+ #
59
+ # * Task object.
60
+
61
+ def jsonToTask(jsonObject)
62
+ task = Task.new
63
+
64
+ if jsonObject.has_key?("id")
65
+ task.setId(jsonObject["id"])
66
+ end
67
+ if jsonObject.has_key?("name")
68
+ task.setName(jsonObject["name"])
69
+ end
70
+ if jsonObject.has_key?("completed")
71
+ task.setCompleted(jsonObject["completed"])
72
+ end
73
+ if jsonObject.has_key?("created_by")
74
+ task.setCreatedBy(jsonObject["created_by"])
75
+ end
76
+ if jsonObject.has_key?("created_person")
77
+ task.setCreatedPerson(jsonObject["created_person"])
78
+ end
79
+ if jsonObject.has_key?("priority")
80
+ task.setPriority(jsonObject["priority"])
81
+ end
82
+ if jsonObject.has_key?("percent_complete")
83
+ task.setPercentComplete(jsonObject["percent_complete"])
84
+ end
85
+ if jsonObject.has_key?("start_date")
86
+ task.setStartDate(jsonObject["start_date"])
87
+ end
88
+ if jsonObject.has_key?("start_date_format")
89
+ task.setStartDateFormat(jsonObject["start_date_format"])
90
+ end
91
+ if jsonObject.has_key?("start_date_long")
92
+ task.setStartDateLong(jsonObject["start_date_long"])
93
+ end
94
+ if jsonObject.has_key?("end_date")
95
+ task.setEndDate(jsonObject["end_date"])
96
+ end
97
+ if jsonObject.has_key?("end_date_format")
98
+ task.setEndDateFormat(jsonObject["end_date_format"])
99
+ end
100
+ if jsonObject.has_key?("end_date_long")
101
+ task.setEndDateLong(jsonObject["end_date_long"])
102
+ end
103
+ if jsonObject.has_key?("duration")
104
+ task.setDuration(jsonObject["duration"])
105
+ end
106
+
107
+ if jsonObject.has_key?("details")
108
+ details = jsonObject["details"]
109
+
110
+ if details.has_key?("owners")
111
+ owners = details["owners"]
112
+ ownerList = Array.new
113
+
114
+ for i in 0...owners.length
115
+ owner = owners[i]
116
+ ownerList.push(jsonToOwner(owner))
117
+ end
118
+
119
+ task.setOwners(ownerList)
120
+ end
121
+
122
+ if details.has_key?("comments")
123
+ comments = details["comments"]
124
+
125
+ commentList = Array.new
126
+
127
+ for j in 0...comments.length
128
+ comment = comments[j]
129
+ commentList.push(jsonToComment(comment))
130
+ end
131
+
132
+ task.setComments(commentList)
133
+ end
134
+
135
+ if details.has_key?("documents")
136
+ documents = details["documents"]
137
+ documentIds = Array.new
138
+
139
+ for l in 0...documents.length
140
+ documentIds[l] = String(documents[l]["id"])
141
+ end
142
+
143
+ task.setAssociateDocumentIds(documentIds)
144
+ end
145
+
146
+ if details.has_key?("forums")
147
+ forums = details["forums"]
148
+ forumIds = Array.new
149
+
150
+ for m in 0...forums.length
151
+ forumIds[m] = String(forums[m]["id"])
152
+ end
153
+
154
+ task.setAssociateForumIds(forumIds)
155
+ end
156
+ end
157
+
158
+ if jsonObject.has_key?("link")
159
+ link = jsonObject["link"]
160
+
161
+ if link.has_key?("self")
162
+ task.setURL(link["self"]["url"])
163
+ end
164
+ if link.has_key?("timesheet")
165
+ task.setTimesheetURL(link["timesheet"]["url"])
166
+ end
167
+ end
168
+
169
+ if jsonObject.has_key?("subtasks")
170
+ subtasks = jsonObject["subtasks"]
171
+
172
+ tasks = Array.new
173
+
174
+ for k in 0...subtasks.length
175
+ taskObj = subtasks[k]
176
+ tasks.push(jsonToTask(taskObj))
177
+ end
178
+
179
+ task.setSubtasks(tasks)
180
+ end
181
+
182
+ if jsonObject.has_key?("tasklist")
183
+ tasklist = jsonObject["tasklist"]
184
+
185
+ task.setTasklist(jsonToTasklist(tasklist))
186
+ end
187
+
188
+ return task
189
+ end
190
+
191
+ # * Parse the JSONObject into Owner object.
192
+ #
193
+ # ==== Parameters
194
+ #
195
+ # * jsonObject:: - JSONObject contains the details of a owner.
196
+ #
197
+ # ==== Returns
198
+ #
199
+ # * Owner object.
200
+
201
+ def jsonToOwner(jsonObject)
202
+ owner = Owner.new
203
+
204
+ if jsonObject.has_key?("id")
205
+ owner.setId(jsonObject["id"])
206
+ end
207
+ if jsonObject.has_key?("name")
208
+ owner.setName(jsonObject["name"])
209
+ end
210
+ return owner
211
+ end
212
+
213
+ # * Parse the JSONObject into Comment object.
214
+ #
215
+ # ==== Parameters
216
+ #
217
+ # * jsonObject:: - JSONObject contains the details of a comment.
218
+ #
219
+ # ==== Returns
220
+ #
221
+ # * Comment object.
222
+
223
+ def jsonToComment(jsonObject)
224
+ comment = Comment.new
225
+
226
+ if jsonObject.has_key?("id")
227
+ comment.setId(jsonObject["id"])
228
+ end
229
+ if jsonObject.has_key?("content")
230
+ comment.setContent(jsonObject["content"])
231
+ end
232
+ if jsonObject.has_key?("created_time")
233
+ comment.setCreatedTime(jsonObject["created_time"])
234
+ end
235
+ if jsonObject.has_key?("created_time_format")
236
+ comment.setCreatedTimeFormat(jsonObject["created_time_format"])
237
+ end
238
+ if jsonObject.has_key?("created_time_long")
239
+ comment.setCreatedTimeLong(jsonObject["created_time_long"])
240
+ end
241
+ if jsonObject.has_key?("added_by")
242
+ comment.setAddedBy(jsonObject["added_by"])
243
+ end
244
+ if jsonObject.has_key?("added_person")
245
+ comment.setAddedPerson(jsonObject["added_person"])
246
+ end
247
+ if jsonObject.has_key?("updated_by")
248
+ comment.setUpdatedBy(jsonObject["updated_by"])
249
+ end
250
+ return comment
251
+ end
252
+
253
+ # * Parse the JSONObject into Tasklist object.
254
+ #
255
+ # ==== Parameters
256
+ #
257
+ # * jsonObject:: - JSONObject contains the details of a task list.
258
+ #
259
+ # ==== Returns
260
+ #
261
+ # * Tasklist object.
262
+
263
+ def jsonToTasklist(jsonObject)
264
+ tasklist = Tasklist.new
265
+
266
+ if jsonObject.has_key?("id")
267
+ tasklist.setId(jsonObject["id"])
268
+ end
269
+ if jsonObject.has_key?("name")
270
+ tasklist.setName(jsonObject["name"])
271
+ end
272
+
273
+ return tasklist
274
+ end
275
+
276
+ # * Parse the JSON response and get the success message.
277
+ #
278
+ # ==== Parameters
279
+ #
280
+ # * response:: - This JSON response contains the success message.
281
+ #
282
+ # ==== Returns
283
+ #
284
+ # * String object.
285
+
286
+ def getResult(response)
287
+ jsonObject = JSON.parse response
288
+ result = jsonObject["response"]
289
+ return result
290
+ end
291
+ end
292
+ end
293
+ end