| line | stmt | bran | cond | sub | pod | time | code | 
| 1 | 7 |  |  | 7 |  | 37 | use strict; | 
|  | 7 |  |  |  |  | 13 |  | 
|  | 7 |  |  |  |  | 184 |  | 
| 2 | 7 |  |  | 7 |  | 32 | use warnings; | 
|  | 7 |  |  |  |  | 15 |  | 
|  | 7 |  |  |  |  | 197 |  | 
| 3 | 7 |  |  | 7 |  | 32 | use MRO::Compat 'c3'; | 
|  | 7 |  |  |  |  | 13 |  | 
|  | 7 |  |  |  |  | 213 |  | 
| 4 |  |  |  |  |  |  |  | 
| 5 |  |  |  |  |  |  | package WebService::Shippo::Collection; | 
| 6 | 7 |  |  | 7 |  | 37 | use Params::Callbacks ( 'callbacks' ); | 
|  | 7 |  |  |  |  | 11 |  | 
|  | 7 |  |  |  |  | 359 |  | 
| 7 | 7 |  |  | 7 |  | 35 | use base              ( 'WebService::Shippo::Object' ); | 
|  | 7 |  |  |  |  | 13 |  | 
|  | 7 |  |  |  |  | 4997 |  | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | sub item_count | 
| 10 |  |  |  |  |  |  | { | 
| 11 | 0 |  |  | 0 | 0 |  | my ( $invocant ) = @_; | 
| 12 | 0 |  |  |  |  |  | return $invocant->{count}; | 
| 13 |  |  |  |  |  |  | } | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | sub page_size | 
| 16 |  |  |  |  |  |  | { | 
| 17 | 0 |  |  | 0 | 0 |  | my ( $invocant ) = @_; | 
| 18 | 0 |  |  |  |  |  | return scalar( @{ $invocant->{results} } ); | 
|  | 0 |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | } | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | sub next_page | 
| 22 |  |  |  |  |  |  | { | 
| 23 | 0 |  |  | 0 | 0 |  | my ( $callbacks, $invocant ) = &callbacks; | 
| 24 | 0 | 0 |  |  |  |  | return unless defined $invocant->{next}; | 
| 25 | 0 |  |  |  |  |  | my $response = WebService::Shippo::Request->get( $invocant->{next} ); | 
| 26 | 0 |  |  |  |  |  | return $invocant->item_class->construct_from( $response, $callbacks ); | 
| 27 |  |  |  |  |  |  | } | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | sub plus_next_pages | 
| 30 |  |  |  |  |  |  | { | 
| 31 | 0 |  |  | 0 | 0 |  | my ( $callbacks, $invocant ) = &callbacks; | 
| 32 | 0 | 0 |  |  |  |  | return $invocant unless defined $invocant->{next}; | 
| 33 | 0 |  |  |  |  |  | my $current = $invocant; | 
| 34 | 0 |  |  |  |  |  | while ( defined( $current->{next} ) ) { | 
| 35 | 0 |  |  |  |  |  | my $r = WebService::Shippo::Request->get( $current->{next} ); | 
| 36 | 0 |  |  |  |  |  | $current = $invocant->item_class->construct_from( $r, $callbacks ); | 
| 37 | 0 |  |  |  |  |  | push @{ $invocant->{results} }, @{ $current->{results} }; | 
|  | 0 |  |  |  |  |  |  | 
|  | 0 |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  | } | 
| 39 | 0 |  |  |  |  |  | undef $invocant->{next}; | 
| 40 | 0 |  |  |  |  |  | return $invocant; | 
| 41 |  |  |  |  |  |  | } | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | sub previous_page | 
| 44 |  |  |  |  |  |  | { | 
| 45 | 0 |  |  | 0 | 0 |  | my ( $callbacks, $invocant ) = &callbacks; | 
| 46 | 0 | 0 |  |  |  |  | return unless defined $invocant->{previous}; | 
| 47 | 0 |  |  |  |  |  | my $response = WebService::Shippo::Request->get( $invocant->{previous} ); | 
| 48 | 0 |  |  |  |  |  | return $invocant->item_class->construct_from( $response, $callbacks ); | 
| 49 |  |  |  |  |  |  | } | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | sub plus_previous_pages | 
| 52 |  |  |  |  |  |  | { | 
| 53 | 0 |  |  | 0 | 0 |  | my ( $callbacks, $invocant ) = &callbacks; | 
| 54 | 0 | 0 |  |  |  |  | return $invocant unless defined $invocant->{previous}; | 
| 55 | 0 |  |  |  |  |  | my $current = $invocant; | 
| 56 | 0 |  |  |  |  |  | while ( defined( $current->{previous} ) ) { | 
| 57 | 0 |  |  |  |  |  | my $r = WebService::Shippo::Request->get( $current->{previous} ); | 
| 58 | 0 |  |  |  |  |  | $current = $invocant->item_class->construct_from( $r, $callbacks ); | 
| 59 | 0 |  |  |  |  |  | unshift @{ $invocant->{results} }, @{ $current->{results} }; | 
|  | 0 |  |  |  |  |  |  | 
|  | 0 |  |  |  |  |  |  | 
| 60 |  |  |  |  |  |  | } | 
| 61 | 0 |  |  |  |  |  | undef $invocant->{previous}; | 
| 62 | 0 |  |  |  |  |  | return $invocant; | 
| 63 |  |  |  |  |  |  | } | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | sub items | 
| 66 |  |  |  |  |  |  | { | 
| 67 | 0 |  |  | 0 | 0 |  | my ( $callbacks, $invocant ) = &callbacks; | 
| 68 | 0 | 0 |  |  |  |  | return $callbacks->transform( @{ $invocant->{results} } ) | 
|  | 0 |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | if wantarray; | 
| 70 | 0 |  |  |  |  |  | return [ $callbacks->transform( @{ $invocant->{results} } ) ]; | 
|  | 0 |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  | } | 
| 72 |  |  |  |  |  |  |  | 
| 73 |  |  |  |  |  |  | sub item | 
| 74 |  |  |  |  |  |  | { | 
| 75 | 0 |  |  | 0 | 0 |  | my ( $callbacks, $invocant, $position ) = &callbacks; | 
| 76 |  |  |  |  |  |  | return | 
| 77 | 0 | 0 | 0 |  |  |  | unless $position > 0 && $position <= $invocant->{count}; | 
| 78 | 0 |  |  |  |  |  | return $callbacks->smart_transform( $invocant->{results}[ $position - 1 ] ); | 
| 79 |  |  |  |  |  |  | } | 
| 80 |  |  |  |  |  |  |  | 
| 81 |  |  |  |  |  |  | sub item_at_index | 
| 82 |  |  |  |  |  |  | { | 
| 83 | 0 |  |  | 0 | 0 |  | my ( $callbacks, $invocant, $index ) = &callbacks; | 
| 84 | 0 |  |  |  |  |  | return $callbacks->smart_transform( $invocant->{results}[$index] ); | 
| 85 |  |  |  |  |  |  | } | 
| 86 |  |  |  |  |  |  |  | 
| 87 |  |  |  |  |  |  | BEGIN { | 
| 88 | 7 |  |  | 7 |  | 177 | no warnings 'once'; | 
|  | 7 |  |  |  |  | 17 |  | 
|  | 7 |  |  |  |  | 295 |  | 
| 89 | 7 |  |  | 7 |  | 56 | *Shippo::Collection:: = *WebService::Shippo::Collection::; | 
| 90 | 7 |  |  |  |  | 152 | *to_array = *items; | 
| 91 |  |  |  |  |  |  | } | 
| 92 |  |  |  |  |  |  |  | 
| 93 |  |  |  |  |  |  | 1; |