Webqq/Model/Remote/_get_friend_info.pm untested

filter: Statementstmt 0.0% 0 / 26 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 2 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 37 CC 5 SCAR 32.3
CC
5
Cov
0%
Mojo::Webqq::Model::_get_friend_info
30.0
BEGIN
2.0
CRAP 25.3
1 use strict;
2 sub Mojo::Webqq::Model::_get_friend_info{
3 my $self = shift;
4 my $uin = shift;
5 my $callback = shift;
6 my $api_url = 'https://s.web2.qq.com/api/get_friend_info2';
7 my $headers = {
8 Referer=>'https://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1',
9 json=>1,
10 ua_request_timeout=> $self->model_update_timeout,
11 ua_retry_times => 3,
12 };
13 my @query_string = (
14 tuin => $uin,
15 vfwebqq => $self->vfwebqq,
16 clientid => $self->clientid,
17 psessionid => $self->psessionid,
18 t => time,
19 );
20  
21 my $is_blocking = ref $callback eq "CODE"?0:1;
22 my $handle = sub{
23 my $json = shift;
24 return undef unless defined $json;
25 return undef if $json->{retcode} !=0;
26 my $friend_info = $json->{result};
27 $friend_info->{birthday} = join("-",@{ $friend_info->{birthday}}{qw(year month day)} );
28 $friend_info{state} = $self->code2state(delete $friend_info->{'stat'});
29 $friend_info->{id} = delete $friend_info->{uin};
30 $friend_info->{name} = $friend_info->{nick};
31 return $friend_info;
32 };
33 if($is_blocking){
34 return $hande->( $self->http_get($self->gen_url($api_url,@query_string),$headers,) );
35 }
36 else{
37 $self->http_get($self->gen_url($api_url,@query_string),$headers,sub{
38 my $json = shift;
39 $callback->( $handle->($json) );
40 });
41 }
42 }
43 1;