class QyWechat::Message
Public Class Methods
factory(hash)
click to toggle source
# File lib/qy_wechat/message/message.rb, line 34 def self.factory(hash) case hash['MsgType'] when 'text' TextMessage.new(hash) when 'image' ImageMessage.new(hash) when 'location' LocationMessage.new(hash) when 'link' LinkMessage.new(hash) when 'event' EventMessage.new(hash) when 'voice' VoiceMessage.new(hash) when 'video' VideoMessage.new(hash) else raise ArgumentError, 'Unknown Message' end end
new(hash)
click to toggle source
# File lib/qy_wechat/message/message.rb, line 9 def initialize(hash) @source = OpenStruct.new(hash) end
Public Instance Methods
CreateTime()
click to toggle source
# File lib/qy_wechat/message/message.rb, line 17 def CreateTime @source.CreateTime.to_i end
MsgId()
click to toggle source
# File lib/qy_wechat/message/message.rb, line 21 def MsgId @source.MsgId.to_i end
agent_id()
click to toggle source
应用ID
# File lib/qy_wechat/message/message.rb, line 30 def agent_id @source.AgentID end
corp_id()
click to toggle source
# File lib/qy_wechat/message/message.rb, line 25 def corp_id @source.FromUserName end
method_missing(method, *args, &block)
click to toggle source
# File lib/qy_wechat/message/message.rb, line 13 def method_missing(method, *args, &block) @source.send(method, *args, &block) end