File Coverage

blib/lib/Mojo/Weixin/Model/Remote/_webwxbatchgetcontact_group_member.pm
Criterion Covered Total %
statement 6 28 21.4
branch 0 10 0.0
condition 0 4 0.0
subroutine 2 3 66.6
pod n/a
total 8 45 17.7


line stmt bran cond sub pod time code
1 1     1   6 use strict;
  1         2  
  1         26  
2 1     1   5 use Mojo::Weixin::Const qw(%KEY_MAP_GROUP_MEMBER);
  1         1  
  1         308  
3             sub Mojo::Weixin::_webwxbatchgetcontact_group_member{
4 0     0     my $self = shift;
5 0   0       my $eid = shift // '';
6 0           my @ids = @_;
7 0           my @return;
8 0           my $api = "https://".$self->domain . "/cgi-bin/mmwebwx-bin/webwxbatchgetcontact";
9              
10 0           while( my @id = splice(@ids,0,50) ){
11 0           my @query_string = (
12             type => "ex",
13             r => $self->now(),
14             );
15 0 0         push @query_string,(pass_ticket => $self->pass_ticket) if $self->pass_ticket;
16             my $post = {
17             BaseRequest => {
18             Uin => $self->wxuin,
19             DeviceID => $self->deviceid,
20             Sid => $self->wxsid,
21             Skey => $self->skey,
22             },
23             Count => @id+0,
24 0           List => [ map { {UserName=>$_,EncryChatRoomId=>$eid} } @id ],
  0            
25             };
26 0           my $json = $self->http_post($self->gen_url2($api,@query_string),{Referer=>'https://'.$self->domain . '/',json=>1},json=>$post);
27 0 0         next unless defined $json;
28 0 0         next if $json->{BaseResponse}{Ret}!=0;
29 0           for my $e (@{$json->{ContactList}}){
  0            
30 0           my $member = {};
31 0           for(keys %KEY_MAP_GROUP_MEMBER){
32 0   0       $member->{$_} = $e->{$KEY_MAP_GROUP_MEMBER{$_}} // "";
33             }
34 0           $member->{sex} = $self->code2sex($member->{sex});
35 0           push @return,$member;
36             }
37              
38             }
39 0 0         return if @return ==0;
40 0 0         return wantarray?@return:$return[0];
41             }
42              
43             1;