Module: WeixinAuthorize::Api::Groups

Included in:
Client
Defined in:
lib/weixin_authorize/api/groups.rb

Instance Method Summary collapse

Instance Method Details

#create_group(group_name) ⇒ Object



8
9
10
11
12
# File 'lib/weixin_authorize/api/groups.rb', line 8

def create_group(group_name)
  create_url = "#{group_base_url}/create?#{access_token_param}"
  group = MultiJson.dump({group: {name: group_name}})
  JSON.parse(RestClient.post(create_url, group))
end

#get_group_for(openid) ⇒ Object



23
24
25
26
27
# File 'lib/weixin_authorize/api/groups.rb', line 23

def get_group_for(openid)
  group_url = "#{group_base_url}/getid?#{access_token_param}"
  openid = MultiJson.dump({openid: openid})
  JSON.parse(RestClient.post(group_url, openid))
end

#groupsObject



16
17
18
19
# File 'lib/weixin_authorize/api/groups.rb', line 16

def groups
  groups_url = "#{group_base_url}/get?#{access_token_param}"
  JSON.parse(RestClient.get(groups_url))
end

#update_group_for_openid(openid, to_groupid) ⇒ Object



39
40
41
42
43
# File 'lib/weixin_authorize/api/groups.rb', line 39

def update_group_for_openid(openid, to_groupid)
  group_url = "#{group_base_url}/members/update?#{access_token_param}"
  group = MultiJson.dump({openid: openid, to_groupid: to_groupid})
  JSON.parse(RestClient.post(group_url, group))
end

#update_group_name(group_id, new_group_name) ⇒ Object



31
32
33
34
35
# File 'lib/weixin_authorize/api/groups.rb', line 31

def update_group_name(group_id, new_group_name)
  group_url = "#{group_base_url}/update?#{access_token_param}"
  group = MultiJson.dump({group: {id: openid, name: new_group_name}})
  JSON.parse(RestClient.post(group_url, group))
end