zohoProjects 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,7 +6,7 @@ module Projects
6
6
  class Task
7
7
 
8
8
  private
9
- attr_accessor :id, :name, :completed, :createdBy, :createdPerson, :priority, :percentComplete, :startDate, :startDateFormat, :startDateLong, :endDate, :endDateFormat, :endDateLong, :duration, :url, :timesheetUrl, :owners, :comments, :associateDocumentIds, :associateForumIds, :asks, :tasklist
9
+ attr_accessor :id, :name, :completed, :createdBy, :createdPerson, :priority, :percentComplete, :startDate, :startDateFormat, :startDateLong, :endDate, :endDateFormat, :endDateLong, :duration, :url, :subtaskUrl, :timesheetUrl, :owners, :comments, :associateDocumentIds, :associateForumIds, :tasks, :tasklist
10
10
 
11
11
  public
12
12
 
@@ -309,6 +309,33 @@ module Projects
309
309
  def getURL
310
310
  return @url
311
311
  end
312
+
313
+ # * Set the subtask URL.
314
+ #
315
+ # ==== Parameters
316
+ #
317
+ # * subtaskUrl:: - URL for the subtask.
318
+
319
+
320
+ def setSubtaskUrl(subtaskUrl)
321
+
322
+ @subtaskUrl = subtaskUrl
323
+
324
+ end
325
+
326
+ # * Get the subtask URL.
327
+ #
328
+ # ==== Returns
329
+ #
330
+ # * Returns the subtask URL.
331
+
332
+
333
+ def getSubtaskUrl
334
+
335
+ return @subtaskUrl
336
+
337
+ end
338
+
312
339
 
313
340
  # * Set the time sheet URL.
314
341
  #
@@ -414,7 +441,7 @@ module Projects
414
441
  #
415
442
  # ==== Parameters
416
443
  #
417
- # * tasks:: - List of Task object.
444
+ # * tasks:: - True or false.
418
445
 
419
446
  def setSubtasks(tasks)
420
447
  @tasks = tasks
@@ -424,7 +451,7 @@ module Projects
424
451
  #
425
452
  # ==== Returns
426
453
  #
427
- # * List of Task object.
454
+ # * Returns true if the task has subtasks else returns false.
428
455
 
429
456
  def getSubtasks
430
457
  return @tasks
@@ -494,4 +521,4 @@ module Projects
494
521
  end
495
522
  end
496
523
  end
497
- end
524
+ end
@@ -1,9 +1,11 @@
1
- # $Id$
1
+ # $Id$
2
2
  module Projects
3
3
  module Parser
4
4
 
5
5
  require 'json'
6
6
  require File.dirname(__FILE__).chomp("/projects/parser") + '/projects/model/Bug'
7
+ require File.dirname(__FILE__).chomp("/projects/parser") + '/projects/model/Defaultfield'
8
+ require File.dirname(__FILE__).chomp("/projects/parser") + '/projects/model/Customfield'
7
9
 
8
10
 
9
11
  # * Parse the JSON response into respective objects.
@@ -187,6 +189,213 @@ module Projects
187
189
 
188
190
  return bug
189
191
  end
192
+
193
+ # * Parse the JSON response and make it into Defaultfield object.
194
+ #
195
+ # ==== Parameters
196
+ #
197
+ # * response:: - This JSON response contains the details of the default fields.
198
+ #
199
+ # ==== Returns
200
+ #
201
+ # * Returns the Defaultfield object.
202
+
203
+
204
+ def getDefaultFields(response)
205
+
206
+ jsonObject = JSON.parse response
207
+
208
+ defaultField = Defaultfield.new
209
+
210
+ if jsonObject.has_key?("defaultfields")
211
+
212
+ defaultFields = jsonObject["defaultfields"]
213
+
214
+ if defaultFields.has_key?("severity_details")
215
+
216
+ severitydetails = defaultFields["severity_details"]
217
+
218
+ severityDetails = Array.new
219
+
220
+ for i in 0...severitydetails.length
221
+
222
+ severityDetails.push(jsonToHash(severity_details[i]))
223
+ end
224
+
225
+ defaultField.setSeverityDetails(severityDetails)
226
+ end
227
+
228
+ if defaultFields.has_key?("status_deatils")
229
+
230
+ statusdeatils = defaultFields["status_deatils"]
231
+
232
+ statusDeatils = Array.new
233
+
234
+ for i in 0...statusdeatils.length
235
+
236
+ statusDeatils.push(jsonToHash(statusdeatils[i]))
237
+
238
+ end
239
+
240
+ defaultField.setStatusDeatils(statusDeatils)
241
+ end
242
+
243
+ if defaultFields.has_key?("module_details")
244
+
245
+ moduledetails = defaultFields["module_details"]
246
+
247
+ moduleDetails = Array.new
248
+
249
+ for i in 0...moduledetails.length
250
+
251
+ moduleDetails.push(jsonToHash(moduledetails[i]))
252
+
253
+ end
254
+
255
+ defaultField.setModuleDetails(moduleDetails)
256
+ end
257
+
258
+ if defaultFields.has_key?("priority_details")
259
+
260
+ prioritydetails = defaultFields["priority_details"]
261
+
262
+ priorityDetails = Array.new
263
+
264
+ for i in 0...prioritydetails.length
265
+
266
+ priorityDetails.push(jsonToHash(prioritydetails[i]))
267
+
268
+ end
269
+
270
+ defaultField.setPriorityDetails(priorityDetails)
271
+ end
272
+
273
+ if defaultFields.has_key?("classification_details")
274
+
275
+ classificationdetails = defaultFields["classification_details"]
276
+
277
+ classificationDetails = Array.new
278
+
279
+ for i in 0...classificationdetails.length
280
+
281
+ classificationDetails.push(jsonToHash(classificationdetails[i]))
282
+
283
+ end
284
+
285
+ defaultField.setClassificationDetails(classificationDetails)
286
+ end
287
+
288
+ end
289
+
290
+ return defaultField
291
+ end
292
+
293
+
294
+ # * Parse the JSONObject into HashMap object.
295
+ #
296
+ # ==== Parameters
297
+ #
298
+ # * jsonObject:: - JSONObject contains the details of the default field.
299
+ #
300
+ # ==== Returns
301
+ #
302
+ # * Returns the Hash object.
303
+
304
+
305
+ def jsonToHash(jsonObject)
306
+
307
+ hash = JSON.parse(jsonObject)
308
+
309
+ return hash
310
+ end
311
+
312
+
313
+ # * Parse the JSON response and make it into the list of Customfield object.
314
+ #
315
+ # ==== Parameters
316
+ #
317
+ # * response:: - This JSON response contains the details of the custom fields.
318
+ #
319
+ # ==== Returns
320
+ #
321
+ # * Returns list of Customfield object.
322
+
323
+
324
+ def getCustomfields(response)
325
+
326
+ jsonObject = JSON.parse response
327
+
328
+ customFields = Array.new
329
+
330
+ if jsonObject.has_key?("customfields")
331
+
332
+ customfields = jsonObject["customfields"]
333
+
334
+ for i in 0...customfields.length
335
+
336
+ customFields.push(jsonToCustomfield(customfields[i]))
337
+
338
+ end
339
+
340
+ end
341
+
342
+ return customFields
343
+
344
+ end
345
+
346
+ # * Parse the JSONObject into the Customfield object.
347
+ #
348
+ # ==== Parameters
349
+ #
350
+ # * jsonObject:: - JSONObject contains the details of the custom field.
351
+ #
352
+ # ==== Returns
353
+ #
354
+ # * Returns the Customfield object.
355
+
356
+
357
+ def jsonToCustomfield(jsonObject)
358
+
359
+ customfield = Customfield.new
360
+
361
+ if jsonObject.has_key?("label_name")
362
+
363
+ customfield.setLabelName(jsonObject["label_name"])
364
+
365
+ end
366
+
367
+ if jsonObject.has_key?("column_name")
368
+
369
+ customfield.setColumnName(jsonObject["column_name"])
370
+
371
+ end
372
+
373
+ if jsonObject.has_key?("default_Value")
374
+
375
+ customfield.setDefaultValue(jsonObject["default_Value"])
376
+
377
+ end
378
+
379
+ if jsonObject.has_key?("picklist_values")
380
+
381
+ picklistValues = Array.new
382
+
383
+ picklistvalues = jsonObject["picklist_values"]
384
+
385
+ for i in 0...picklistvalues.length
386
+
387
+ picklistValues.push(picklistvalues[i])
388
+
389
+ end
390
+
391
+ customfield.setPicklistValues(picklistValues)
392
+
393
+ end
394
+
395
+ return customfield
396
+
397
+ end
398
+
190
399
 
191
400
  # * Parse the JSON response and get the success message.
192
401
  #
@@ -205,4 +414,4 @@ module Projects
205
414
  end
206
415
  end
207
416
  end
208
- end
417
+ end
@@ -161,22 +161,28 @@ module Projects
161
161
  if link.has_key?("self")
162
162
  task.setURL(link["self"]["url"])
163
163
  end
164
+
165
+ if link.has_key?("subtask")
166
+ task.setSubtaskUrl(link["subtask"]["url"])
167
+ end
168
+
164
169
  if link.has_key?("timesheet")
165
170
  task.setTimesheetURL(link["timesheet"]["url"])
166
171
  end
167
172
  end
168
173
 
169
174
  if jsonObject.has_key?("subtasks")
170
- subtasks = jsonObject["subtasks"]
171
175
 
172
- tasks = Array.new
176
+ #subtasks = jsonObject["subtasks"]
177
+
178
+ #tasks = Array.new
173
179
 
174
- for k in 0...subtasks.length
175
- taskObj = subtasks[k]
176
- tasks.push(jsonToTask(taskObj))
177
- end
180
+ #for k in 0...subtasks.length
181
+ # taskObj = subtasks[k]
182
+ # tasks.push(jsonToTask(taskObj))
183
+ #end
178
184
 
179
- task.setSubtasks(tasks)
185
+ task.setSubtasks(jsonObject["subtasks"])
180
186
  end
181
187
 
182
188
  if jsonObject.has_key?("tasklist")
@@ -210,6 +216,61 @@ module Projects
210
216
  return owner
211
217
  end
212
218
 
219
+ # * Parse the JSON response and make it into list of Comment object.
220
+ #
221
+ # ==== Parameters
222
+ #
223
+ # * response:: - JSON response contains the details of the task comments.
224
+ #
225
+ # ==== Returns
226
+ #
227
+ # * Returns List of Comment object.
228
+
229
+ def getComments(response)
230
+
231
+ jsonObject = JSON.parse response
232
+
233
+ commentsList = Array.new
234
+
235
+ if jsonObject.has_key?("comments")
236
+
237
+ comments = jsonObject["comments"]
238
+
239
+ for i in 0...comments.length
240
+
241
+ commentsList.push(jsonToComment(comments[i]))
242
+
243
+ end
244
+
245
+ end
246
+
247
+ return commentsList
248
+ end
249
+
250
+
251
+ # * Parse the JSON response and make it into Comment object.
252
+ #
253
+ # ==== Parameters
254
+ #
255
+ # * response:: - JSON response contains the details of a comment.
256
+ #
257
+ # ==== Returns
258
+ #
259
+ # * Returns the Comment object.
260
+
261
+
262
+ def getComment(response)
263
+
264
+ jsonObject = JSON.parse response
265
+
266
+ comments = jsonObject["comments"]
267
+
268
+ return jsonToComment(comments[0])
269
+
270
+ end
271
+
272
+
273
+
213
274
  # * Parse the JSONObject into Comment object.
214
275
  #
215
276
  # ==== Parameters
@@ -290,4 +351,4 @@ module Projects
290
351
  end
291
352
  end
292
353
  end
293
- end
354
+ end
@@ -171,4 +171,4 @@ module Projects
171
171
  end
172
172
  end
173
173
  end
174
- end
174
+ end
data/lib/zohoProjects.rb CHANGED
@@ -16,6 +16,8 @@ require 'projects/model/Project'
16
16
  require 'projects/model/Activity'
17
17
  require 'projects/model/Milestone'
18
18
  require 'projects/model/Tasklist'
19
+ require 'projects/model/Customfield'
20
+ require 'projects/model/Defaultfield'
19
21
  require 'projects/model/Task'
20
22
  require 'projects/model/Owner'
21
23
  require 'projects/model/Bug'
@@ -1,3 +1,3 @@
1
1
  module ZohoProjects
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/zohoProjects.gemspec CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.files = %w[
18
18
  Gemfile
19
19
  Gemfile.lock
20
- LICENSE.txt
20
+ LICENSE
21
21
  Rakefile
22
22
  README.md
23
23
  zohoProjects.gemspec
@@ -41,6 +41,8 @@ Gem::Specification.new do |spec|
41
41
  lib/projects/model/Buglog.rb
42
42
  lib/projects/model/Category.rb
43
43
  lib/projects/model/Comment.rb
44
+ lib/projects/model/Customfield.rb
45
+ lib/projects/model/Defaultfield.rb
44
46
  lib/projects/model/Document.rb
45
47
  lib/projects/model/Event.rb
46
48
  lib/projects/model/Folder.rb
@@ -75,7 +77,6 @@ Gem::Specification.new do |spec|
75
77
  lib/projects/util/ZohoHTTPClient.rb
76
78
  lib/projects/exception/ProjectsException.rb
77
79
  lib/projects/service/ZohoProject.rb
78
- lib/test/ProjectsTest.rb
79
80
  ]
80
81
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
81
82
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})