File Coverage

blib/lib/Mojo/Webqq/Model/Remote/_get_group_list_info.pm
Criterion Covered Total %
statement 3 30 10.0
branch 0 8 0.0
condition n/a
subroutine 1 4 25.0
pod n/a
total 4 42 9.5


line stmt bran cond sub pod time code
1 1     1   7 use strict;
  1         3  
  1         356  
2             sub Mojo::Webqq::Model::_get_group_list_info{
3 0     0     my $self = shift;
4 0           my $callback = shift;
5 0           my $api_url = 'http://s.web2.qq.com/api/get_group_name_list_mask2';
6 0           my $headers = {
7             Referer => 'http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1',
8             json=>1,
9             ua_request_timeout => $self->model_update_timeout,
10             ua_retry_times => 3,
11             };
12 0           my %r = (
13             hash => $self->hash($self->ptwebqq,$self->uid),
14             vfwebqq => $self->vfwebqq,
15             );
16 0 0         my $is_blocking = ref $callback eq "CODE"?0:1;
17             my $handle = sub{
18 0     0     my $json = shift;
19 0 0         return undef unless defined $json;
20 0 0         return undef unless exists $json->{result}{gnamelist};
21 0           my $group_list_info = $json->{result}{gnamelist};
22 0           my %gmarklist;
23 0           for(@{ $group_list_info }){
  0            
24 0           $gmarklist{$_->{gid}} = $_->{markname};
25             }
26 0           for(@{$group_list_info}){
  0            
27 0           $_->{markname} = $self->xmlescape_parse($gmarklist{$_->{gid}});
28 0           $_->{name} = $self->xmlescape_parse($_->{name});
29 0           $_->{id} = delete $_->{gid};
30 0           delete $_->{flag} ;
31             }
32 0           return $group_list_info;
33 0           };
34 0 0         if($is_blocking){
35 0           return $handle->($self->http_get($api_url,$headers,form=>{r=>$self->to_json(\%r)},) );
36             }
37             else{
38             $self->http_get($api_url,$headers,form=>{r=>$self->to_json(\%r)},sub{
39 0     0     my $json = shift;
40 0           $callback->( $handle->($json) );
41 0           });
42             }
43             }
44             1;