Class: CommitTracker::TrackStudio
- Inherits:
-
Object
- Object
- CommitTracker::TrackStudio
- Defined in:
- lib/commit_tracker/trackstudio.rb
Overview
CommitTracker::TrackStudio
Cleint for TrackStudio
Instance Method Summary collapse
-
#create_message(options = {}) ⇒ Object
create message and return message id.
-
#create_task(options = {}) ⇒ Object
create task and return task id.
-
#delete_message(options = {}) ⇒ Object
delete message by message id.
-
#delete_task(options = {}) ⇒ Object
delete task by id or number.
-
#get_category_for_task(taskId, category) ⇒ Object
return category id by task id and name category.
-
#get_category_list_for_task(taskId) ⇒ Object
return categoryes by task id.
-
#get_mstatus_id(taskId, msg_status) ⇒ Object
return message status id by name.
-
#get_priority_for_wokflow(workflow_id) ⇒ Object
retrun available priority for workflow id.
-
#get_priority_id(taskId, priority) ⇒ Object
return priority id by name and task id.
-
#get_resolution_id(mstatusId, resolution) ⇒ Object
return priority id by message status id and resolution name.
-
#get_task_id(task_number) ⇒ Object
return task id by number.
-
#get_user_id(user) ⇒ Object
return user id by name.
-
#get_workflow_for_task(taskId) ⇒ Object
return available workflows by task id.
-
#initialize(options = {}) ⇒ TrackStudio
constructor
Initializes the CommitTracker::TrackStudio.
Constructor Details
#initialize(options = {}) ⇒ TrackStudio
Initializes the CommitTracker::TrackStudio
Examples
ts = CommitTracker::TrackStudio.new(:url => 'http://ts.domain.com/TrackStudio/services/',
:login => 'user',
:password => 'qwerty')
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/commit_tracker/trackstudio.rb', line 17 def initialize(={}) url = [:url] || 'http://localhost/TrackStudio/services/' @login = [:login] || 'login' @password = [:password] || 'password' Savon.configure do |config| config.soap_version = 2 end @User = Savon::Client.new do wsdl.document = url + "User?wsdl" end @Task = Savon::Client.new do wsdl.document = url + "Task?wsdl" end @Message = Savon::Client.new do wsdl.document = url + "Message?wsdl" end @Step = Savon::Client.new do wsdl.document = url + "Step?wsdl" end @Acl = Savon::Client.new do wsdl.document = url + "Acl?wsdl" end @Bookmark = Savon::Client.new do wsdl.document = url + "Bookmark?wsdl" end @Category = Savon::Client.new do wsdl.document = url + "Category?wsdl" end @Constants = Savon::Client.new do wsdl.document = url + "Constants?wsdl" end @Export = Savon::Client.new do wsdl.document = url + "Export?wsdl" end @Filter = Savon::Client.new do wsdl.document = url + "Filter?wsdl" end @Find = Savon::Client.new do wsdl.document = url + "Find?wsdl" end @Index = Savon::Client.new do wsdl.document = url + "Index?wsdl" end @MailImport = Savon::Client.new do wsdl.document = url + "MailImport?wsdl" end @Prstatus = Savon::Client.new do wsdl.document = url + "Prstatus?wsdl" end @Registration = Savon::Client.new do wsdl.document = url + "Registration?wsdl" end @Registration = Savon::Client.new do wsdl.document = url + "Registration?wsdl" end @Report = Savon::Client.new do wsdl.document = url + "Report?wsdl" end @SCM = Savon::Client.new do wsdl.document = url + "SCM?wsdl" end @Template = Savon::Client.new do wsdl.document = url + "Template?wsdl" end @Udf = Savon::Client.new do wsdl.document = url + "Udf?wsdl" end @Workflow = Savon::Client.new do wsdl.document = url + "Workflow?wsdl" end @sessionId = nil begin response = @User.request :soap, :authenticate, :body => { :login => @login, :password => @password } @sessionId = response.to_hash[:authenticate_response][:return] rescue Savon::SOAP::Fault => e raise ErrorCommitTask, e.to_hash[:fault][:reason][:text] end end |
Instance Method Details
#create_message(options = {}) ⇒ Object
create message and return message id
-
task number (:task_number)
-
message status (:msg_status)
-
text message (:comment)
-
time spent (:hrs)
-
assigned user (:user)
-
change resolution task (:resolution)
-
change priority task (:priority)
-
add budget time for task in seconds (:budget_sec)
-
set deadline day (:deadline_sec)
-
send notify to email (:is_notify)
Examples
= ts.(:task_number => "1234",
:msg_status => "Assigned",
:comment => "test msg!!!!",
:hrs => 3*3600,
:user => "user_1",
:resolution => nil,
:priority => "Normal",
:budget_sec => nil,
:deadline_sec => Time.now.to_i + 4 * 86400,
:is_notify => true)
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 |
# File 'lib/commit_tracker/trackstudio.rb', line 455 def (={}) begin priorityId = nil resolutionId = nil [:is_notify] = false if [:is_notify].nil? [:comment] = "" if [:comment].nil? [:deadline_sec] *= 1000 if ![:deadline_sec].nil? taskId = get_task_id([:task_number]) mstatusId = get_mstatus_id(taskId, [:msg_status]) handlerUserId = get_user_id([:user]) priorityId = get_priority_id(taskId, [:priority]) if ![:priority].nil? resolutionId = get_resolution_id(mstatusId, [:resolution]) if ![:resolution].nil? = @Message.request :soap, :createMessage, :body => { :sessionId => @sessionId.to_s, :taskId => taskId, :mstatusId => mstatusId, :text => [:comment], :hrs => [:hrs], :handlerUserId => handlerUserId, :handlerGroupId => nil, :resolutionId => resolutionId, :priorityId => priorityId, :deadlineLong => [:deadline_sec], :budget => [:budget_sec], :sendMail => [:is_notify] } rescue Savon::SOAP::Fault => e raise ErrorCommitTask, e.to_hash[:fault][:reason][:text] end return .to_hash[:create_message_response][:return] end |
#create_task(options = {}) ⇒ Object
create task and return task id
Options:
-
name task (:name)
-
short name task (:shortname)
-
assigned user (:user)
-
parent task (:parent_number)
-
description (:description)
-
priority (:priority)
-
category task (:category)
-
budget time for task in seconds (:budget_sec)
-
deadline day (:deadline_sec)
-
name custom fields (:udf_names)(array)
-
value custom fields (:udf_values)(array)
Examples
taskId = ts.create_task(:name => "example task 1"
:shortname => "ex1",
:user => "user_1",
:parent_number => 123,
:description => "This is example task"
:priority => "Normal",
:category => "Task",
:budget_sec => 3 * 3600,
:deadline_sec => Time.now.to_i + 5 * 86400,
:udf_names => ['one', 'two'],
:udf_values => ['test', 4] )
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 |
# File 'lib/commit_tracker/trackstudio.rb', line 399 def create_task(={}) begin handlerUserId = get_user_id([:user]) parentId = get_task_id([:parent_number]) priorityId = get_priority_id(parentId, [:priority]) if ![:priority].nil? categoryId = get_category_for_task(parentId, [:category]) [:deadline_sec] *= 1000 if ![:deadline_sec].nil? task_number = @Task.request :soap, :createTask, :body => { :sessionId => @sessionId.to_s, :categoryId => categoryId, :shortname => [:shortname], :name => [:name], :description => [:description], :budget => [:budget_sec], :deadline => [:deadline_sec], :priorityId => priorityId, :parentId => parentId, :handlerUserId => handlerUserId, :handlerGroupId => nil, :udfNames => [:udf_names], :udfValues => [:udf_values] } rescue Savon::SOAP::Fault => e raise ErrorCommitTask, e.to_hash[:fault][:reason][:text] end end |
#delete_message(options = {}) ⇒ Object
delete message by message id
Examples
ts.(:messageId => "4028929033561c0801335a5490e80433")
360 361 362 363 364 365 366 367 368 369 |
# File 'lib/commit_tracker/trackstudio.rb', line 360 def (={}) begin @Message.request :soap, :deleteMessage, :body => { :sessionId => @sessionId.to_s, :messageId => [:messageId] } rescue Savon::SOAP::Fault => e raise ErrorCommitTask, e.to_hash[:fault][:reason][:text] end end |
#delete_task(options = {}) ⇒ Object
delete task by id or number
Examples
ts.delete_task(:task_number => 1234)
ts.delete_task(:task_number => taskId)
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 |
# File 'lib/commit_tracker/trackstudio.rb', line 335 def delete_task(={}) begin taskId = nil if ![:task_number].nil? and [:task_number].integer? taskId = get_task_id([:task_number]) else taskId = [:task_number] end @Task.request :soap, :deleteTask, :body => { :sessionId => @sessionId.to_s, :taskId => taskId } rescue Savon::SOAP::Fault => e raise ErrorCommitTask, e.to_hash[:fault][:reason][:text] end end |
#get_category_for_task(taskId, category) ⇒ Object
return category id by task id and name category
Examples
category = ts.get_category_for_task(taskId, "Task")
313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
# File 'lib/commit_tracker/trackstudio.rb', line 313 def get_category_for_task(taskId, category) begin categories_list = get_category_list_for_task(taskId) return nil if categories_list.nil? categories_list.each do |item| return item[:id] if item[:name] == category end rescue Savon::SOAP::Fault => e raise ErrorCommitTask, e.to_hash[:fault][:reason][:text] end end |
#get_category_list_for_task(taskId) ⇒ Object
return categoryes by task id
Examples
categoryes_list = ts.get_category_list_for_task(taskId)
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 |
# File 'lib/commit_tracker/trackstudio.rb', line 291 def get_category_list_for_task(taskId) begin response = @Category.request :soap, :getCreatableCategoryList, :body => { :sessionId => @sessionId.to_s, :taskId => taskId } value = response.to_hash[:get_creatable_category_list_response][:return] value = [value] if !value.kind_of?(Array) and !value.nil? return value rescue Savon::SOAP::Fault => e raise ErrorCommitTask, e.to_hash[:fault][:reason][:text] end end |
#get_mstatus_id(taskId, msg_status) ⇒ Object
return message status id by name
Examples
msg_status = "New"
mstatusId = ts.get_mstatus_id(taskId, msg_status)
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/commit_tracker/trackstudio.rb', line 150 def get_mstatus_id(taskId, msg_status) raise ErrorCommitTask, "msg_status is nil" if msg_status.nil? begin response = @Step.request :soap, :getAvailableMstatusList, :body => { :sessionId => @sessionId.to_s, :taskId => taskId } value = response.to_hash[:get_available_mstatus_list_response][:return] if !value.nil? value = [value] if !value.kind_of?(Array) value.each do |item| return item[:id] if item[:name] == msg_status end end rescue Savon::SOAP::Fault => e raise ErrorCommitTask, e.to_hash[:fault][:reason][:text] end return nil end |
#get_priority_for_wokflow(workflow_id) ⇒ Object
retrun available priority for workflow id
Examples
priorityId = ts.get_priority_for_wokflow(workflowId)
218 219 220 221 222 223 224 225 226 |
# File 'lib/commit_tracker/trackstudio.rb', line 218 def get_priority_for_wokflow(workflow_id) response = @Workflow.request :soap, :getPriorityList, :body => { :sessionId => @sessionId.to_s, :workflowId => workflow_id } value = response.to_hash[:get_priority_list_response][:return] return value end |
#get_priority_id(taskId, priority) ⇒ Object
return priority id by name and task id
Examples
taskId = ts.get_task_id(1234)
priorityId = ts.get_priority_id(taskId, "Medium")
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
# File 'lib/commit_tracker/trackstudio.rb', line 234 def get_priority_id(taskId, priority) begin workflow_list = get_workflow_for_task(taskId) workflow_list = [workflow_list] if !workflow_list.kind_of?(Array) workflow_list.each do |workflow| value = get_priority_for_wokflow(workflow[:id]) next if value.nil? value = [value] if !value.kind_of?(Array) value.each do |item| return item[:id] if item[:name] == priority end end rescue Savon::SOAP::Fault => e raise ErrorCommitTask, e.to_hash[:fault][:reason][:text] end return nil end |
#get_resolution_id(mstatusId, resolution) ⇒ Object
return priority id by message status id and resolution name
Examples
resolutionId = ts.get_resolution_id(mstatusId, "inProgress")
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
# File 'lib/commit_tracker/trackstudio.rb', line 262 def get_resolution_id(mstatusId, resolution) begin response = @Workflow.request :soap, :getResolutionList, :body => { :sessionId => @sessionId.to_s, :mstatusId => mstatusId } value = response.to_hash[:get_resolution_list_response][:return] if !value.nil? value = [value] if !value.kind_of?(Array) value.each do |item| return item[:id] if item[:name] == resolution end end rescue Savon::SOAP::Fault => e raise ErrorCommitTask, e.to_hash[:fault][:reason][:text] end return nil end |
#get_task_id(task_number) ⇒ Object
return task id by number
Examples
taskId = ts.get_task_id(1234)
128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/commit_tracker/trackstudio.rb', line 128 def get_task_id(task_number) raise ErrorCommitTask, "task number is nil" if task_number.nil? begin response = @Task.request :soap, :findTaskIdByQuickGo, :body => { :sessionId => @sessionId.to_s, :quickGo => task_number } taskId = response.to_hash[:find_task_id_by_quick_go_response][:return] return taskId rescue Savon::SOAP::Fault => e raise ErrorCommitTask, e.to_hash[:fault][:reason][:text] end end |
#get_user_id(user) ⇒ Object
return user id by name
Examples
userId = ts.get_user_id("user_1")
180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/commit_tracker/trackstudio.rb', line 180 def get_user_id(user) begin find_user = user || @login response = @User.request :soap, :findUserIdByQuickGo, :body => { :sessionId => @sessionId.to_s, :quickGo => find_user } return response.to_hash[:find_user_id_by_quick_go_response][:return] rescue Savon::SOAP::Fault => e raise ErrorCommitTask, e.to_hash[:fault][:reason][:text] end end |
#get_workflow_for_task(taskId) ⇒ Object
return available workflows by task id
Examples
taskId = ts.get_task_id(1234)
workflow_list = ts.get_workflow_for_task(taskId)
200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/commit_tracker/trackstudio.rb', line 200 def get_workflow_for_task(taskId) begin response = @Workflow.request :soap, :getAvailableWorkflowList, :body => { :sessionId => @sessionId.to_s, :taskId => taskId } return response.to_hash[:get_available_workflow_list_response][:return] rescue Savon::SOAP::Fault => e raise ErrorCommitTask, e.to_hash[:fault][:reason][:text] end end |