Class: SimpleWx::Messages::MusicMessage

Inherits:
SimpleWx::Message show all
Defined in:
lib/simple_wx/messages/music_message.rb

Instance Attribute Summary

Attributes inherited from SimpleWx::Message

#json, #openid, #xml

Attributes inherited from Base

#error, #raise_flag

Instance Method Summary collapse

Methods inherited from Base

method_missing

Constructor Details

#initialize(options) ⇒ MusicMessage

Returns a new instance of MusicMessage.



4
5
6
7
# File 'lib/simple_wx/messages/music_message.rb', line 4

def initialize options
  super
  @music = options[:music]
end

Instance Method Details

#send_jsonObject



9
10
11
12
13
14
# File 'lib/simple_wx/messages/music_message.rb', line 9

def send_json
  @json[:msgtype] = "music"
  @json[:music] = @music
  SimpleWx.logger.info("SimpleWxLog:#{self.class.name} -- #{@openid} -- #{json}")
  super
end

#to_xmlObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/simple_wx/messages/music_message.rb', line 16

def to_xml
  @xml["MsgType"] = "music"
  @xml["Music"] = {
    "Title"        => @music[:title],
    "Description"  => @music[:description],
    "MusicUrl"     => @music[:music_url],
    "HQMusicUrl"   => @music[:hq_music_url],
    "ThumbMediaId" => @music[:thumb_media_id]
  }
  super
end