Project

sysaid

0.0
No commit activity in last 3 years
No release in over 3 years
Wrapper for the SysAid SOAP API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 2.3.0, ~> 2.3
 Project Readme

Description

ruby-sysaid is a Ruby-based wrapper for the SysAid SOAP API. It abstracts the nonsense that is dealing with SOAP in Ruby and provides a clean interface for dealing with SysAid API objects.

Installation

(Tested with Ruby 1.9.3, 2.0.x, 2.1.x)

Simply type:

gem install sysaid

If you're using Bundler add:

gem 'sysaid'

to your Gemfile.

If you'd like to build the gem from source:

gem build ./sysaid.gemspec
gem install ./sysaid-*.gem

(You may have to specify the specific version above, i.e. sysaid-0.1.0.gem.)

Usage

require 'sysaid'

SysAid::login "account", "username", "password", "wsdl_uri"

# Find a ticket by ID and change its title

ticket = SysAid::Ticket.find_by_id(123456)
if ticket
  puts "Ticket found. Title is: #{ticket.title}"

  ticket.title = "My title has changed."

  if ticket.save
    puts "Ticket saved successfully."
  else
    puts "Could not save ticket."
  end
else
  puts "Could not find ticket."
end


# Find all tickets by a status

tickets = SysAid::Ticket.find_by_query("status IN (1, 2, 3)")
if tickets
  puts "Found #{tickets.length} tickets."
else
  puts "Could not find any tickets."
end



# Create user 'deleteme' if he doesn't exist, delete him if he does

user = SysAid::User.find_by_username('deleteme')
unless user
  puts "Could not find user 'deleteme'. Creating..."

  user = SysAid::User.new('deleteme')
  if user.save
    puts "User saved successfully"
  else
    puts "Could not save user"
  end
else
  puts "User 'deleteme' found. Deleting."

  user.delete
end

# You could also have changed the user's name, e.g.
# user.first_name = "Don't Delete"
# user.save


# Find IDs of projects whose status = 2 (2 = Active)
projects = SysAid::Project.find_by_query("status=2")

if projects
  puts "== These projects are ACTIVE =="
  projects.each do |proj_id|
    project = SysAid::Project.find_by_id(proj_id)

    puts project.title
  end
end


# Find IDs of tasks whose project_id = 25
tasks = SysAid::Task.find_by_project_id(25)

if tasks
  puts "== These tasks are in project 25 =="
  tasks.each do |task_id|
    task = SysAid::Tasks.find_by_id(task_id)

    puts task.title
  end
end


# Find all activities related to ticket ID 12345
activity_ids = SysAid::Activity.find_by_ticket_id("12345")

if activity_ids
  activity_ids.each do |activity_id|
    activity = SysAid::Activity.find_by_id(activity_id)
    puts activity.description
  end
end

Error Handling

ruby-sysaid will throw a SysAidException exception on any problems it catches.

It is recommended you wrap all your SysAid code with a check for this exception, e.g.

begin
    activity_ids = SysAid::Activity.find_by_ticket_id("12345")
rescue SysAidException => e
    puts "SysAid error: #{e.message}"
end

Additional

Please file any bugs at https://github.com/cthielen/ruby-sysaid/issues.

Written by Christopher Thielen for the University of California Davis.

Available under the MIT license.

Version 0.3.5 Last updated: Monday, January 11, 2016