Module: WxExt::Api::User::Group

Extended by:
Group
Included in:
Group
Defined in:
lib/wx_ext/api/user/group.rb

Overview

User group api of weixin.

Author:

  • FuShengYang

Instance Method Summary collapse

Instance Method Details

#create_group(access_token, group_name) ⇒ Hash

Create user group via post.

Parameters:

  • access_token (Enumerable<String>)
  • group_name (Enumerable<String>)

Returns:

  • (Hash)

    A json parse hash.



23
24
25
26
27
# File 'lib/wx_ext/api/user/group.rb', line 23

def create_group(access_token, group_name)
  url = 'https://api.weixin.qq.com/cgi-bin/groups/create'\
        "?access_token=#{access_token}"
  Helper.http_post(url, { group: { name: group_name } }.to_json)
end

#groups(access_token) ⇒ Hash

Get all groups via get.

Parameters:

  • access_token (Enumerable<String>)

Returns:

  • (Hash)

    A json parse hash.



33
34
35
36
37
# File 'lib/wx_ext/api/user/group.rb', line 33

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

#mv_user_group(access_token, openid, to_groupid) ⇒ Hash

Move user group via post.

Parameters:

  • access_token (Enumerable<String>)
  • openid (Enumerable<String>)
  • to_groupid (Enumerable<String>)

Returns:

  • (Hash)

    A json parse hash.



68
69
70
71
72
# File 'lib/wx_ext/api/user/group.rb', line 68

def mv_user_group(access_token, openid, to_groupid)
  url = 'https://api.weixin.qq.com/cgi-bin/groups/members/update'\
        "?access_token=#{access_token}"
  Helper.http_post(url, { openid: openid, to_groupid: to_groupid }.to_json)
end

#update_group_name(access_token, id, name) ⇒ Hash

Update user group name via post.

Parameters:

  • access_token (Enumerable<String>)
  • id (Enumerable<String>)
  • name (Enumerable<String>)

Returns:

  • (Hash)

    A json parse hash.



56
57
58
59
60
# File 'lib/wx_ext/api/user/group.rb', line 56

def update_group_name(access_token, id, name)
  url = 'https://api.weixin.qq.com/cgi-bin/groups/update'\
        "?access_token=#{access_token}"
  Helper.http_post(url, { group: { id: id, name: name } }.to_json)
end

#user_of_group(access_token, openid) ⇒ Hash

Get user of group via post.

Parameters:

  • access_token (Enumerable<String>)
  • openid (Enumerable<String>)

Returns:

  • (Hash)

    A json parse hash.



44
45
46
47
48
# File 'lib/wx_ext/api/user/group.rb', line 44

def user_of_group(access_token, openid)
  url = 'https://api.weixin.qq.com/cgi-bin/groups/getid'\
        "?access_token=#{access_token}"
  Helper.http_post(url, { openid: openid }.to_json)
end