/usr/share/perl5/Flickr/API/Response.pm is in libflickr-api-perl 1.28-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | package Flickr::API::Response;
use strict;
use warnings;
use HTTP::Response;
use parent qw(HTTP::Response);
our $VERSION = '1.28';
sub new {
my $class = shift;
my $self = HTTP::Response->new;
my $options = shift;
bless $self, $class;
return $self;
}
sub init_flickr {
my ($self, $options) = @_;
$self->{tree} = undef;
$self->{hash} = undef;
$self->{success} = 0;
$self->{error_code} = 0;
$self->{error_message} = '';
return;
}
sub set_fail {
my ($self, $code, $message) = @_;
$self->{success} = 0;
$self->{error_code} = $code;
$self->{error_message} = $message;
return;
}
sub set_ok {
my ($self, $tree, $hashref) = @_;
$self->{success} = 1;
$self->{tree} = $tree;
$self->{hash} = $hashref;
return;
}
#
# some accessors
#
sub as_tree {
my ($self) = @_;
if (defined $self->{tree}) {
return $self->{tree};
}
else {
return;
}
}
sub as_hash {
my ($self) = @_;
if (defined $self->{hash}) {
return $self->{hash};
}
else {
return;
}
}
sub error_code {
my ($self) = @_;
return $self->{error_code};
}
sub error_message {
my ($self) = @_;
my $text = $self->{error_message};
$text =~ s/\"/\"/g;
return $text;
}
sub success {
my ($self) = @_;
return $self->{success};
}
sub rc {
my ($self) = @_;
return $self->{_rc};
}
sub _propagate_status {
my $self = shift;
my $stat = shift;
$stat->{_rc} = $self->{_rc}; # http response _rc
$stat->{success} = $self->{success}; # set by Flickr::API::Response
$stat->{error_code} = $self->{error_code}; # Returned by Flickr or set in API
$stat->{error_message} = $self->error_message(); # use method since it fixes text
return;
}
1;
__END__
=head1 NAME
Flickr::API::Response - A response from the flickr API.
=head1 SYNOPSIS
use Flickr::API;
use Flickr::API::Response;
my $api = Flickr::API->new({'key' => 'your_api_key'});
my $response = $api->execute_method('flickr.test.echo', {
'foo' => 'bar',
'baz' => 'quux',
});
print "Success: $response->{success}\n";
=head1 DESCRIPTION
This object encapsulates a response from the Flickr API. It's
a subclass of L<HTTP::Response> with the following additional
keys:
{
'success' => 1,
'tree' => XML::Parser::Lite::Tree,
'hash' => Flickr response as a hash,
'error_code' => 0,
'error_message' => '',
}
The C<_request> key contains the request object that this response
was generated from. This request will be a L<Flickr::API::Request>
object, which is a subclass of L<HTTP:Request>.
The C<sucess> key contains 1 or 0, indicating
whether the request succeeded. If it failed, C<error_code> and
C<error_message> explain what went wrong. If it succeeded, C<tree>
contains an L<XML::Parser::Lite::Tree> object of the response XML.
=head1 METHODS
=over
=item C<as_tree()>
Returns the args passed to flickr with the method that produced this response
=item C<as_hash()>
Returns the args passed to flickr with the method that produced this response
=item C<error_code()>
Returns the Flickr Error Code, if any
=item C<error_message()>
Returns the Flickr Error Message, if any
=item C<success()>
Returns the success or lack thereof from Flickr
=item C<rc()>
Returns the Flickr http status code
=item C<_propagate_status(\%hash)>
Returns the entire response status block as a hashref.
=back
=head1 AUTHOR
Copyright (C) 2004, Cal Henderson, E<lt>cal@iamcal.comE<gt>
Copyright (C) 2015-2016, Louis B. Moore, E<lt>lbmoore@cpan.orgE<gt>
OAuth and accessor methods.
=head1 SEE ALSO
L<Flickr::API>,
L<XML::Parser::Lite>
=cut
|