File Coverage

blib/lib/Flickr/API/Response.pm
Criterion Covered Total %
statement 41 59 69.4
branch 0 4 0.0
condition n/a
subroutine 11 15 73.3
pod 7 10 70.0
total 59 88 67.0


line stmt bran cond sub pod time code
1             package Flickr::API::Response;
2              
3 15     15   131 use strict;
  15         39  
  15         586  
4 15     15   116 use warnings;
  15         27  
  15         737  
5 15     15   84 use HTTP::Response;
  15         28  
  15         633  
6              
7 15     15   101 use parent qw(HTTP::Response);
  15         32  
  15         130  
8              
9             our $VERSION = '1.28';
10              
11             sub new {
12 0     0 1 0 my $class = shift;
13 0         0 my $self = HTTP::Response->new;
14 0         0 my $options = shift;
15 0         0 bless $self, $class;
16 0         0 return $self;
17             }
18              
19             sub init_flickr {
20 2     2 0 6 my ($self, $options) = @_;
21 2         10 $self->{tree} = undef;
22 2         5 $self->{hash} = undef;
23 2         5 $self->{success} = 0;
24 2         9 $self->{error_code} = 0;
25 2         6 $self->{error_message} = '';
26 2         4 return;
27             }
28              
29             sub set_fail {
30 2     2 0 6 my ($self, $code, $message) = @_;
31 2         6 $self->{success} = 0;
32 2         7 $self->{error_code} = $code;
33 2         6 $self->{error_message} = $message;
34 2         5 return;
35             }
36              
37             sub set_ok {
38 0     0 0 0 my ($self, $tree, $hashref) = @_;
39 0         0 $self->{success} = 1;
40 0         0 $self->{tree} = $tree;
41 0         0 $self->{hash} = $hashref;
42 0         0 return;
43             }
44              
45             #
46             # some accessors
47             #
48             sub as_tree {
49 0     0 1 0 my ($self) = @_;
50              
51 0 0       0 if (defined $self->{tree}) {
52              
53 0         0 return $self->{tree};
54             }
55             else {
56 0         0 return;
57             }
58             }
59              
60              
61             sub as_hash {
62 0     0 1 0 my ($self) = @_;
63              
64 0 0       0 if (defined $self->{hash}) {
65              
66 0         0 return $self->{hash};
67             }
68             else {
69 0         0 return;
70             }
71             }
72              
73             sub error_code {
74              
75 3     3 1 17 my ($self) = @_;
76 3         33 return $self->{error_code};
77              
78             }
79              
80             sub error_message {
81              
82 1     1 1 7 my ($self) = @_;
83 1         3 my $text = $self->{error_message};
84 1         10 $text =~ s/\"/\"/g;
85 1         4 return $text;
86              
87             }
88              
89             sub success {
90              
91 1     1 1 4 my ($self) = @_;
92 1         6 return $self->{success};
93              
94             }
95              
96             sub rc {
97              
98 3     3 1 745 my ($self) = @_;
99 3         13 return $self->{_rc};
100              
101             }
102              
103             sub _propagate_status {
104              
105 1     1   3 my $self = shift;
106 1         3 my $stat = shift;
107              
108 1         4 $stat->{_rc} = $self->{_rc}; # http response _rc
109 1         4 $stat->{success} = $self->{success}; # set by Flickr::API::Response
110 1         3 $stat->{error_code} = $self->{error_code}; # Returned by Flickr or set in API
111 1         5 $stat->{error_message} = $self->error_message(); # use method since it fixes text
112              
113 1         3 return;
114              
115             }
116              
117             1;
118              
119             __END__