Class: Wechat::Message::Mass::Public
Overview
Constant Summary
collapse
- MSG_TYPE =
{
mpnews: 'media_id',
voice: 'media_id',
image: 'media_id',
mpvideo: 'media_id',
text: 'content',
wxcard: 'card_id'
}.freeze
Instance Attribute Summary
#msgtype
Instance Method Summary
collapse
#initialize, #restore
Methods inherited from Base
#content_blank?
Instance Method Details
#content(msgtype, body) ⇒ Object
33
34
35
36
37
38
|
# File 'app/apis/wechat/message/mass/public.rb', line 33
def content(msgtype, body)
@message_hash.merge! msgtype: msgtype
@message_hash[msgtype] = {
MSG_TYPE[msgtype.to_sym] => body
}
end
|
#do_send ⇒ Object
22
23
24
|
# File 'app/apis/wechat/message/mass/public.rb', line 22
def do_send
api.post @send_to, @message_hash
end
|
#to(*openid, **options) ⇒ Object
26
27
28
29
30
31
|
# File 'app/apis/wechat/message/mass/public.rb', line 26
def to(*openid, **options)
raise 'must send to more than 2 uses!' if openid.size < 2
@message_hash.merge!(touser: openid, **options)
@send_to = 'message/mass/send'
self
end
|
#to_mass(tag_id = nil, **options) ⇒ Object
12
13
14
15
16
17
18
19
20
|
# File 'app/apis/wechat/message/mass/public.rb', line 12
def to_mass(tag_id = nil, **options)
if tag_id
@message_hash.merge!(filter: { is_to_all: false, tag_id: tag_id }, **options)
else
@message_hash.merge!(filter: { is_to_all: true }, **options)
end
@send_to = 'message/mass/sendall'
self
end
|