class OTRS::Service
Attributes
change_by[RW]
change_time[RW]
comment[RW]
config_items[RW]
create_by[RW]
create_time[RW]
criticality[RW]
criticality_id[RW]
cur_inci_state[RW]
cur_inci_state_id[RW]
cur_inci_state_type[RW]
cur_inci_state_type_from_c_is[RW]
name[RW]
name_short[RW]
parent_id[RW]
service_id[RW]
tickets[RW]
type[RW]
type_id[RW]
valid_id[RW]
Public Class Methods
all()
click to toggle source
# File lib/otrs_connector/otrs/service.rb, line 92 def self.all self.where(:name => '%') end
find(id)
click to toggle source
# File lib/otrs_connector/otrs/service.rb, line 17 def self.find(id) data = { 'ServiceID' => id, 'UserID' => 1 } params = { :object => 'ServiceObject', :method => 'ServiceGet', :data => data } object = self.object_preprocessor self.connect(params) object.run_callbacks :find do object end end
new(attributes = {})
click to toggle source
# File lib/otrs_connector/otrs/service.rb, line 11 def initialize(attributes = {}) attributes.each do |name, value| send("#{name.to_s.underscore.to_sym}=", value) end end
where(attributes)
click to toggle source
# File lib/otrs_connector/otrs/service.rb, line 75 def self.where(attributes) tmp = {} attributes.each do |key,value| tmp[key.to_s.camelize.to_sym] = value end attributes = tmp attributes[:UserID] = 1 data = attributes params = { :object => 'ServiceObjectCustom', :method => 'ServiceSearch', :data => data } a = connect(params) services = self.superclass::Relation.new a.each do |service| services << self.object_preprocessor(service) end services end
Public Instance Methods
create(attributes)
click to toggle source
# File lib/otrs_connector/otrs/service.rb, line 32 def create(attributes) attributes[:valid_id] ||= 1 attributes[:user_id] ||= 1 attributes[:type_id] ||= 1 attributes[:criticality_id] ||= 3 tmp = {} attributes.each do |key,value| if key == :user_id tmp[:UserID] = value end if key == :valid_id tmp[:ValidID] = value end if key == :type_id tmp[:TypeID] = value end if key == :criticality_id tmp[:CriticalityID] = value end if key == :parent_id tmp[:ParentID] = value end if key != :user_id or key != :valid_id or key != :type_id or key != :crticality_id or key != :parent_id tmp[key.to_s.camelize.to_sym] = value end end attributes = tmp data = attributes params = { :object => 'ServiceObject', :method => 'ServiceAdd', :data => data } a = connect(params) service_id = a.first unless service_id.nil? self.class.find(service_id) else raise "Could not create service" end service = self.class.find(service_id) service.attributes.each do |key,value| instance_variable_set "@#{key.to_s}", value end service end
persisted?()
click to toggle source
# File lib/otrs_connector/otrs/service.rb, line 7 def persisted? false end
save()
click to toggle source
# File lib/otrs_connector/otrs/service.rb, line 26 def save run_callbacks :save do self.create(self.attributes) end end