site logo

Example: Ticket deletion (Ruby)


Example: delete a ticket  

This script shows how to:

  • connect to your helpdesk API with your access key
  • delete a ticket with a specific id

 

#!/usr/bin/ruby
########################################
# $Id: delete-ticket.rb,v 1.1 2009/08/25 11:25:25 ivaylo Exp $
#
# This is an example how to use the Mojo Helpdesk API
# Language: ruby
#
# This script shows how to:
# - connect to your helpdesk API with your access key
# - update a ticket.
#
# You will need to adjust the URL and MYID values:
#
# URL - Base URL to your helpdesk.
#
# MYID - Your access key, as displayed on your "profile" page
#
########################################
# Feel free to use this code and modify to fit your needs.
# More information visit www.mojohelpdesk.com
########################################
require 'soap/wsdlDriver'
require 'open-uri'

########################################
# Your helpdesk URL
# URL = "http://supportxyz.mojohelpdeskcom
# MYID = "8b1459cfcb367d72419e2642e56fa3b72bc5c2a0"
#
# Replace the info below with your own:
########################################
########################################
URL = "http://myhelpdesk.mojohelpdesk.com"
MYID = "1c5f8839c504defffab67b258844741f10cf7a48"
########################################
begin
drv = SOAP::WSDLDriverFactory.new("#{URL}/backend/service.wsdl").create_rpc_driver
rescue
printf "Fatal error: Could not connect to server.wsdl or an error occured (%s). Check your URL and try again.\n", $!; exit(-1)
end

printf ">>> WSDL found.\n"

#
# Updating ticket id = 992
#
puts ">>> Deleting ticket"
res = drv.DeleteTicket("#{MYID}", 992)
if res['successful'] == true
printf ">>> Ticket delete successful\n"
puts res.inspect
else
printf ">>> Ticket delete failed\n"
printf ">>> Error: %s\n", res['error_message']
end

exit(0)