Module: Wechat::Api::Work::Menu

Included in:
Wechat::Api::Work
Defined in:
app/apis/wechat/api/work/menu.rb

Constant Summary collapse

BASE =
'https://qyapi.weixin.qq.com/cgi-bin/'

Instance Method Summary collapse

Instance Method Details

#custom_message_send(message) ⇒ Object



42
43
44
# File 'app/apis/wechat/api/work/menu.rb', line 42

def custom_message_send(message)
  post 'message/send', message.is_a?(Wechat::Message) ? message.agent_id(@agentid).as_json : message.merge(agent_id: @agentid)
end

#material(media_id) ⇒ Object



26
27
28
# File 'app/apis/wechat/api/work/menu.rb', line 26

def material(media_id)
  get 'material/get', params: { media_id: media_id, agentid: @agentid }, as: :file, base: BASE
end

#material_add(type, file) ⇒ Object



30
31
32
# File 'app/apis/wechat/api/work/menu.rb', line 30

def material_add(type, file)
  post_file 'material/add_material', file, params: { type: type, agentid: @agentid }, base: BASE
end

#material_countObject



18
19
20
# File 'app/apis/wechat/api/work/menu.rb', line 18

def material_count
  get 'material/get_count', params: { agentid: @agentid }, base: BASE
end

#material_delete(media_id) ⇒ Object



34
35
36
# File 'app/apis/wechat/api/work/menu.rb', line 34

def material_delete(media_id)
  get 'material/del', params: { media_id: media_id, agentid: @agentid }, base: BASE
end

#material_list(type, offset, count) ⇒ Object



22
23
24
# File 'app/apis/wechat/api/work/menu.rb', line 22

def material_list(type, offset, count)
  post 'material/batchget', type: type, agentid: @agentid, offset: offset, count: count, base: BASE
end


5
6
7
# File 'app/apis/wechat/api/work/menu.rb', line 5

def menu
  get 'menu/get', params: { agentid: @agentid }, base: BASE
end


13
14
15
16
# File 'app/apis/wechat/api/work/menu.rb', line 13

def menu_create(menu)
  # 微信不接受7bit escaped json(eg \uxxxx), 中文必须UTF-8编码, 这可能是个安全漏洞
  post 'menu/create', menu, params: { agentid: @agentid }, base: BASE
end


9
10
11
# File 'app/apis/wechat/api/work/menu.rb', line 9

def menu_delete
  get 'menu/delete', params: { agentid: @agentid }, base: BASE
end

#message_send(userid, message) ⇒ Object



38
39
40
# File 'app/apis/wechat/api/work/menu.rb', line 38

def message_send(userid, message)
  post 'message/send', Message.to(userid).text(message).agent_id(@agentid), base: BASE
end