line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
7
|
|
|
7
|
|
44
|
use strict; |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
187
|
|
2
|
7
|
|
|
7
|
|
38
|
use warnings; |
|
7
|
|
|
|
|
19
|
|
|
7
|
|
|
|
|
192
|
|
3
|
7
|
|
|
7
|
|
211
|
use MRO::Compat 'c3'; |
|
7
|
|
|
|
|
19
|
|
|
7
|
|
|
|
|
387
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package WebService::Shippo::Fetch; |
6
|
|
|
|
|
|
|
require WebService::Shippo::Request; |
7
|
7
|
|
|
7
|
|
38
|
use Params::Callbacks ( 'callbacks' ); |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
3502
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub fetch |
10
|
|
|
|
|
|
|
{ |
11
|
0
|
|
|
0
|
0
|
|
my ( $callbacks, $invocant, $id, @params ) = &callbacks; |
12
|
0
|
|
|
|
|
|
my $class = $invocant->item_class; |
13
|
0
|
|
|
|
|
|
my $response = Shippo::Request->get( $class->url( $id ), @params ); |
14
|
0
|
|
|
|
|
|
return $class->construct_from( $response, $callbacks ); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub all |
18
|
|
|
|
|
|
|
{ |
19
|
0
|
|
|
0
|
0
|
|
my ( $callbacks, $invocant, @params ) = &callbacks; |
20
|
0
|
0
|
|
|
|
|
@params = ( {} ) |
21
|
|
|
|
|
|
|
unless @params; |
22
|
0
|
0
|
|
|
|
|
my $params = ref( $params[0] ) ? $params[0] : {@params}; |
23
|
0
|
|
|
|
|
|
my $class = $invocant->item_class; |
24
|
0
|
|
|
|
|
|
my $response; |
25
|
|
|
|
|
|
|
$params->{results} = 200 |
26
|
0
|
0
|
|
|
|
|
unless $params->{results}; |
27
|
0
|
|
|
|
|
|
$response = WebService::Shippo::Request->get( $class->url, $params ); |
28
|
0
|
|
|
|
|
|
return $class->construct_from( $response, $callbacks ); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub iterate |
32
|
|
|
|
|
|
|
{ |
33
|
0
|
|
|
0
|
0
|
|
my ( $callbacks, $invocant, @params ) = &callbacks; |
34
|
0
|
0
|
|
|
|
|
@params = ( {} ) |
35
|
|
|
|
|
|
|
unless @params; |
36
|
0
|
0
|
|
|
|
|
my $params = ref( $params[0] ) ? $params[0] : {@params}; |
37
|
|
|
|
|
|
|
$params->{results} = 200 |
38
|
0
|
0
|
|
|
|
|
unless $params->{results}; |
39
|
0
|
|
|
|
|
|
my $collection = $invocant->all( $params ); |
40
|
0
|
|
|
|
|
|
my $index = 0; |
41
|
|
|
|
|
|
|
my $iterator = sub { |
42
|
0
|
|
|
0
|
|
|
my @results; |
43
|
0
|
|
0
|
|
|
|
while ( $collection && !@results ) { |
44
|
0
|
0
|
|
|
|
|
if ( $index == @{ $collection->results } ) { |
|
0
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
$collection = $collection->next_page; |
46
|
0
|
|
|
|
|
|
$index = 0; |
47
|
0
|
0
|
|
|
|
|
unless ( $collection ) { |
48
|
0
|
|
|
|
|
|
$collection = $invocant->all( $params ); |
49
|
0
|
|
|
|
|
|
last; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
0
|
|
|
|
|
|
@results = $callbacks->transform( $collection->{results}[ $index++ ] ); |
53
|
|
|
|
|
|
|
} |
54
|
0
|
0
|
|
|
|
|
return @results if wantarray; |
55
|
0
|
|
|
|
|
|
return \@results; |
56
|
0
|
|
|
|
|
|
}; |
57
|
0
|
|
|
|
|
|
return $iterator; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub collect |
61
|
|
|
|
|
|
|
{ |
62
|
0
|
|
|
0
|
0
|
|
my $iterator = &iterate; |
63
|
|
|
|
|
|
|
my $collector = sub { |
64
|
0
|
|
|
0
|
|
|
my @results; |
65
|
0
|
|
|
|
|
|
while ( my @list = $iterator->() ) { |
66
|
0
|
|
|
|
|
|
push @results, @list; |
67
|
|
|
|
|
|
|
} |
68
|
0
|
0
|
|
|
|
|
return @results if wantarray; |
69
|
0
|
|
|
|
|
|
return \@results; |
70
|
0
|
|
|
|
|
|
}; |
71
|
0
|
|
|
|
|
|
return $collector; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
BEGIN { |
75
|
7
|
|
|
7
|
|
42
|
no warnings 'once'; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
342
|
|
76
|
7
|
|
|
7
|
|
21
|
*retrieve = *fetch; |
77
|
7
|
|
|
|
|
136
|
*Shippo::Fetcher:: = *WebService::Shippo::Fetcher::; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |