Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
weixin_authorize
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
weixin_authorize
Commits
2b583a54
Commit
2b583a54
authored
Jun 28, 2015
by
lanrion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加批量更新分组,删除分组API
parent
e11e584b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
8 deletions
+37
-8
.gitignore
+1
-0
lib/weixin_authorize/api/groups.rb
+11
-0
spec/api/custom_spec.rb
+0
-3
spec/api/groups_spec.rb
+25
-5
No files found.
.gitignore
View file @
2b583a54
...
...
@@ -16,3 +16,4 @@ test/tmp
test/version_tmp
tmp
*DS_Store
.ruby-version
lib/weixin_authorize/api/groups.rb
View file @
2b583a54
...
...
@@ -38,6 +38,17 @@ module WeixinAuthorize
http_post
(
group_url
,
{
openid:
openid
,
to_groupid:
to_groupid
})
end
# 批量移动用户分组
def
batch_update_group_for_openids
(
openids
,
group_id
)
group_url
=
"
#{
group_base_url
}
/members/batchupdate"
http_post
(
group_url
,
{
openid_list:
openids
,
to_groupid:
group_id
})
end
def
delete_group
(
group_id
)
group_url
=
"
#{
group_base_url
}
/delete"
http_post
(
group_url
,
{
group:
{
id:
group_id
}})
end
private
def
group_base_url
...
...
spec/api/custom_spec.rb
View file @
2b583a54
...
...
@@ -42,17 +42,14 @@ describe WeixinAuthorize::Api::Custom do
it
"#send_video_custom"
do
pending
(
"The test must have a media_id"
)
this_should_not_get_executed
end
it
"#send_music_custom"
do
pending
(
"The test must have a media_id"
)
this_should_not_get_executed
end
it
"#send_voice_custom"
do
pending
(
"The test must have a media_id"
)
this_should_not_get_executed
end
end
spec/api/groups_spec.rb
View file @
2b583a54
...
...
@@ -8,18 +8,35 @@ describe WeixinAuthorize::Api::Groups do
"test group_name_2"
end
let
(
:groups
)
do
$client
.
groups
end
let
(
:last_group_id
)
do
groups
.
result
[
"groups"
][
-
1
][
"id"
]
end
it
"#delete all group step by step"
do
group_ids
=
groups
.
result
[
"groups"
].
collect
{
|
group
|
group
[
"id"
]}
group_ids
.
each
do
|
group_id
|
res
=
$client
.
delete_group
(
group_id
)
if
res
.
code
.
to_s
!=
"45009"
expect
(
res
.
code
).
to
eq
(
WeixinAuthorize
::
OK_CODE
)
end
end
end
it
"create a group"
do
response
=
$client
.
create_group
(
group_name
)
if
response
.
code
==
WeixinAuthorize
::
OK_CODE
expect
(
response
.
result
[
"group"
][
"name"
]).
to
eq
(
group_name
)
else
expect
(
response
.
code
).
to
eq
(
-
1
)
puts
"
SB
WEIXIN says: system error"
puts
"WEIXIN says: system error"
end
end
it
"get groups"
do
groups
=
$client
.
groups
expect
(
groups
.
result
[
"groups"
][
-
1
][
"name"
]).
to
eq
(
group_name
)
end
...
...
@@ -32,7 +49,7 @@ describe WeixinAuthorize::Api::Groups do
response
=
$client
.
create_group
(
group_name
)
if
response
.
code
!=
WeixinAuthorize
::
OK_CODE
expect
(
response
.
code
).
to
eq
(
-
1
)
puts
"
SB
WEIXIN says: system error"
puts
"WEIXIN says: system error"
else
expect
(
response
.
result
[
"group"
][
"name"
]).
to
eq
(
group_name
)
response
=
$client
.
update_group_name
(
response
.
result
[
"group"
][
"id"
],
group_name_2
)
...
...
@@ -43,12 +60,15 @@ describe WeixinAuthorize::Api::Groups do
end
it
"#update_group_for_openid"
do
groups
=
$client
.
groups
last_group_id
=
groups
.
result
[
"groups"
][
-
1
][
"id"
]
$client
.
update_group_for_openid
(
ENV
[
"OPENID"
],
last_group_id
)
group
=
$client
.
get_group_for
(
ENV
[
"OPENID"
])
expect
(
group
.
result
[
"groupid"
]).
to
eq
(
last_group_id
)
$client
.
update_group_for_openid
(
ENV
[
"OPENID"
],
0
)
end
it
"#batch update group for openids"
do
res
=
$client
.
batch_update_group_for_openids
([
ENV
[
"OPENID"
]],
last_group_id
)
expect
(
res
.
code
).
to
eq
(
WeixinAuthorize
::
OK_CODE
)
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment