Class: OTRS::Service
Instance Attribute Summary collapse
-
#change_by ⇒ Object
Returns the value of attribute change_by.
-
#change_time ⇒ Object
Returns the value of attribute change_time.
-
#comment ⇒ Object
Returns the value of attribute comment.
-
#config_items ⇒ Object
Returns the value of attribute config_items.
-
#create_by ⇒ Object
Returns the value of attribute create_by.
-
#create_time ⇒ Object
Returns the value of attribute create_time.
-
#criticality ⇒ Object
Returns the value of attribute criticality.
-
#criticality_id ⇒ Object
Returns the value of attribute criticality_id.
-
#cur_inci_state ⇒ Object
Returns the value of attribute cur_inci_state.
-
#cur_inci_state_id ⇒ Object
Returns the value of attribute cur_inci_state_id.
-
#cur_inci_state_type ⇒ Object
Returns the value of attribute cur_inci_state_type.
-
#cur_inci_state_type_from_c_is ⇒ Object
Returns the value of attribute cur_inci_state_type_from_c_is.
-
#name ⇒ Object
Returns the value of attribute name.
-
#name_short ⇒ Object
Returns the value of attribute name_short.
-
#parent_id ⇒ Object
Returns the value of attribute parent_id.
-
#service_id ⇒ Object
Returns the value of attribute service_id.
-
#tickets ⇒ Object
Returns the value of attribute tickets.
-
#type ⇒ Object
Returns the value of attribute type.
-
#type_id ⇒ Object
Returns the value of attribute type_id.
-
#valid_id ⇒ Object
Returns the value of attribute valid_id.
Class Method Summary collapse
Instance Method Summary collapse
- #create(attributes) ⇒ Object
-
#initialize(attributes = {}) ⇒ Service
constructor
A new instance of Service.
- #persisted? ⇒ Boolean
- #save ⇒ Object
Methods inherited from OTRS
api_url, api_url=, #attributes, #connect, connect, get_from_remote, object_preprocessor, password, password=, process_response, setup_connection_params, user, user=
Constructor Details
#initialize(attributes = {}) ⇒ Service
Returns a new instance of Service.
11 12 13 14 15 |
# 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 |
Instance Attribute Details
#change_by ⇒ Object
Returns the value of attribute change_by.
2 3 4 |
# File 'lib/otrs_connector/otrs/service.rb', line 2 def change_by @change_by end |
#change_time ⇒ Object
Returns the value of attribute change_time.
2 3 4 |
# File 'lib/otrs_connector/otrs/service.rb', line 2 def change_time @change_time end |
#comment ⇒ Object
Returns the value of attribute comment.
2 3 4 |
# File 'lib/otrs_connector/otrs/service.rb', line 2 def comment @comment end |
#config_items ⇒ Object
Returns the value of attribute config_items.
2 3 4 |
# File 'lib/otrs_connector/otrs/service.rb', line 2 def config_items @config_items end |
#create_by ⇒ Object
Returns the value of attribute create_by.
2 3 4 |
# File 'lib/otrs_connector/otrs/service.rb', line 2 def create_by @create_by end |
#create_time ⇒ Object
Returns the value of attribute create_time.
2 3 4 |
# File 'lib/otrs_connector/otrs/service.rb', line 2 def create_time @create_time end |
#criticality ⇒ Object
Returns the value of attribute criticality.
2 3 4 |
# File 'lib/otrs_connector/otrs/service.rb', line 2 def criticality @criticality end |
#criticality_id ⇒ Object
Returns the value of attribute criticality_id.
2 3 4 |
# File 'lib/otrs_connector/otrs/service.rb', line 2 def criticality_id @criticality_id end |
#cur_inci_state ⇒ Object
Returns the value of attribute cur_inci_state.
2 3 4 |
# File 'lib/otrs_connector/otrs/service.rb', line 2 def cur_inci_state @cur_inci_state end |
#cur_inci_state_id ⇒ Object
Returns the value of attribute cur_inci_state_id.
2 3 4 |
# File 'lib/otrs_connector/otrs/service.rb', line 2 def cur_inci_state_id @cur_inci_state_id end |
#cur_inci_state_type ⇒ Object
Returns the value of attribute cur_inci_state_type.
2 3 4 |
# File 'lib/otrs_connector/otrs/service.rb', line 2 def cur_inci_state_type @cur_inci_state_type end |
#cur_inci_state_type_from_c_is ⇒ Object
Returns the value of attribute cur_inci_state_type_from_c_is.
2 3 4 |
# File 'lib/otrs_connector/otrs/service.rb', line 2 def cur_inci_state_type_from_c_is @cur_inci_state_type_from_c_is end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/otrs_connector/otrs/service.rb', line 2 def name @name end |
#name_short ⇒ Object
Returns the value of attribute name_short.
2 3 4 |
# File 'lib/otrs_connector/otrs/service.rb', line 2 def name_short @name_short end |
#parent_id ⇒ Object
Returns the value of attribute parent_id.
2 3 4 |
# File 'lib/otrs_connector/otrs/service.rb', line 2 def parent_id @parent_id end |
#service_id ⇒ Object
Returns the value of attribute service_id.
2 3 4 |
# File 'lib/otrs_connector/otrs/service.rb', line 2 def service_id @service_id end |
#tickets ⇒ Object
Returns the value of attribute tickets.
2 3 4 |
# File 'lib/otrs_connector/otrs/service.rb', line 2 def tickets @tickets end |
#type ⇒ Object
Returns the value of attribute type.
2 3 4 |
# File 'lib/otrs_connector/otrs/service.rb', line 2 def type @type end |
#type_id ⇒ Object
Returns the value of attribute type_id.
2 3 4 |
# File 'lib/otrs_connector/otrs/service.rb', line 2 def type_id @type_id end |
#valid_id ⇒ Object
Returns the value of attribute valid_id.
2 3 4 |
# File 'lib/otrs_connector/otrs/service.rb', line 2 def valid_id @valid_id end |
Class Method Details
.all ⇒ Object
92 93 94 |
# File 'lib/otrs_connector/otrs/service.rb', line 92 def self.all self.where(:name => '%') end |
.find(id) ⇒ Object
17 18 19 20 21 22 23 24 |
# 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 |
.where(attributes) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# 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 |
Instance Method Details
#create(attributes) ⇒ Object
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 |
# 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? ⇒ Boolean
7 8 9 |
# File 'lib/otrs_connector/otrs/service.rb', line 7 def persisted? false end |
#save ⇒ Object
26 27 28 29 30 |
# File 'lib/otrs_connector/otrs/service.rb', line 26 def save run_callbacks :save do self.create(self.attributes) end end |