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,197 @@
1
+ # $Id$
2
+ module Projects
3
+ module Parser
4
+
5
+ require 'json'
6
+ require File.dirname(__FILE__).chomp("/projects/parser") + '/projects/model/Document'
7
+ require File.dirname(__FILE__).chomp("/projects/parser") + '/projects/model/Version'
8
+ require File.dirname(__FILE__).chomp("/projects/parser") + '/projects/model/Folder'
9
+
10
+ # * Parse the JSON response into respective objects.
11
+
12
+ class DocumentParser
13
+ include Projects::Model
14
+ # * Parse the JSON response and make it into List of Document object.
15
+ #
16
+ # ==== Parameters
17
+ #
18
+ # * response:: - This JSON response contains the details of a documents.
19
+ #
20
+ # ==== Returns
21
+ #
22
+ # * List of Document object.
23
+
24
+ def getDocuments(response)
25
+ documents_all_json = JSON.parse response
26
+ documents_all_array = documents_all_json["documents"]
27
+ documents_class_array = Array.new
28
+ for i in 0...documents_all_array.length
29
+ documents_class_array.push(jsonToDocument(documents_all_array[i]))
30
+ end
31
+ return documents_class_array
32
+ end
33
+
34
+ # * Parse the JSON response and make it into Document object.
35
+ #
36
+ # ==== Parameters
37
+ #
38
+ # * response:: - This JSON response contains the details of a document.
39
+ #
40
+ # ==== Returns
41
+ #
42
+ # * Document object.
43
+
44
+ def getDocument(response)
45
+ document_json = JSON.parse response
46
+ document_array = document_json["documents"]
47
+ return jsonToDocument(document_array[0])
48
+ end
49
+
50
+ # * Parse the JSONObject into Document object.
51
+ #
52
+ # ==== Parameters
53
+ #
54
+ # * jsonObject:: - JSONObject contains the details of the document.
55
+ #
56
+ # ==== Returns
57
+ #
58
+ # * Document object.
59
+
60
+ def jsonToDocument(jsonObject)
61
+ document = Document.new
62
+
63
+ if jsonObject.has_key?("id")
64
+ document.setId(jsonObject["id"])
65
+ end
66
+ if jsonObject.has_key?("file_name")
67
+ document.setFilename(jsonObject["file_name"])
68
+ end
69
+ if jsonObject.has_key?("content_type")
70
+ document.setContenttype(jsonObject["content_type"])
71
+ end
72
+
73
+ if jsonObject.has_key?("versions")
74
+ versions = jsonObject["versions"]
75
+
76
+ versionList = Array.new
77
+
78
+ for i in 0...versions.length
79
+ version = versions[i]
80
+ versionList.push(jsonToVersion(version))
81
+ end
82
+
83
+ document.setVersions(versionList)
84
+ end
85
+
86
+ if jsonObject.has_key?("folder")
87
+ folder = jsonObject["folder"]
88
+ document.setFolder(jsonToFolder(folder))
89
+ end
90
+
91
+ if jsonObject.has_key?("link")
92
+ link = jsonObject["link"]
93
+
94
+ if link.has_key?("self")
95
+ document.setURL(link["self"]["url"])
96
+ end
97
+ end
98
+
99
+ return document
100
+ end
101
+
102
+ # * Parse the JSONObject into Version object.
103
+ #
104
+ # ==== Parameters
105
+ #
106
+ # * jsonObject:: - JSONObject contains the details of a version.
107
+ #
108
+ # ==== Returns
109
+ #
110
+ # * Version object.
111
+
112
+ def jsonToVersion(jsonObject)
113
+ version = Version.new
114
+
115
+ if jsonObject.has_key?("id")
116
+ version.setId(jsonObject["id"])
117
+ end
118
+ if jsonObject.has_key?("uploaded_by")
119
+ version.setUploadedBy(jsonObject["uploaded_by"])
120
+ end
121
+ if jsonObject.has_key?("description")
122
+ version.setDescription(jsonObject["description"])
123
+ end
124
+ if jsonObject.has_key?("version")
125
+ version.setVersion(jsonObject["version"])
126
+ end
127
+ if jsonObject.has_key?("uploaded_on")
128
+ version.setUploadedOn(jsonObject["uploaded_on"])
129
+ end
130
+ if jsonObject.has_key?("file_size")
131
+ version.setFileSize(jsonObject["file_size"])
132
+ end
133
+ if jsonObject.has_key?("uploaded_date")
134
+ version.setUploadedDate(jsonObject["uploaded_date"])
135
+ end
136
+ if jsonObject.has_key?("uploaded_date_format")
137
+ version.setUploadedDateFormat(jsonObject["uploaded_date_format"])
138
+ end
139
+ if jsonObject.has_key?("uploaded_date_long")
140
+ version.setUploadedDateLong(jsonObject["uploaded_date_long"])
141
+ end
142
+
143
+ return version
144
+ end
145
+
146
+ # * Parse the JSONObject into Folder object.
147
+ #
148
+ # ==== Parameters
149
+ #
150
+ # * jsonObject:: - JSONObject contains the details of a folder.
151
+ #
152
+ # ==== Returns
153
+ #
154
+ # * Folder object.
155
+
156
+ def jsonToFolder(jsonObject)
157
+ folder = Folder.new
158
+
159
+ if jsonObject.has_key?("id")
160
+ folder.setId(jsonObject["id"])
161
+ end
162
+ if jsonObject.has_key?("name")
163
+ folder.setName(jsonObject["name"])
164
+ end
165
+ if jsonObject.has_key?("is_discussion")
166
+ folder.setIsDicussion(jsonObject["is_discussion"])
167
+ end
168
+
169
+ if jsonObject.has_key?("link")
170
+ link = jsonObject["link"]
171
+
172
+ if link.has_key?("self")
173
+ folder.setURL(link["self"]["url"])
174
+ end
175
+ end
176
+
177
+ return folder
178
+ end
179
+
180
+ # * Parse the JSON response and get the success message.
181
+ #
182
+ # ==== Parameters
183
+ #
184
+ # * response:: - This JSON response contains the success message.
185
+ #
186
+ # ==== Returns
187
+ #
188
+ # * String object.
189
+
190
+ def getResult(response)
191
+ jsonObject = JSON.parse response
192
+ result = jsonObject["response"]
193
+ return result
194
+ end
195
+ end
196
+ end
197
+ end
@@ -0,0 +1,156 @@
1
+ # $Id$
2
+ module Projects
3
+ module Parser
4
+
5
+ require 'json'
6
+ require File.dirname(__FILE__).chomp("/projects/parser") + '/projects/model/Event'
7
+ require File.dirname(__FILE__).chomp("/projects/parser") + '/projects/model/Participant'
8
+
9
+
10
+ # * Parse the JSON response into respective objects.
11
+
12
+ class EventParser
13
+ include Projects::Model
14
+ # * Parse the JSON response and make it into List of Event object.
15
+ #
16
+ # ==== Parameters
17
+ #
18
+ # * response:: - This JSON response contains the details of events.
19
+ #
20
+ # ==== Returns
21
+ #
22
+ # * List of Event object.
23
+
24
+ def getEvents(response)
25
+ events_all_json = JSON.parse response
26
+ events_all_array = events_all_json["events"]
27
+ events_class_array = Array.new
28
+ for i in 0...events_all_array.length
29
+ events_class_array.push(jsonToEvent(events_all_array[i]))
30
+ end
31
+ return events_class_array
32
+ end
33
+
34
+ # * Parse the JSON response and make it into Event object.
35
+ #
36
+ # ==== Parameters
37
+ #
38
+ # * response:: - This JSON response contains the details of an event.
39
+ #
40
+ # ==== Returns
41
+ #
42
+ # * Event object.
43
+
44
+ def getEvent(response)
45
+ event_json = JSON.parse response
46
+ event_array = event_json["events"]
47
+ return jsonToEvent(event_array[0])
48
+ end
49
+
50
+ # * Parse the JSONObject into Event object.
51
+ #
52
+ # ==== Parameters
53
+ #
54
+ # * jsonObject:: - JSONObject contains the details of an event.
55
+ #
56
+ # ==== Returns
57
+ #
58
+ # * Event object.
59
+
60
+ def jsonToEvent(jsonObject)
61
+
62
+ event = Event.new
63
+
64
+ if jsonObject.has_key?("id")
65
+ event.setId(jsonObject["id"])
66
+ end
67
+ if jsonObject.has_key?("title")
68
+ event.setTitle(jsonObject["title"])
69
+ end
70
+ if jsonObject.has_key?("location")
71
+ event.setLocation(jsonObject["location"])
72
+ end
73
+ if jsonObject.has_key?("scheduled_on")
74
+ event.setScheduledOn(jsonObject["scheduled_on"])
75
+ end
76
+ if jsonObject.has_key?("scheduled_on_long")
77
+ event.setScheduledOnLong(jsonObject["scheduled_on_long"])
78
+ end
79
+ if jsonObject.has_key?("reminder")
80
+ event.setReminder(jsonObject["reminder"])
81
+ end
82
+ if jsonObject.has_key?("repeat")
83
+ event.setRepeat(jsonObject["repeat"])
84
+ end
85
+ if jsonObject.has_key?("occurrence(s)")
86
+ event.setOccurrences(jsonObject["occurrence(s)"])
87
+ end
88
+ if jsonObject.has_key?("occurred")
89
+ event.setOccurred(jsonObject["occurred"])
90
+ end
91
+ if jsonObject.has_key?("duration_hour")
92
+ event.setDurationHours(jsonObject["duration_hour"])
93
+ end
94
+ if jsonObject.has_key?("duration_minutes")
95
+ event.setDurationMinutes(jsonObject["duration_minutes"])
96
+ end
97
+
98
+ if jsonObject.has_key?("participants")
99
+ participants = jsonObject["participants"]
100
+
101
+ participantList = Array.new
102
+
103
+ for j in 0...participants.length
104
+ participant = participants[j]
105
+ participantList.push(jsonToParticipant(participant))
106
+ end
107
+
108
+ event.setParticipants(participantList)
109
+ end
110
+
111
+ return event
112
+ end
113
+
114
+ # * Parse the JSONObject into Participant object.
115
+ #
116
+ # ==== Parameters
117
+ #
118
+ # * jsonObject:: - JSONObject contains the details of a participant.
119
+ #
120
+ # ==== Returns
121
+ #
122
+ # * Participant object.
123
+
124
+ def jsonToParticipant(jsonObject)
125
+
126
+ participant = Participant.new
127
+
128
+ if jsonObject.has_key?("participant_id")
129
+ participant.setParticipantId(jsonObject["participant_id"])
130
+ end
131
+ if jsonObject.has_key?("participant_person")
132
+ participant.setParticipantPerson(jsonObject["participant_person"])
133
+ end
134
+
135
+ return participant
136
+ end
137
+
138
+ # * Parse the JSON response and get the success message.
139
+ #
140
+ # ==== Parameters
141
+ #
142
+ # * response:: - This JSON response contains the success message.
143
+ #
144
+ # ==== Returns
145
+ #
146
+ # * String object.
147
+
148
+ def getResult(response)
149
+ jsonObject = JSON.parse response
150
+ result = jsonObject["response"]
151
+ return result
152
+ end
153
+
154
+ end
155
+ end
156
+ end
@@ -0,0 +1,99 @@
1
+ # $Id$
2
+ module Projects
3
+ module Parser
4
+
5
+ require 'json'
6
+ require File.dirname(__FILE__).chomp("/projects/parser") + '/projects/model/Folder'
7
+
8
+ # * Parse the JSON response into respective objects.
9
+
10
+ class FolderParser
11
+ include Projects::Model
12
+ # * Parse the JSON response and make it into List of Folder object.
13
+ #
14
+ # ==== Parameters
15
+ #
16
+ # * response:: - This JSON response contains the details of folders.
17
+ #
18
+ # ==== Returns
19
+ #
20
+ # * List of Folder object.
21
+
22
+ def getFolders(response)
23
+ folders_all_json = JSON.parse response
24
+ folders_all_array = folders_all_json["folders"]
25
+ folders_class_array = Array.new
26
+ for i in 0...folders_all_array.length
27
+ folders_class_array.push(jsonToFolder(folders_all_array[i]))
28
+ end
29
+ return folders_class_array
30
+ end
31
+
32
+ # * Parse the JSON response and make it into Folder object.
33
+ #
34
+ # ==== Parameters
35
+ #
36
+ # * response:: - This JSON response contains the details of a folder.
37
+ #
38
+ # ==== Returns
39
+ #
40
+ # * Folder object.
41
+
42
+ def getFolder(response)
43
+ folder_json = JSON.parse response
44
+ folder_array = folder_json["folders"]
45
+ return jsonToFolder(folder_array[0])
46
+ end
47
+
48
+ # * Parse the JSONObject into Folder object.
49
+ #
50
+ # ==== Parameters
51
+ #
52
+ # * jsonObject:: - JSONObject contains the details of a folder.
53
+ #
54
+ # ==== Returns
55
+ #
56
+ # * Folder object.
57
+
58
+ def jsonToFolder(jsonObject)
59
+ folder = Folder.new
60
+
61
+ if jsonObject.has_key?("id")
62
+ folder.setId(jsonObject["id"])
63
+ end
64
+ if jsonObject.has_key?("name")
65
+ folder.setName(jsonObject["name"])
66
+ end
67
+ if jsonObject.has_key?("is_discussion")
68
+ folder.setIsDicussion(jsonObject["is_discussion"])
69
+ end
70
+
71
+ if jsonObject.has_key?("link")
72
+ link = jsonObject["link"]
73
+
74
+ if link.has_key?("self")
75
+ folder.setURL(link["self"]["url"])
76
+ end
77
+ end
78
+
79
+ return folder
80
+ end
81
+
82
+ # * Parse the JSON response and get the success message.
83
+ #
84
+ # ==== Parameters
85
+ #
86
+ # * response:: - This JSON response contains the success message.
87
+ #
88
+ # ==== Returns
89
+ #
90
+ # * String object.
91
+
92
+ def getResult(response)
93
+ jsonObject = JSON.parse response
94
+ result = jsonObject["response"]
95
+ return result
96
+ end
97
+ end
98
+ end
99
+ end