Git Product home page Git Product logo

ruby-sysaid's Introduction

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



# 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.4 Last updated: Wednesday, July 2, 2014

ruby-sysaid's People

Contributors

cthielen avatar mattmencel avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.