Class: OTRS::Ticket::Article
Instance Attribute Summary
Attributes inherited from OTRS::Ticket
#age, #archive_flag, #changed, #create_time_unix, #created, #customer_id, #customer_user_id, #escalation_response_time, #escalation_solution_time, #escalation_time, #escalation_update_time, #group_id, #lock, #lock_id, #owner, #owner_id, #priority, #priority_id, #queue, #queue_id, #real_till_time_not_used, #responsible, #responsible_id, #service_id, #slaid, #state, #state_id, #state_type, #ticket_free_key1, #ticket_free_key10, #ticket_free_key11, #ticket_free_key12, #ticket_free_key13, #ticket_free_key14, #ticket_free_key15, #ticket_free_key16, #ticket_free_key2, #ticket_free_key3, #ticket_free_key4, #ticket_free_key5, #ticket_free_key6, #ticket_free_key7, #ticket_free_key8, #ticket_free_key9, #ticket_free_text1, #ticket_free_text10, #ticket_free_text11, #ticket_free_text12, #ticket_free_text13, #ticket_free_text14, #ticket_free_text15, #ticket_free_text16, #ticket_free_text2, #ticket_free_text3, #ticket_free_text4, #ticket_free_text5, #ticket_free_text6, #ticket_free_text7, #ticket_free_text8, #ticket_free_text9, #ticket_free_time1, #ticket_free_time2, #ticket_free_time3, #ticket_free_time4, #ticket_free_time5, #ticket_free_time6, #ticket_id, #ticket_number, #title, #type, #type_id, #unlock_timeout, #until_time
Class Method Summary
collapse
Instance Method Summary
collapse
#destroy, free_text_fields, #id, #name, #persisted?, #set_free_text_field, ticket_number_lookup
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 = {}) ⇒ Article
Returns a new instance of Article.
7
8
9
10
11
12
|
# File 'lib/otrs_connector/otrs/ticket/article.rb', line 7
def initialize(attributes = {})
attributes.each do |name, value|
OTRS::Ticket::Article.set_accessors(name.to_s.underscore)
send("#{name.to_s.underscore.to_sym}=", value)
end
end
|
Class Method Details
.find(id) ⇒ Object
30
31
32
33
34
35
36
|
# File 'lib/otrs_connector/otrs/ticket/article.rb', line 30
def self.find(id)
data = { 'ArticleID' => id, 'UserID' => 1 }
params = { :object => 'TicketObject', :method => 'ArticleGet', :data => data }
a = connect(params)
a = Hash[*a].symbolize_keys
self.new(a)
end
|
.set_accessors(key) ⇒ Object
3
4
5
|
# File 'lib/otrs_connector/otrs/ticket/article.rb', line 3
def self.set_accessors(key)
attr_accessor key.to_sym
end
|
.where(ticket_id) ⇒ Object
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/otrs_connector/otrs/ticket/article.rb', line 38
def self.where(ticket_id)
data = { 'TicketID' => ticket_id }
params = { :object => 'TicketObject', :method => 'ArticleIndex', :data => data }
a = connect(params)
b = []
a.each do |c|
b << find(c)
end
OTRS::Relation.new(b)
end
|
Instance Method Details
#create(attributes) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/otrs_connector/otrs/ticket/article.rb', line 17
def create(attributes)
data = { 'TicketID' => attributes[:ticket_id], 'From' => attributes[:email], 'Subject' => attributes[:title], 'Body' => attributes[:body] }
data['ArticleType'] ||= 'email-external'
data['UserID'] ||= 1
data['SenderType'] ||= 'agent'
data['HistoryType'] ||= 'NewTicket'
data['HistoryComment'] ||= ' '
data['ContentType'] ||= 'text/plain'
params = { :object => 'TicketObject', :method => 'ArticleCreate', :data => data }
a = connect(params)
if a.first.nil? then nil else a end
end
|
#save ⇒ Object
13
14
15
|
# File 'lib/otrs_connector/otrs/ticket/article.rb', line 13
def save
self.create(self.attributes)
end
|