Module: WxExt::Api::Menu

Extended by:
Menu
Included in:
Menu
Defined in:
lib/wx_ext/api/menu.rb

Overview

User api of weixin.

Author:

  • FuShengYang

Instance Method Summary collapse

Instance Method Details

#create_menu(access_token, menu_hash) ⇒ Hash

Create menu via post.

Parameters:

  • access_token (Enumerable<String>)
  • menu_hash (Hash)

Returns:

  • (Hash)

    Json based hash.



19
20
21
22
23
# File 'lib/wx_ext/api/menu.rb', line 19

def create_menu(access_token, menu_hash)
  url = 'https://api.weixin.qq.com/cgi-bin/menu/create'\
        "?access_token=#{access_token}"
  Helper.http_post(url, menu_hash.to_json)
end

#del_menu(access_token) ⇒ Hash

Del menu via get.

Parameters:

  • access_token (Enumerable<String>)

Returns:

  • (Hash)

    Json based hash.



39
40
41
42
43
# File 'lib/wx_ext/api/menu.rb', line 39

def del_menu(access_token)
  url = 'https://api.weixin.qq.com/cgi-bin/menu/delete'\
        "?access_token=#{access_token}"
  Helper.http_get(url, { accept: :json })
end

Get menus via get.

Parameters:

  • access_token (Enumerable<String>)

Returns:

  • (Hash)

    Json based hash.



29
30
31
32
33
# File 'lib/wx_ext/api/menu.rb', line 29

def menus(access_token)
  url = 'https://api.weixin.qq.com/cgi-bin/menu/get'\
        "?access_token=#{access_token}"
  Helper.http_get(url, { accept: :json })
end