Sha256: 4bcdbb7ee65879ee3b87b64bc7afd6777d063a65f989a1ef679cf5b228ddf25d
Contents?: true
Size: 1.38 KB
Versions: 14
Compression:
Stored size: 1.38 KB
Contents
class OTRS::Ticket::Article < OTRS::Ticket def self.set_accessors(key) attr_accessor key.to_sym end 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 def save self.create(self.attributes) end 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 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 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 end
Version data entries
14 entries across 14 versions & 1 rubygems