lib/ImgurAPI/Client.pm

filter: Statementstmt 12.7% 63 / 495 Branchbran 0.7% 2 / 284 Conditioncond 4.3% 7 / 160 MC/DCmcdc 3.6% 3 / 83 Subroutinesub 24.3% 27 / 111 Podpod 18.5% 18 / 97 totaltotal 9.7% 120 / 1230 CC 226 SCAR 43.8
CC
226
Cov
8%
request
650.0
gallery_search
156.0
gallery
110.0
CRAP 79.6
↑ Summary
1  
2 package ImgurAPI::Client;
3  
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use HTTP::Request::Common;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use JSON qw(decode_json encode_json);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use List::Util qw(first);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use LWP::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Mozilla::CA;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Scalar::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use XML::LibXML;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 our $VERSION = '1.2.1';
17  
18 1 ▶use constant ENDPOINTS => {
Subroutine BEGIN: called CC=1 SCAR=0.0
19 'IMGUR' => 'https://api.imgur.com/3',
20 'RAPIDAPI' => 'https://imgur-apiv3.p.rapidapi.com',
21 'OAUTH_AUTHORIZE' => 'https://api.imgur.com/oauth2/authorize',
22 'OAUTH_TOKEN' => 'https://api.imgur.com/oauth2/token',
23 1 };
24  
25 5 ▶sub new {
Subroutine new: called CC=4 SCAR=13.9
Pod documented
26 5 my $self = shift;
27 5 ▶ my $args = shift // {};
Condition100%2/2
shift() // {}
l!l
14
MC/DC100%1/1
shift() // {}
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
28 my $vars = {
29 'auth' => 1,
30 'access_token' => $args->{'access_token'},
31 'oauth_cb_state' => $args->{'oauth_cb_state'},
32 'client_id' => $args->{'client_id'},
33 'client_secret' => $args->{'client_secret'},
34 'format_type' => $args->{'format_type'} || 'json',
35 'lwp' => LWP::UserAgent->new,
36 'rapidapi_key' => $args->{'rapidapi_key'},
37 'refresh_token' => $args->{'refresh_token'},
38 'response' => undef,
39 'ratelimit_hdrs' => {},
40 5 ▶ 'user_agent' => $args->{'user_agent'} || "ImgurAPI::Client/$VERSION",
Condition75%3/4
$args->{'format_type'} || 'json'
l!l
14
$args->{'user_agent'} || "ImgurAPI::Client/$ImgurAPI::Client::VERSION"
l!l
05
MC/DC100%1/1
$args->{'format_type'} || 'json'
$args->{'format_type'}
MC/DC0%0/1
$args->{'user_agent'} || "ImgurAPI::Client/$ImgurAPI::Client::VERSION"
$args->{'user_agent'}
Truth table100%2/2
A
A= $args->{'format_type'}
Aresult
11
00
Truth table50%1/2
A
A= $args->{'user_agent'}
Aresult
11
00
41 };
42  
43 5 return bless $vars, $self;
44 }
45  
46 1 ▶sub _lwp { shift->{'lwp'} }
Subroutine _lwp: called CC=1 SCAR=0.0
47  
48 0 ▶sub request {
Subroutine request: not called CC=25 SCAR=64.8
Pod undocumented
49 0 my ($self, $uri, $http_method, $data, $hdr, $debug) = @_;
50  
51 0 ▶ $http_method = uc($http_method // 'GET');
Condition0%0/2
$http_method // "GET"
l!l
00
MC/DC0%0/1
$http_method // "GET"
$http_method
Truth table0%0/2
A
A= $http_method
Aresult
11
00
52  
53 0 ▶ my $endpoint = $self->{'rapidapi_key'} ? ENDPOINTS->{'RAPIDAPI'} . $uri : ($uri =~ /^\// ? ENDPOINTS->{'IMGUR'} . $uri : $uri);
Branch: 2 branches
BranchTrueFalseTotal
$self->{'rapidapi_key'} ? : 0 0 0
$uri =~ m[^/] ? : 0 0 0
54  
55 0 ▶ $endpoint .= ($endpoint =~ /\?/ ? '&' : '?') . '_format=' . $self->{'format_type'} . "&_method=$http_method";
Branch: 1 branch
BranchTrueFalseTotal
$endpoint =~ /\?/ ? : 0 0 0
56  
57 0 $self->_lwp->default_header('User-Agent' => "ImgurAPI::Client/$VERSION");
58  
59 0 ▶ if ($self->{'auth'}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'auth'}) { } 0 0 0
elsif ($self->{'client_id'}) { } 0 0 0
60 0 ▶ my $access_token = $self->{'access_token'} // die "Missing required access_token";
Condition0%0/2
$self->{"access_token"} // die("Missing required access_token")
l!l
00
MC/DC0%0/1
$self->{"access_token"} // die("Missing required access_token")
$self->{"access_token"}
Truth table0%0/2
A
A= $self->{"access_token"}
Aresult
11
00
61 0 $self->_lwp->default_header('Authorization' => "Bearer $access_token");
62 } elsif ($self->{'client_id'}) {
63 0 $self->_lwp->default_header('Authorization' => "Client-ID " . $self->{'client_id'});
64 }
65  
66 0 ▶ if ($http_method =~ /^GET|DELETE$/ && $data && ref($data) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if ($http_method =~ /^GET|DELETE$/ and $data and ref $data eq "HASH") 0 0 0
Condition0%0/6
$http_method =~ /^GET|DELETE$/ and $data and ref $data eq "HASH"
!ll&&!rl&&r
000
$http_method =~ /^GET|DELETE$/ and $data
!ll&&!rl&&r
000
MC/DC0%0/3
$http_method =~ /^GET|DELETE$/ and $data and ref $data eq "HASH"
$http_method =~ /^GET|DELETE$/ $data ref $data eq "HASH"
Truth table0%0/4
A and B and C
A= $http_method =~ /^GET|DELETE$/B= $dataC= ref $data eq "HASH"
ABCresult
0XX0
10X0
1100
1111
67 0 $endpoint .= "&$_=$data->{$_}" foreach keys %$data;
68 }
69  
70 0 my $request;
71 0 ▶ if ($http_method eq 'POST') {
Branch: 2 branches
BranchTrueFalseTotal
if ($http_method eq 'POST') { } 0 0 0
elsif ($http_method eq 'PUT') { } 0 0 0
72 0 ▶ $request = HTTP::Request::Common::POST($endpoint, %{$hdr//{}}, Content => $data);
Condition0%0/2
$hdr // {}
l!l
00
MC/DC0%0/1
$hdr // {}
$hdr
Truth table0%0/2
A
A= $hdr
Aresult
11
00
73 } elsif ($http_method eq 'PUT') {
74 0 ▶ $request = HTTP::Request::Common::PUT($endpoint, %{$hdr//{}}, Content => $data);
Condition0%0/2
$hdr // {}
l!l
00
MC/DC0%0/1
$hdr // {}
$hdr
Truth table0%0/2
A
A= $hdr
Aresult
11
00
75 } else {
76 0 $request = HTTP::Request->new($http_method, $endpoint);
77 }
78  
79 0 ▶ print Dumper $request if $ENV{'DEBUG'} || ($debug // 0);
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"DEBUG"} or $debug // 0 0 0 0
Condition0%0/5
$ENV{"DEBUG"} or $debug // 0
l!l&&r!l&&!r
000
$debug // 0
l!l
00
MC/DC0%0/2
$ENV{"DEBUG"} or $debug // 0
$ENV{"DEBUG"} $debug
Truth table0%0/3
A or B
A= $ENV{"DEBUG"}B= $debug
ABresult
1X1
011
000
80  
81 0 my $response = $self->_lwp->request($request);
82  
83 0 my @ratelimit_headers = qw(userlimit userremaining userreset clientlimit clientremaining);
84 0 foreach my $header (@ratelimit_headers) {
85 0 my $val = $response->header("x-ratelimit-$header");
86 0 ▶ $self->{'ratelimit_headers'}->{$header} = $val && $val =~ /^\d+$/ ? int $val : $val;
Branch: 1 branch
BranchTrueFalseTotal
$val && $val =~ /^\d+$/ ? : 0 0 0
Condition0%0/3
$val and $val =~ /^\d+$/
!ll&&!rl&&r
000
MC/DC0%0/2
$val and $val =~ /^\d+$/
$val $val =~ /^\d+$/
Truth table0%0/3
A and B
A= $valB= $val =~ /^\d+$/
ABresult
0X0
100
111
87 }
88  
89 0 $self->{'response'} = $response;
90 0 $self->{'response_content'} = $response->decoded_content;
91  
92 0 ▶ print Dumper $response if $ENV{'DEBUG'};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"DEBUG"} 0 0 0
93  
94 0 ▶ if ($self->format_type eq 'xml') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->format_type eq 'xml') { } 0 0 0
95 0 return XML::LibXML->new->load_xml(string => $response->decoded_content);
96 } else {
97 0 my $decoded = eval { decode_json $response->decoded_content };
98 0 ▶ if (my $err = $@) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $err = $@) 0 0 0
99 0 die "An error occurred while trying to json decode imgur response: $err\n" . $response->decoded_content;
100 }
101 0 return $decoded;
102 }
103 }
104  
105 0 ▶sub refresh_access_token {
Subroutine refresh_access_token: not called CC=8 SCAR=42.8
Pod undocumented
106 0 my $self = shift;
107 0 ▶ my $opts = shift // {};
Condition0%0/2
shift() // {}
l!l
00
MC/DC0%0/1
shift() // {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
108  
109 0 ▶ my $refresh_token = $opts->{'refresh_token'} || $self->{'refresh_token'} or die "missing required refresh_token";
Branch: 1 branch
BranchTrueFalseTotal
my $refresh_token = $opts->{"refresh_token"} || $self->{"refresh_token"} or die "missing required refresh_token" 0 0 0
Condition0%0/3
$opts->{'refresh_token'} || $self->{'refresh_token'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts->{'refresh_token'} || $self->{'refresh_token'}
$opts->{'refresh_token'} $self->{'refresh_token'}
Truth table0%0/3
A || B
A= $opts->{'refresh_token'}B= $self->{'refresh_token'}
ABresult
1X1
011
000
110 0 ▶ my $client_id = $opts->{'client_id'} || $self->{'client_id'} or die "missing required client_id";
Branch: 1 branch
BranchTrueFalseTotal
my $client_id = $opts->{"client_id"} || $self->{"client_id"} or die "missing required client_id" 0 0 0
Condition0%0/3
$opts->{'client_id'} || $self->{'client_id'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts->{'client_id'} || $self->{'client_id'}
$opts->{'client_id'} $self->{'client_id'}
Truth table0%0/3
A || B
A= $opts->{'client_id'}B= $self->{'client_id'}
ABresult
1X1
011
000
111 0 ▶ my $client_secret = $opts->{'client_secret'} || $self->{'client_secret'} or die "missing required client_secret";
Branch: 1 branch
BranchTrueFalseTotal
my $client_secret = $opts->{"client_secret"} || $self->{"client_secret"} or die "missing required client_secret" 0 0 0
Condition0%0/3
$opts->{'client_secret'} || $self->{'client_secret'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts->{'client_secret'} || $self->{'client_secret'}
$opts->{'client_secret'} $self->{'client_secret'}
Truth table0%0/3
A || B
A= $opts->{'client_secret'}B= $self->{'client_secret'}
ABresult
1X1
011
000
112  
113 0 my $resp = $self->request(ENDPOINTS->{'OAUTH_TOKEN'}, 'POST', {
114 'refresh_token' => $refresh_token,
115 'client_id' => $client_id,
116 'client_secret' => $client_secret,
117 'grant_type' => 'refresh_token',
118 });
119  
120 0 $self->{'access_token'} = $resp->{'access_token'};
121 0 $self->{'refresh_token'} = $resp->{'refresh_token'};
122  
123 return {
124 access_token => $resp->{'access_token'},
125 0 refresh_token => $resp->{'refresh_token'}
126 }
127 }
128  
129 # Setters
130 1 ▶sub set_access_token {
Subroutine set_access_token: called CC=1 SCAR=0.0
Pod documented
131 1 my ($self, $access_token) = @_;
132 1 $self->{'access_token'} = $access_token;
133 }
134  
135 2 ▶sub set_client_id {
Subroutine set_client_id: called CC=1 SCAR=0.0
Pod documented
136 2 my ($self, $client_id) = @_;
137 2 $self->{'client_id'} = $client_id;
138 }
139  
140 1 ▶sub set_client_secret {
Subroutine set_client_secret: called CC=1 SCAR=0.0
Pod documented
141 1 my ($self, $client_secret) = @_;
142 1 $self->{'client_secret'} = $client_secret;
143 }
144  
145 1 ▶sub set_format_type {
Subroutine set_format_type: called CC=1 SCAR=0.0
Pod documented
146 1 my ($self, $format_type) = @_;
147 1 $self->{'format_type'} = $format_type;
148 }
149  
150 2 ▶sub set_oauth_cb_state {
Subroutine set_oauth_cb_state: called CC=1 SCAR=0.0
Pod documented
151 2 my ($self, $oauth_cb_state) = @_;
152 2 $self->{'oauth_cb_state'} = $oauth_cb_state;
153 }
154  
155 1 ▶sub set_rapidapi_key {
Subroutine set_rapidapi_key: called CC=1 SCAR=0.0
Pod documented
156 1 my ($self, $rapidapi_key) = @_;
157 1 $self->{'rapidapi_key'} = $rapidapi_key;
158 }
159  
160 0 ▶sub set_refresh_token {
Subroutine set_refresh_token: not called CC=1 SCAR=6.9
Pod undocumented
161 0 my ($self, $refresh_token) = @_;
162 0 $self->{'refresh_token'} = $refresh_token;
163 }
164  
165 0 ▶sub set_user_agent {
Subroutine set_user_agent: not called CC=1 SCAR=6.9
Pod documented
166 0 my ($self, $user_agent) = @_;
167 0 $self->{'user_agent'} = $user_agent;
168 }
169  
170 # Getters
171 5 ▶sub oauth2_authorize_url {
Subroutine oauth2_authorize_url: called CC=3 SCAR=11.0
Pod undocumented
172 5 my $self = shift;
173 5 ▶ my $client_id = $self->{'client_id'} or die "missing required client_id";
Branch: 1 branch
BranchTrueFalseTotal
my $client_id = $self->{"client_id"} or die "missing required client_id" 4 1 5
174 4 ▶ my $state = $self->{'oauth_cb_state'} // '';
Condition100%2/2
$self->{"oauth_cb_state"} // ""
l!l
22
MC/DC100%1/1
$self->{"oauth_cb_state"} // ""
$self->{"oauth_cb_state"}
Truth table100%2/2
A
A= $self->{"oauth_cb_state"}
Aresult
11
00
175 4 return (ENDPOINTS->{'OAUTH_AUTHORIZE'} . "?client_id=$client_id&response_type=token&state=$state");
176 }
177  
178 3 ▶sub access_token {
Subroutine access_token: called CC=1 SCAR=0.0
Pod documented
179 3 return shift->{'access_token'}
180 }
181  
182 3 ▶sub client_id {
Subroutine client_id: called CC=1 SCAR=0.0
Pod documented
183 3 return shift->{'client_id'};
184 }
185  
186 3 ▶sub client_secret {
Subroutine client_secret: called CC=1 SCAR=0.0
Pod documented
187 3 return shift->{'client_secret'}
188 }
189  
190 3 ▶sub format_type {
Subroutine format_type: called CC=1 SCAR=0.0
Pod documented
191 3 return shift->{'format_type'}
192 }
193  
194 3 ▶sub oauth_cb_state {
Subroutine oauth_cb_state: called CC=1 SCAR=0.0
Pod documented
195 3 return shift->{'oauth_cb_state'}
196 }
197  
198 3 ▶sub rapidapi_key {
Subroutine rapidapi_key: called CC=1 SCAR=0.0
Pod documented
199 3 return shift->{'rapidapi_key'}
200 }
201  
202 1 ▶sub response {
Subroutine response: called CC=1 SCAR=0.0
Pod documented
203 1 return shift->{'response'}
204 }
205  
206 0 ▶sub response_content {
Subroutine response_content: not called CC=1 SCAR=6.9
Pod documented
207 0 return shift->{'response_content'}
208 }
209  
210 0 ▶sub ratelimit_headers {
Subroutine ratelimit_headers: not called CC=1 SCAR=6.9
Pod documented
211 0 return shift->{'ratelimit_headers'}
212 }
213  
214 0 ▶sub user_agent {
Subroutine user_agent: not called CC=1 SCAR=6.9
Pod documented
215 0 return shift->{'user_agent'}
216 }
217  
218 # Account
219 0 ▶sub account {
Subroutine account: not called CC=2 SCAR=17.9
Pod undocumented
220 0 my $self = shift;
221 0 ▶ my $user = shift or die "missing required username";
Branch: 1 branch
BranchTrueFalseTotal
my $user = shift() or die "missing required username" 0 0 0
222 0 return $self->request("/account/$user");
223 }
224  
225 0 ▶sub account_album {
Subroutine account_album: not called CC=3 SCAR=24.8
Pod undocumented
226 0 my $self = shift;
227 0 ▶ my $user = shift or die "missing required username";
Branch: 1 branch
BranchTrueFalseTotal
my $user = shift() or die "missing required username" 0 0 0
228 0 ▶ my $id = shift or die "missing required album id";
Branch: 1 branch
BranchTrueFalseTotal
my $id = shift() or die "missing required album id" 0 0 0
229 0 return $self->request("/account/$user/album/$id");
230 }
231  
232 0 ▶sub account_album_count {
Subroutine account_album_count: not called CC=2 SCAR=17.9
Pod undocumented
233 0 my $self = shift;
234 0 ▶ my $user = shift or die "missing required username";
Branch: 1 branch
BranchTrueFalseTotal
my $user = shift() or die "missing required username" 0 0 0
235 0 return $self->request("/account/$user/albums/count");
236 }
237  
238 0 ▶sub account_album_delete {
Subroutine account_album_delete: not called CC=3 SCAR=24.8
Pod undocumented
239 0 my $self = shift;
240 0 ▶ my $user = shift or die "missing required username";
Branch: 1 branch
BranchTrueFalseTotal
my $user = shift() or die "missing required username" 0 0 0
241 0 ▶ my $id = shift or die "missing required album id";
Branch: 1 branch
BranchTrueFalseTotal
my $id = shift() or die "missing required album id" 0 0 0
242 0 return $self->request("/account/$user/album/$id", 'DELETE');
243 }
244  
245 0 ▶sub account_album_ids {
Subroutine account_album_ids: not called CC=4 SCAR=30.0
Pod undocumented
246 0 my $self = shift;
247 0 ▶ my $user = shift or die "missing requied username";
Branch: 1 branch
BranchTrueFalseTotal
my $user = shift() or die "missing requied username" 0 0 0
248 0 ▶ my $opts = shift // {};
Condition0%0/2
shift() // {}
l!l
00
MC/DC0%0/1
shift() // {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
249 0 ▶ my $page = $opts->{'page'} // 0;
Condition0%0/2
$opts->{"page"} // 0
l!l
00
MC/DC0%0/1
$opts->{"page"} // 0
$opts->{"page"}
Truth table0%0/2
A
A= $opts->{"page"}
Aresult
11
00
250 0 return $self->request("/account/$user/albums/ids/$page");
251 }
252  
253 0 ▶sub account_albums {
Subroutine account_albums: not called CC=4 SCAR=30.0
Pod undocumented
254 0 my $self = shift;
255 0 ▶ my $user = shift or die "missing requied username";
Branch: 1 branch
BranchTrueFalseTotal
my $user = shift() or die "missing requied username" 0 0 0
256 0 ▶ my $opts = shift // {};
Condition0%0/2
shift() // {}
l!l
00
MC/DC0%0/1
shift() // {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
257 0 ▶ my $page = $opts->{'page'} // 0;
Condition0%0/2
$opts->{"page"} // 0
l!l
00
MC/DC0%0/1
$opts->{"page"} // 0
$opts->{"page"}
Truth table0%0/2
A
A= $opts->{"page"}
Aresult
11
00
258 0 return $self->request("/account/$user/albums/$page");
259 }
260  
261 0 ▶sub account_block_status {
Subroutine account_block_status: not called CC=2 SCAR=17.9
Pod undocumented
262 0 my $self = shift;
263 0 ▶ my $user = shift or die "missing required username";
Branch: 1 branch
BranchTrueFalseTotal
my $user = shift() or die "missing required username" 0 0 0
264 0 return $self->request("https://api.imgur.com/account/v1/$user/block");
265 }
266  
267 0 ▶sub account_block_create {
Subroutine account_block_create: not called CC=5 SCAR=34.0
Pod undocumented
268 0 my $self = shift;
269 0 ▶ my $user = shift or die "missing required username";
Branch: 1 branch
BranchTrueFalseTotal
my $user = shift() or die "missing required username" 0 0 0
270 0 my $resp = eval { $self->request("https://api.imgur.com/account/v1/$user/block", 'POST') };
271  
272 0 ▶ if (my $err = $@) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $err = $@) 0 0 0
273 # we have to check if the response was successful when it throws because the imgur api
274 # states it will return the same object we return just below upon blocking a user.. but they dont.
275 # so we end up trying to json decode an empty response which throws an error. if they just returned
276 # the object they said they would in their api doc, we wouldnt get a json decode error.
277 # 201 and 'Created' msg indicates success.
278 0 ▶ if ($self->{'response'}->code != 201 ||
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"response"}->code != 201 or $self->{"response"}{"_msg"} ne "Created") 0 0 0
Condition0%0/3
$self->{"response"}->code != 201 or $self->{"response"}{"_msg"} ne "Created"
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"response"}->code != 201 or $self->{"response"}{"_msg"} ne "Created"
$self->{"response"}->code != 201 $self->{"response"}{"_msg"} ne "Created"
Truth table0%0/3
A or B
A= $self->{"response"}->code != 201B= $self->{"response"}{"_msg"} ne "Created"
ABresult
1X1
011
000
279 $self->{'response'}->{'_msg'} ne 'Created') {
280 0 die $err;
281 }
282 $resp = {
283 0 'success' => 1,
284 'status' => 201,
285 'data' => {
286 'blocked' => 1,
287 }
288 };
289 }
290 0 return $resp;
291 }
292  
293 0 ▶sub account_block_delete {
Subroutine account_block_delete: not called CC=4 SCAR=30.0
Pod undocumented
294 0 my $self = shift;
295 0 ▶ my $user = shift or die "missing required username";
Branch: 1 branch
BranchTrueFalseTotal
my $user = shift() or die "missing required username" 0 0 0
296 0 my $resp = eval { $self->request("https://api.imgur.com/account/v1/$user/block", 'DELETE') };
297  
298 0 ▶ if (my $err = $@) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $err = $@) 0 0 0
299 # we have to check if the response was successful when it throws because the imgur api
300 # states it will return the same object we return just below upon unblocking a user.. but they dont.
301 # so we end up trying to json decode an empty response which throws an error. if they just returned
302 # the object they said they would in their api doc, we wouldnt get a json decode error.
303 # 204 rc indicates success.
304 0 ▶ if ($self->{'response'}->code == 204) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"response"}->code == 204) 0 0 0
305 return {
306 0 'success' => 1,
307 'status' => 204,
308 'data' => {
309 'blocked' => 0,
310 }
311 }
312 }
313 0 die $err;
314 }
315  
316 0 return $resp;
317 }
318  
319 0 ▶sub account_blocks {
Subroutine account_blocks: not called CC=1 SCAR=6.9
Pod undocumented
320 0 my $self = shift;
321 0 return $self->request("/account/me/block");
322 }
323  
324 0 ▶sub account_comment {
Subroutine account_comment: not called CC=3 SCAR=24.8
Pod undocumented
325 0 my $self = shift;
326 0 ▶ my $user = shift or die "missing required username";
Branch: 1 branch
BranchTrueFalseTotal
my $user = shift() or die "missing required username" 0 0 0
327 0 ▶ my $id = shift or die "missing required comment id";
Branch: 1 branch
BranchTrueFalseTotal
my $id = shift() or die "missing required comment id" 0 0 0
328 0 return $self->request("/account/$user/comment/$id");
329 }
330  
331 0 ▶sub account_comment_count {
Subroutine account_comment_count: not called CC=2 SCAR=17.9
Pod undocumented
332 0 my $self = shift;
333 0 ▶ my $user = shift or die "missing required username";
Branch: 1 branch
BranchTrueFalseTotal
my $user = shift() or die "missing required username" 0 0 0
334 0 return $self->request("/account/$user/comments/count");
335 }
336  
337 0 ▶sub account_comment_delete {
Subroutine account_comment_delete: not called CC=3 SCAR=24.8
Pod undocumented
338 0 my $self = shift;
339 0 ▶ my $user = shift or die "missing required username";
Branch: 1 branch
BranchTrueFalseTotal
my $user = shift() or die "missing required username" 0 0 0
340 0 ▶ my $id = shift or die "missing required comment id";
Branch: 1 branch
BranchTrueFalseTotal
my $id = shift() or die "missing required comment id" 0 0 0
341 0 return $self->request("/account/$user/comment/$id", 'DELETE');
342 }
343  
344 0 ▶sub account_comment_ids {
Subroutine account_comment_ids: not called CC=5 SCAR=34.0
Pod undocumented
345 0 my $self = shift;
346 0 ▶ my $user = shift or die "missing required username";
Branch: 1 branch
BranchTrueFalseTotal
my $user = shift() or die "missing required username" 0 0 0
347 0 ▶ my $opts = shift // {};
Condition0%0/2
shift() // {}
l!l
00
MC/DC0%0/1
shift() // {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
348 0 ▶ my $sort = $opts->{'sort'} // 'newest';
Condition0%0/2
$opts->{"sort"} // "newest"
l!l
00
MC/DC0%0/1
$opts->{"sort"} // "newest"
$opts->{"sort"}
Truth table0%0/2
A
A= $opts->{"sort"}
Aresult
11
00
349 0 ▶ my $page = $opts->{'page'} // 0;
Condition0%0/2
$opts->{"page"} // 0
l!l
00
MC/DC0%0/1
$opts->{"page"} // 0
$opts->{"page"}
Truth table0%0/2
A
A= $opts->{"page"}
Aresult
11
00
350 0 return $self->request("/account/$user/comments/ids/$sort/$page");
351 }
352  
353 0 ▶sub account_comments {
Subroutine account_comments: not called CC=5 SCAR=34.0
Pod undocumented
354 0 my $self = shift;
355 0 ▶ my $user = shift or die "missing required username";
Branch: 1 branch
BranchTrueFalseTotal
my $user = shift() or die "missing required username" 0 0 0
356 0 ▶ my $opts = shift // {};
Condition0%0/2
shift() // {}
l!l
00
MC/DC0%0/1
shift() // {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
357 0 ▶ my $sort = $opts->{'sort'} // 'newest';
Condition0%0/2
$opts->{"sort"} // "newest"
l!l
00
MC/DC0%0/1
$opts->{"sort"} // "newest"
$opts->{"sort"}
Truth table0%0/2
A
A= $opts->{"sort"}
Aresult
11
00
358 0 ▶ my $page = $opts->{'page'} // 0;
Condition0%0/2
$opts->{"page"} // 0
l!l
00
MC/DC0%0/1
$opts->{"page"} // 0
$opts->{"page"}
Truth table0%0/2
A
A= $opts->{"page"}
Aresult
11
00
359 0 return $self->request("/account/$user/comments/$sort/$page");
360 }
361  
362 0 ▶sub account_delete {
Subroutine account_delete: not called CC=3 SCAR=24.8
Pod undocumented
363 0 my $self = shift;
364 0 ▶ my $client_id = shift or die "missing required client id";
Branch: 1 branch
BranchTrueFalseTotal
my $client_id = shift() or die "missing required client id" 0 0 0
365 0 ▶ my $body = shift or die "missing required post body";
Branch: 1 branch
BranchTrueFalseTotal
my $body = shift() or die "missing required post body" 0 0 0
366 0 return $self->request("/account/me/delete?client_id=$client_id", 'POST', $body);
367 }
368  
369 0 ▶sub account_favorites {
Subroutine account_favorites: not called CC=5 SCAR=34.0
Pod undocumented
370 0 my $self = shift;
371 0 ▶ my $user = shift or die "missing required username";
Branch: 1 branch
BranchTrueFalseTotal
my $user = shift() or die "missing required username" 0 0 0
372 0 ▶ my $opts = shift // {};
Condition0%0/2
shift() // {}
l!l
00
MC/DC0%0/1
shift() // {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
373 0 ▶ my $sort = $opts->{'sort'} // 'newest';
Condition0%0/2
$opts->{"sort"} // "newest"
l!l
00
MC/DC0%0/1
$opts->{"sort"} // "newest"
$opts->{"sort"}
Truth table0%0/2
A
A= $opts->{"sort"}
Aresult
11
00
374 0 ▶ my $page = $opts->{'page'} // 0;
Condition0%0/2
$opts->{"page"} // 0
l!l
00
MC/DC0%0/1
$opts->{"page"} // 0
$opts->{"page"}
Truth table0%0/2
A
A= $opts->{"page"}
Aresult
11
00
375 0 return $self->request("/account/$user/favorites/$page/$sort");
376 }
377  
378 0 ▶sub account_gallery_favorites {
Subroutine account_gallery_favorites: not called CC=5 SCAR=34.0
Pod undocumented
379 0 my $self = shift;
380 0 ▶ my $user = shift or die "missing required username";
Branch: 1 branch
BranchTrueFalseTotal
my $user = shift() or die "missing required username" 0 0 0
381 0 ▶ my $opts = shift // {};
Condition0%0/2
shift() // {}
l!l
00
MC/DC0%0/1
shift() // {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
382 0 ▶ my $sort = $opts->{'sort'} // 'newest';
Condition0%0/2
$opts->{"sort"} // "newest"
l!l
00
MC/DC0%0/1
$opts->{"sort"} // "newest"
$opts->{"sort"}
Truth table0%0/2
A
A= $opts->{"sort"}
Aresult
11
00
383 0 ▶ my $page = $opts->{'page'} // 0;
Condition0%0/2
$opts->{"page"} // 0
l!l
00
MC/DC0%0/1
$opts->{"page"} // 0
$opts->{"page"}
Truth table0%0/2
A
A= $opts->{"page"}
Aresult
11
00
384 0 return $self->request("/account/$user/gallery_favorites/$page/$sort");
385 }
386  
387 0 ▶sub account_image {
Subroutine account_image: not called CC=3 SCAR=24.8
Pod undocumented
388 0 my $self = shift;
389 0 ▶ my $user = shift or die "missing required username";
Branch: 1 branch
BranchTrueFalseTotal
my $user = shift() or die "missing required username" 0 0 0
390 0 ▶ my $id = shift or die "missing required image id";
Branch: 1 branch
BranchTrueFalseTotal
my $id = shift() or die "missing required image id" 0 0 0
391 0 return $self->request("/account/$user/image/$id");
392 }
393  
394 0 ▶sub account_image_count {
Subroutine account_image_count: not called CC=2 SCAR=17.9
Pod undocumented
395 0 my $self = shift;
396 0 ▶ my $user = shift or die "missing required username";
Branch: 1 branch
BranchTrueFalseTotal
my $user = shift() or die "missing required username" 0 0 0
397 0 return $self->request("/account/$user/images/count");
398 }
399  
400 0 ▶sub account_image_delete {
Subroutine account_image_delete: not called CC=3 SCAR=24.8
Pod undocumented
401 0 my $self = shift;
402 0 ▶ my $user = shift or die "missing required username";
Branch: 1 branch
BranchTrueFalseTotal
my $user = shift() or die "missing required username" 0 0 0
403 0 ▶ my $id = shift or die "missing required image id";
Branch: 1 branch
BranchTrueFalseTotal
my $id = shift() or die "missing required image id" 0 0 0
404 0 return $self->request("/account/$user/image/$id", 'DELETE');
405 }
406  
407 0 ▶sub account_image_ids {
Subroutine account_image_ids: not called CC=4 SCAR=30.0
Pod undocumented
408 0 my $self = shift;
409 0 ▶ my $user = shift or die "missing required username";
Branch: 1 branch
BranchTrueFalseTotal
my $user = shift() or die "missing required username" 0 0 0
410 0 ▶ my $opts = shift // {};
Condition0%0/2
shift() // {}
l!l
00
MC/DC0%0/1
shift() // {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
411 0 ▶ my $page = $opts->{'page'} // 0;
Condition0%0/2
$opts->{"page"} // 0
l!l
00
MC/DC0%0/1
$opts->{"page"} // 0
$opts->{"page"}
Truth table0%0/2
A
A= $opts->{"page"}
Aresult
11
00
412 0 return $self->request("/account/$user/images/ids/$page");
413 }
414  
415 0 ▶sub account_images {
Subroutine account_images: not called CC=4 SCAR=30.0
Pod undocumented
416 0 my $self = shift;
417 0 ▶ my $user = shift or die "missing required username";
Branch: 1 branch
BranchTrueFalseTotal
my $user = shift() or die "missing required username" 0 0 0
418 0 ▶ my $opts = shift // {};
Condition0%0/2
shift() // {}
l!l
00
MC/DC0%0/1
shift() // {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
419 0 ▶ my $page = $opts->{'page'} // 0;
Condition0%0/2
$opts->{"page"} // 0
l!l
00
MC/DC0%0/1
$opts->{"page"} // 0
$opts->{"page"}
Truth table0%0/2
A
A= $opts->{"page"}
Aresult
11
00
420 0 return $self->request("/account/$user/images/$page");
421 }
422  
423 0 ▶sub account_reply_notifications {
Subroutine account_reply_notifications: not called CC=4 SCAR=30.0
Pod undocumented
424 0 my $self = shift;
425 0 ▶ my $user = shift or die "missing required username";
Branch: 1 branch
BranchTrueFalseTotal
my $user = shift() or die "missing required username" 0 0 0
426 0 ▶ my $opts = shift // {};
Condition0%0/2
shift() // {}
l!l
00
MC/DC0%0/1
shift() // {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
427 0 ▶ my $new = $opts->{'new'} // 1;
Condition0%0/2
$opts->{"new"} // 1
l!l
00
MC/DC0%0/1
$opts->{"new"} // 1
$opts->{"new"}
Truth table0%0/2
A
A= $opts->{"new"}
Aresult
11
00
428 0 return $self->request("/account/$user/notifications/replies?new=$new");
429 }
430  
431 0 ▶sub account_settings {
Subroutine account_settings: not called CC=2 SCAR=17.9
Pod undocumented
432 0 my $self = shift;
433 0 ▶ my $user = shift or die "missing required username";
Branch: 1 branch
BranchTrueFalseTotal
my $user = shift() or die "missing required username" 0 0 0
434 0 return $self->request("/account/$user/settings");
435 }
436  
437 0 ▶sub account_settings_update {
Subroutine account_settings_update: not called CC=5 SCAR=34.0
Pod undocumented
438 0 my $self = shift;
439 0 ▶ my $user = shift or die "missing required username";
Branch: 1 branch
BranchTrueFalseTotal
my $user = shift() or die "missing required username" 0 0 0
440 0 ▶ my $settings = shift // {};
Condition0%0/2
shift() // {}
l!l
00
MC/DC0%0/1
shift() // {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
441 0 my @valid_settings = (qw(bio public_images messaging_enabled accepted_gallery_terms username show_mature newsletter_subscribed));
442 0 my %valid_settings_map = map { $_ => 1 } @valid_settings;
443 0 my $data = {};
444  
445 0 foreach my $key (keys %{$settings}) {
446 0 ▶ $data->{$key} = $settings->{$key} if exists $valid_settings_map{$key};
Branch: 1 branch
BranchTrueFalseTotal
if exists $valid_settings_map{$key} 0 0 0
447 }
448  
449 0 return $self->request("/account/$user/settings", 'PUT', $data);
450 }
451  
452 0 ▶sub account_submissions {
Subroutine account_submissions: not called CC=4 SCAR=30.0
Pod undocumented
453 0 my $self = shift;
454 0 ▶ my $user = shift or die "missing required username";
Branch: 1 branch
BranchTrueFalseTotal
my $user = shift() or die "missing required username" 0 0 0
455 0 ▶ my $opts = shift // {};
Condition0%0/2
shift() // {}
l!l
00
MC/DC0%0/1
shift() // {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
456 0 ▶ my $page = $opts->{'page'} // 0;
Condition0%0/2
$opts->{"page"} // 0
l!l
00
MC/DC0%0/1
$opts->{"page"} // 0
$opts->{"page"}
Truth table0%0/2
A
A= $opts->{"page"}
Aresult
11
00
457 0 return $self->request("/account/$user/submissions/$page");
458 }
459  
460 0 ▶sub account_tag_follow {
Subroutine account_tag_follow: not called CC=2 SCAR=17.9
Pod undocumented
461 0 my $self = shift;
462 0 ▶ my $tag = shift or die "missing required tag";
Branch: 1 branch
BranchTrueFalseTotal
my $tag = shift() or die "missing required tag" 0 0 0
463 0 return $self->request("/account/me/follow/tag/$tag", 'POST');
464 }
465  
466 0 ▶sub account_tag_unfollow {
Subroutine account_tag_unfollow: not called CC=2 SCAR=17.9
Pod undocumented
467 0 my $self = shift;
468 0 ▶ my $tag = shift or die "missing required tag";
Branch: 1 branch
BranchTrueFalseTotal
my $tag = shift() or die "missing required tag" 0 0 0
469 0 return $self->request("/account/me/follow/tag/$tag", 'DELETE');
470 }
471  
472 0 ▶sub account_verify_email_send {
Subroutine account_verify_email_send: not called CC=2 SCAR=17.9
Pod undocumented
473 0 my $self = shift;
474 0 ▶ my $user = shift or die "missing required username";
Branch: 1 branch
BranchTrueFalseTotal
my $user = shift() or die "missing required username" 0 0 0
475 0 return $self->request("/account/$user/verifyemail", 'POST');
476 }
477  
478 0 ▶sub account_verify_email_status {
Subroutine account_verify_email_status: not called CC=2 SCAR=17.9
Pod undocumented
479 0 my $self = shift;
480 0 ▶ my $user = shift or die "missing required username";
Branch: 1 branch
BranchTrueFalseTotal
my $user = shift() or die "missing required username" 0 0 0
481 0 return $self->request("/account/$user/verifyemail");
482 }
483  
484 # Album
485 0 ▶sub album {
Subroutine album: not called CC=2 SCAR=17.9
Pod undocumented
486 0 my $self = shift;
487 0 ▶ my $id = shift or die "missing required album id";
Branch: 1 branch
BranchTrueFalseTotal
my $id = shift() or die "missing required album id" 0 0 0
488 0 return $self->request("/album/$id");
489 }
490  
491 0 ▶sub album_create {
Subroutine album_create: not called CC=6 SCAR=37.4
Pod undocumented
492 0 my $self = shift;
493 0 ▶ my $opts = shift // {};
Condition0%0/2
shift() // {}
l!l
00
MC/DC0%0/1
shift() // {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
494 0 my @opt_keys = (qw(ids deletehashes title description cover));
495 0 my %valid_opts = map { $_ => 1 } @opt_keys;
496 0 my $data = {};
497  
498 0 foreach my $opt (keys %{$opts}) {
499 0 ▶ if (exists $valid_opts{$opt}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $valid_opts{$opt}) 0 0 0
500 0 ▶ my $key = $opt eq 'ids' || $opt eq 'deletehashes' ? $opt.'[]' : $opt;
Branch: 1 branch
BranchTrueFalseTotal
$opt eq 'ids' || $opt eq 'deletehashes' ? : 0 0 0
Condition0%0/3
$opt eq "ids" or $opt eq "deletehashes"
l!l&&r!l&&!r
000
MC/DC0%0/2
$opt eq "ids" or $opt eq "deletehashes"
$opt eq "ids" $opt eq "deletehashes"
Truth table0%0/3
A or B
A= $opt eq "ids"B= $opt eq "deletehashes"
ABresult
1X1
011
000
501 0 $data->{$key} = $opts->{$opt};
502 }
503 }
504  
505 0 return $self->request("/album", 'POST', $data);
506 }
507  
508 0 ▶sub album_delete {
Subroutine album_delete: not called CC=2 SCAR=17.9
Pod undocumented
509 0 my $self = shift;
510 0 ▶ my $id = shift or die "missing required album id";
Branch: 1 branch
BranchTrueFalseTotal
my $id = shift() or die "missing required album id" 0 0 0
511 0 return $self->request("/album/$id", 'DELETE');
512 }
513  
514 0 ▶sub album_favorite {
Subroutine album_favorite: not called CC=2 SCAR=17.9
Pod undocumented
515 0 my $self = shift;
516 0 ▶ my $id = shift or die "missing required album id";
Branch: 1 branch
BranchTrueFalseTotal
my $id = shift() or die "missing required album id" 0 0 0
517 0 return $self->request("/album/$id/favorite", 'POST');
518 }
519  
520 0 ▶sub album_image {
Subroutine album_image: not called CC=3 SCAR=24.8
Pod undocumented
521 0 my $self = shift;
522 0 ▶ my $album_id = shift or die "missing required album id";
Branch: 1 branch
BranchTrueFalseTotal
my $album_id = shift() or die "missing required album id" 0 0 0
523 0 ▶ my $image_id = shift or die "missing required image id";
Branch: 1 branch
BranchTrueFalseTotal
my $image_id = shift() or die "missing required image id" 0 0 0
524 0 return $self->request("/album/$album_id/image/$image_id");
525 }
526  
527 0 ▶sub album_images {
Subroutine album_images: not called CC=2 SCAR=17.9
Pod undocumented
528 0 my $self = shift;
529 0 ▶ my $album_id = shift or die "missing required album id";
Branch: 1 branch
BranchTrueFalseTotal
my $album_id = shift() or die "missing required album id" 0 0 0
530 0 return $self->request("/album/$album_id/images");
531 }
532  
533 0 ▶sub album_images_add {
Subroutine album_images_add: not called CC=3 SCAR=24.8
Pod undocumented
534 0 my $self = shift;
535 0 ▶ my $album_id = shift or die "missing required album_id";
Branch: 1 branch
BranchTrueFalseTotal
my $album_id = shift() or die "missing required album_id" 0 0 0
536 0 ▶ my $image_ids = shift or die "missing required image_ids";
Branch: 1 branch
BranchTrueFalseTotal
my $image_ids = shift() or die "missing required image_ids" 0 0 0
537 0 return $self->request("/album/$album_id/add", 'POST', {'ids[]' => $image_ids});
538 }
539  
540 0 ▶sub album_images_delete {
Subroutine album_images_delete: not called CC=3 SCAR=24.8
Pod undocumented
541 0 my $self = shift;
542 0 ▶ my $album_id = shift or die "missing required album_id";
Branch: 1 branch
BranchTrueFalseTotal
my $album_id = shift() or die "missing required album_id" 0 0 0
543 0 ▶ my $image_ids = shift or die "missing required image_ids";
Branch: 1 branch
BranchTrueFalseTotal
my $image_ids = shift() or die "missing required image_ids" 0 0 0
544 0 return $self->request("/album/$album_id/remove_images", 'DELETE', {'ids' => join(',', @$image_ids)});
545 }
546  
547 0 ▶sub album_images_set {
Subroutine album_images_set: not called CC=3 SCAR=24.8
Pod undocumented
548 0 my $self = shift;
549 0 ▶ my $album_id = shift or die "missing required album_id";
Branch: 1 branch
BranchTrueFalseTotal
my $album_id = shift() or die "missing required album_id" 0 0 0
550 0 ▶ my $image_ids = shift or die "missing required image_ids";
Branch: 1 branch
BranchTrueFalseTotal
my $image_ids = shift() or die "missing required image_ids" 0 0 0
551 0 return $self->request("/album/$album_id", 'POST', {'ids[]' => $image_ids});
552 }
553  
554 0 ▶sub album_update {
Subroutine album_update: not called CC=7 SCAR=40.3
Pod undocumented
555 0 my $self = shift;
556 0 ▶ my $album_id = shift or die "missing required album_id";
Branch: 1 branch
BranchTrueFalseTotal
my $album_id = shift() or die "missing required album_id" 0 0 0
557 0 ▶ my $opts = shift // {};
Condition0%0/2
shift() // {}
l!l
00
MC/DC0%0/1
shift() // {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
558 0 my %valid_opts = map { $_ => 1 } (qw(ids deletehashes title description cover));
559 0 my $data = {};
560  
561 0 foreach my $opt (keys %{$opts}) {
562 0 ▶ if (exists $valid_opts{$opt}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $valid_opts{$opt}) 0 0 0
563 0 ▶ my $key = $opt eq 'ids' || $opt eq 'deletehashes' ? $opt.'[]' : $opt;
Branch: 1 branch
BranchTrueFalseTotal
$opt eq 'ids' || $opt eq 'deletehashes' ? : 0 0 0
Condition0%0/3
$opt eq "ids" or $opt eq "deletehashes"
l!l&&r!l&&!r
000
MC/DC0%0/2
$opt eq "ids" or $opt eq "deletehashes"
$opt eq "ids" $opt eq "deletehashes"
Truth table0%0/3
A or B
A= $opt eq "ids"B= $opt eq "deletehashes"
ABresult
1X1
011
000
564 0 $data->{$key} = $opts->{$opt};
565 }
566 }
567  
568 0 return $self->request("/album/$album_id", 'PUT', $data);
569 }
570  
571 # Comment
572 0 ▶sub comment {
Subroutine comment: not called CC=1 SCAR=6.9
Pod undocumented
573 0 my ($self, $id) = @_;
574 0 return $self->request("/comment/$id");
575 }
576  
577 0 ▶sub comment_create {
Subroutine comment_create: not called CC=4 SCAR=30.0
Pod undocumented
578 0 my $self = shift;
579 0 ▶ my $image_id = shift or die "missing required image id";
Branch: 1 branch
BranchTrueFalseTotal
my $image_id = shift() or die "missing required image id" 0 0 0
580 0 ▶ my $comment = shift or die "missing required comment";
Branch: 1 branch
BranchTrueFalseTotal
my $comment = shift() or die "missing required comment" 0 0 0
581 0 my $parent_id = shift;
582  
583 0 ▶ return $self->request("/comment", 'POST', {
Branch: 1 branch
BranchTrueFalseTotal
$parent_id ? : 0 0 0
584 'image_id' => $image_id,
585 'comment' => $comment,
586 ($parent_id ? ('parent_id' => $parent_id) : ()),
587 });
588 }
589  
590 0 ▶sub comment_delete {
Subroutine comment_delete: not called CC=2 SCAR=17.9
Pod undocumented
591 0 my $self = shift;
592 0 ▶ my $comment_id = shift or die "missing required comment id";
Branch: 1 branch
BranchTrueFalseTotal
my $comment_id = shift() or die "missing required comment id" 0 0 0
593 0 return $self->request("/comment/$comment_id", 'DELETE');
594 }
595  
596 0 ▶sub comment_replies {
Subroutine comment_replies: not called CC=2 SCAR=17.9
Pod undocumented
597 0 my $self = shift;
598 0 ▶ my $comment_id = shift or die "missing required comment_id";
Branch: 1 branch
BranchTrueFalseTotal
my $comment_id = shift() or die "missing required comment_id" 0 0 0
599 0 return $self->request("/comment/$comment_id/replies");
600 }
601  
602 0 ▶sub comment_reply {
Subroutine comment_reply: not called CC=4 SCAR=30.0
Pod undocumented
603 0 my $self = shift;
604 0 ▶ my $image_id = shift or die "missing required image_id";
Branch: 1 branch
BranchTrueFalseTotal
my $image_id = shift() or die "missing required image_id" 0 0 0
605 0 ▶ my $comment_id = shift or die "missing required comment_id";
Branch: 1 branch
BranchTrueFalseTotal
my $comment_id = shift() or die "missing required comment_id" 0 0 0
606 0 ▶ my $comment = shift or die "missing required comment";
Branch: 1 branch
BranchTrueFalseTotal
my $comment = shift() or die "missing required comment" 0 0 0
607  
608 0 return $self->comment_create($image_id, $comment, $comment_id);
609 }
610  
611 0 ▶sub comment_report {
Subroutine comment_report: not called CC=3 SCAR=24.8
Pod undocumented
612 0 my $self = shift;
613 0 ▶ my $comment_id = shift or die "missing required comment_id";
Branch: 1 branch
BranchTrueFalseTotal
my $comment_id = shift() or die "missing required comment_id" 0 0 0
614 0 my $reason = shift;
615 0 my $data = {};
616  
617 0 ▶ $data->{'reason'} = $reason if $reason;
Branch: 1 branch
BranchTrueFalseTotal
if $reason 0 0 0
618  
619 0 return $self->request("/comment/$comment_id/report", 'POST', $data);
620 }
621  
622 0 ▶sub comment_vote {
Subroutine comment_vote: not called CC=3 SCAR=24.8
Pod undocumented
623 0 my $self = shift;
624 0 ▶ my $comment_id = shift or die "missing required comment_id";
Branch: 1 branch
BranchTrueFalseTotal
my $comment_id = shift() or die "missing required comment_id" 0 0 0
625 0 ▶ my $vote = shift or die "missing required vote";
Branch: 1 branch
BranchTrueFalseTotal
my $vote = shift() or die "missing required vote" 0 0 0
626  
627 0 return $self->request("/comment/$comment_id/vote/$vote", 'POST');
628 }
629  
630 # Credits
631 0 ▶sub credits {
Subroutine credits: not called CC=1 SCAR=6.9
Pod undocumented
632 0 my $self = shift;
633 0 return $self->request("/credits");
634 }
635  
636 # Gallery
637 0 ▶sub gallery {
Subroutine gallery: not called CC=10 SCAR=47.0
Pod undocumented
638 0 my $self = shift;
639 0 ▶ my $opts = shift // {};
Condition0%0/2
shift() // {}
l!l
00
MC/DC0%0/1
shift() // {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
640  
641 0 ▶ die "optional data must be a hashref" if ref $opts ne 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $opts ne "HASH" 0 0 0
642  
643 0 ▶ my $section = $opts->{'section'} // 'hot';
Condition0%0/2
$opts->{"section"} // "hot"
l!l
00
MC/DC0%0/1
$opts->{"section"} // "hot"
$opts->{"section"}
Truth table0%0/2
A
A= $opts->{"section"}
Aresult
11
00
644 0 ▶ my $sort = $opts->{'sort'} // 'viral';
Condition0%0/2
$opts->{"sort"} // "viral"
l!l
00
MC/DC0%0/1
$opts->{"sort"} // "viral"
$opts->{"sort"}
Truth table0%0/2
A
A= $opts->{"sort"}
Aresult
11
00
645 0 ▶ my $page = $opts->{'page'} // 0;
Condition0%0/2
$opts->{"page"} // 0
l!l
00
MC/DC0%0/1
$opts->{"page"} // 0
$opts->{"page"}
Truth table0%0/2
A
A= $opts->{"page"}
Aresult
11
00
646 0 ▶ my $window = $opts->{'window'} // 'day';
Condition0%0/2
$opts->{"window"} // "day"
l!l
00
MC/DC0%0/1
$opts->{"window"} // "day"
$opts->{"window"}
Truth table0%0/2
A
A= $opts->{"window"}
Aresult
11
00
647 0 ▶ my $show_viral = $opts->{'show_viral'} // 1;
Condition0%0/2
$opts->{"show_viral"} // 1
l!l
00
MC/DC0%0/1
$opts->{"show_viral"} // 1
$opts->{"show_viral"}
Truth table0%0/2
A
A= $opts->{"show_viral"}
Aresult
11
00
648 0 ▶ my $album_prev = $opts->{'album_previews'} // 1;
Condition0%0/2
$opts->{"album_previews"} // 1
l!l
00
MC/DC0%0/1
$opts->{"album_previews"} // 1
$opts->{"album_previews"}
Truth table0%0/2
A
A= $opts->{"album_previews"}
Aresult
11
00
649  
650 0 ▶ return $self->request(("/gallery/$section/$sort/$window/$page?showViral=$show_viral&album_previews=" . ($album_prev ? 'true' : 'false')));
Branch: 1 branch
BranchTrueFalseTotal
$album_prev ? : 0 0 0
651 }
652  
653 0 ▶sub gallery_album {
Subroutine gallery_album: not called CC=2 SCAR=17.9
Pod undocumented
654 0 my $self = shift;
655 0 ▶ my $album_id = shift or die "missing required album id";
Branch: 1 branch
BranchTrueFalseTotal
my $album_id = shift() or die "missing required album id" 0 0 0
656 0 return $self->request("/gallery/album/$album_id");
657 }
658  
659 0 ▶sub gallery_image {
Subroutine gallery_image: not called CC=2 SCAR=17.9
Pod undocumented
660 0 my $self = shift;
661 0 ▶ my $image_id = shift or die "missing required image id";
Branch: 1 branch
BranchTrueFalseTotal
my $image_id = shift() or die "missing required image id" 0 0 0
662 0 return $self->request("/gallery/image/$image_id");
663 }
664  
665 0 ▶sub gallery_item_comment {
Subroutine gallery_item_comment: not called CC=3 SCAR=24.8
Pod undocumented
666 0 my $self = shift;
667 0 ▶ my $id = shift or die "missing required album/image id";
Branch: 1 branch
BranchTrueFalseTotal
my $id = shift() or die "missing required album/image id" 0 0 0
668 0 ▶ my $comment = shift or die "missing required comment";
Branch: 1 branch
BranchTrueFalseTotal
my $comment = shift() or die "missing required comment" 0 0 0
669 0 return $self->request("/gallery/$id/comment", 'POST', {comment => $comment});
670 }
671  
672 0 ▶sub gallery_item_comment_info {
Subroutine gallery_item_comment_info: not called CC=3 SCAR=24.8
Pod undocumented
673 0 my $self = shift;
674 0 ▶ my $id = shift or die "missing required album/image id";
Branch: 1 branch
BranchTrueFalseTotal
my $id = shift() or die "missing required album/image id" 0 0 0
675 0 ▶ my $comment_id = shift or die "missing required comment id";
Branch: 1 branch
BranchTrueFalseTotal
my $comment_id = shift() or die "missing required comment id" 0 0 0
676 0 return $self->request("/gallery/$id/comment/$comment_id");
677 }
678  
679 0 ▶sub gallery_item_comments {
Subroutine gallery_item_comments: not called CC=4 SCAR=30.0
Pod undocumented
680 0 my $self = shift;
681 0 ▶ my $id = shift or die "missing required image/album id";
Branch: 1 branch
BranchTrueFalseTotal
my $id = shift() or die "missing required image/album id" 0 0 0
682 0 ▶ my $opts = shift // {};
Condition0%0/2
shift() // {}
l!l
00
MC/DC0%0/1
shift() // {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
683 0 ▶ my $sort = $opts->{'sort'} // 'best';
Condition0%0/2
$opts->{"sort"} // "best"
l!l
00
MC/DC0%0/1
$opts->{"sort"} // "best"
$opts->{"sort"}
Truth table0%0/2
A
A= $opts->{"sort"}
Aresult
11
00
684 0 return $self->request("/gallery/$id/comments/$sort");
685 }
686  
687 0 ▶sub gallery_item_report {
Subroutine gallery_item_report: not called CC=5 SCAR=34.0
Pod undocumented
688 0 my $self = shift;
689 0 ▶ my $id = shift or die "missing required image/album id";
Branch: 1 branch
BranchTrueFalseTotal
my $id = shift() or die "missing required image/album id" 0 0 0
690 0 ▶ my $opts = shift // {};
Condition0%0/2
shift() // {}
l!l
00
MC/DC0%0/1
shift() // {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
691 0 my $reason = $opts->{'reason'};
692 0 ▶ my %data = ($reason ? (reason => $reason) : ());
Branch: 1 branch
BranchTrueFalseTotal
$reason ? : 0 0 0
693  
694 0 ▶ $data{'reason'} = $reason if $reason;
Branch: 1 branch
BranchTrueFalseTotal
if $reason 0 0 0
695  
696 0 return $self->request("/gallery/image/$id/report", 'POST', \%data);
697 }
698  
699 0 ▶sub gallery_item_tags {
Subroutine gallery_item_tags: not called CC=2 SCAR=17.9
Pod undocumented
700 0 my $self = shift;
701 0 ▶ my $id = shift or die "missing required image/album id";
Branch: 1 branch
BranchTrueFalseTotal
my $id = shift() or die "missing required image/album id" 0 0 0
702 0 return $self->request("/gallery/$id/tags");
703 }
704  
705 0 ▶sub gallery_item_tags_update {
Subroutine gallery_item_tags_update: not called CC=3 SCAR=24.8
Pod undocumented
706 0 my $self = shift;
707 0 ▶ my $id = shift or die "missing required image/album id";
Branch: 1 branch
BranchTrueFalseTotal
my $id = shift() or die "missing required image/album id" 0 0 0
708 0 ▶ my $tags = shift or die "missing required tags";
Branch: 1 branch
BranchTrueFalseTotal
my $tags = shift() or die "missing required tags" 0 0 0
709 0 return $self->request("/gallery/$id/tags", 'POST', {'tags' => $tags});
710 }
711  
712 0 ▶sub gallery_item_vote {
Subroutine gallery_item_vote: not called CC=3 SCAR=24.8
Pod undocumented
713 0 my $self = shift;
714 0 ▶ my $id = shift or die "missing required image/album id";
Branch: 1 branch
BranchTrueFalseTotal
my $id = shift() or die "missing required image/album id" 0 0 0
715 0 ▶ my $vote = shift or die "missing required vote";
Branch: 1 branch
BranchTrueFalseTotal
my $vote = shift() or die "missing required vote" 0 0 0
716 0 return $self->request("/gallery/$id/vote/$vote", 'POST');
717 }
718  
719 0 ▶sub gallery_item_votes {
Subroutine gallery_item_votes: not called CC=2 SCAR=17.9
Pod undocumented
720 0 my $self = shift;
721 0 ▶ my $id = shift or die "missing required image/album id";
Branch: 1 branch
BranchTrueFalseTotal
my $id = shift() or die "missing required image/album id" 0 0 0
722 0 return $self->request("/gallery/$id/votes");
723 }
724  
725 0 ▶sub gallery_image_remove {
Subroutine gallery_image_remove: not called CC=2 SCAR=17.9
Pod undocumented
726 0 my $self = shift;
727 0 ▶ my $id = shift or die "missing required image id";
Branch: 1 branch
BranchTrueFalseTotal
my $id = shift() or die "missing required image id" 0 0 0
728 0 return $self->request("/gallery/$id", 'DELETE');
729 }
730  
731 0 ▶sub gallery_search {
Subroutine gallery_search: not called CC=12 SCAR=50.5
Pod undocumented
732 0 my $self = shift;
733 0 ▶ my $opts = shift // {};
Condition0%0/2
shift() // {}
l!l
00
MC/DC0%0/1
shift() // {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
734 0 ▶ my $query = $opts->{'q'} // '';
Condition0%0/2
$opts->{"q"} // ""
l!l
00
MC/DC0%0/1
$opts->{"q"} // ""
$opts->{"q"}
Truth table0%0/2
A
A= $opts->{"q"}
Aresult
11
00
735 0 ▶ my $adv = $opts->{'adv'} // 0;
Condition0%0/2
$opts->{"adv"} // 0
l!l
00
MC/DC0%0/1
$opts->{"adv"} // 0
$opts->{"adv"}
Truth table0%0/2
A
A= $opts->{"adv"}
Aresult
11
00
736 0 ▶ my $sort = $opts->{'sort'} // 'time';
Condition0%0/2
$opts->{"sort"} // "time"
l!l
00
MC/DC0%0/1
$opts->{"sort"} // "time"
$opts->{"sort"}
Truth table0%0/2
A
A= $opts->{"sort"}
Aresult
11
00
737 0 ▶ my $window = $opts->{'window'} // 'all';
Condition0%0/2
$opts->{"window"} // "all"
l!l
00
MC/DC0%0/1
$opts->{"window"} // "all"
$opts->{"window"}
Truth table0%0/2
A
A= $opts->{"window"}
Aresult
11
00
738 0 ▶ my $page = $opts->{'page'} // 0;
Condition0%0/2
$opts->{"page"} // 0
l!l
00
MC/DC0%0/1
$opts->{"page"} // 0
$opts->{"page"}
Truth table0%0/2
A
A= $opts->{"page"}
Aresult
11
00
739 0 my $data = {};
740  
741 0 ▶ if ($adv) {
Branch: 2 branches
BranchTrueFalseTotal
if ($adv) { } 0 0 0
elsif (not $query) { } 0 0 0
742 0 my %adv_keys = map { $_ => 1 } ('q_all', 'q_any', 'q_exactly', 'q_not', 'q_type', 'q_size_px');
743 0 foreach my $key (keys %{$adv}) {
744 0 ▶ $data->{$key} = $adv->{$key} unless ! exists($adv_keys{$key});
Branch: 1 branch
BranchTrueFalseTotal
if exists $adv_keys{$key} 0 0 0
745 }
746 } elsif (!$query) {
747 0 die "must provide a query or adv search parameters";
748 }
749  
750 0 print Dumper $data;
751  
752 0 ▶ return $self->request("/gallery/search/$sort/$window/$page" . ($adv ? '' : "?q=$query"), 'GET', $data, undef, 1);
Branch: 1 branch
BranchTrueFalseTotal
$adv ? : 0 0 0
753 }
754  
755 0 ▶sub gallery_share_image {
Subroutine gallery_share_image: not called CC=9 SCAR=45.0
Pod undocumented
756 0 my $self = shift;
757 0 ▶ my $image_id = shift or die "missing required image id";
Branch: 1 branch
BranchTrueFalseTotal
my $image_id = shift() or die "missing required image id" 0 0 0
758 0 ▶ my $title = shift or die "missing required title";
Branch: 1 branch
BranchTrueFalseTotal
my $title = shift() or die "missing required title" 0 0 0
759 0 ▶ my $opts = shift // {};
Condition0%0/2
shift() // {}
l!l
00
MC/DC0%0/1
shift() // {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
760 0 my $data = {'title' => $title};
761  
762 0 ▶ if ($opts) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts) 0 0 0
763 0 my @optional_keys = ('topic', 'terms', 'mature', 'tags');
764 0 foreach my $key (keys %{$opts}) {
765 0 ▶ if (first { $_ eq $key } @optional_keys) {
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if (&first(sub { $_ eq $key; } , @optional_keys)) 0 0 0
766 0 ▶ if ($key eq 'tags') {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "tags") 0 0 0
767 0 ▶ if (ref $opts->{'tags'} eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $opts->{"tags"} eq "ARRAY") 0 0 0
768 0 $opts->{'tags'} = join(',', @{$opts->{'tags'}});
769 }
770 }
771 0 $data->{$key} = $opts->{$key};
772 }
773 }
774 }
775  
776 0 return $self->request("/gallery/image/$image_id", "POST", $data);
777 }
778  
779 0 ▶sub gallery_share_album {
Subroutine gallery_share_album: not called CC=9 SCAR=45.0
Pod undocumented
780 0 my $self = shift;
781 0 ▶ my $album_id = shift or die "missing required album id";
Branch: 1 branch
BranchTrueFalseTotal
my $album_id = shift() or die "missing required album id" 0 0 0
782 0 ▶ my $title = shift or die "missing required title";
Branch: 1 branch
BranchTrueFalseTotal
my $title = shift() or die "missing required title" 0 0 0
783 0 ▶ my $opts = shift // {};
Condition0%0/2
shift() // {}
l!l
00
MC/DC0%0/1
shift() // {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
784 0 my $data = {'title' => $title};
785  
786 0 ▶ if ($opts) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts) 0 0 0
787 0 my @optional_keys = ('topic', 'terms', 'mature', 'tags');
788 0 foreach my $key (keys %{$opts}) {
789 0 ▶ if (first { $_ eq $key } @optional_keys) {
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if (&first(sub { $_ eq $key; } , @optional_keys)) 0 0 0
790 0 ▶ if ($key eq 'tags') {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "tags") 0 0 0
791 0 ▶ if (ref $opts->{'tags'} eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $opts->{"tags"} eq "ARRAY") 0 0 0
792 0 $opts->{'tags'} = join(',', @{$opts->{'tags'}});
793 }
794 }
795 0 $data->{$key} = $opts->{$key};
796 }
797 }
798 }
799  
800 0 return $self->request("/gallery/album/$album_id", "POST", $data);
801 }
802  
803 0 ▶sub gallery_subreddit {
Subroutine gallery_subreddit: not called CC=8 SCAR=42.8
Pod undocumented
804 0 my $self = shift;
805 0 ▶ my $subreddit = shift or die "missing required subreddit";
Branch: 1 branch
BranchTrueFalseTotal
my $subreddit = shift() or die "missing required subreddit" 0 0 0
806 0 ▶ my $opts = shift // {};
Condition0%0/2
shift() // {}
l!l
00
MC/DC0%0/1
shift() // {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
807  
808 0 ▶ die "optional data must be a hashref" if ref $opts ne 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $opts ne "HASH" 0 0 0
809  
810 0 ▶ my $sort = $opts->{'sort'} // 'time';
Condition0%0/2
$opts->{"sort"} // "time"
l!l
00
MC/DC0%0/1
$opts->{"sort"} // "time"
$opts->{"sort"}
Truth table0%0/2
A
A= $opts->{"sort"}
Aresult
11
00
811 0 ▶ my $window = $opts->{'window'} // 'week';
Condition0%0/2
$opts->{"window"} // "week"
l!l
00
MC/DC0%0/1
$opts->{"window"} // "week"
$opts->{"window"}
Truth table0%0/2
A
A= $opts->{"window"}
Aresult
11
00
812 0 ▶ my $page = $opts->{'page'} // 0;
Condition0%0/2
$opts->{"page"} // 0
l!l
00
MC/DC0%0/1
$opts->{"page"} // 0
$opts->{"page"}
Truth table0%0/2
A
A= $opts->{"page"}
Aresult
11
00
813  
814 0 ▶ return $self->request(("/gallery/r/$subreddit/$sort" . ($sort eq 'top' ? "/$window" : "") . "/$page"));
Branch: 1 branch
BranchTrueFalseTotal
$sort eq 'top' ? : 0 0 0
815 }
816  
817 0 ▶sub gallery_subreddit_image {
Subroutine gallery_subreddit_image: not called CC=3 SCAR=24.8
Pod undocumented
818 0 my $self = shift;
819 0 ▶ my $subreddit = shift or die "missing required subreddit";
Branch: 1 branch
BranchTrueFalseTotal
my $subreddit = shift() or die "missing required subreddit" 0 0 0
820 0 ▶ my $image_id = shift or die "missing required image id";
Branch: 1 branch
BranchTrueFalseTotal
my $image_id = shift() or die "missing required image id" 0 0 0
821  
822 0 return $self->request("/gallery/r/$subreddit/$image_id");
823 }
824  
825 0 ▶sub gallery_tag {
Subroutine gallery_tag: not called CC=7 SCAR=40.3
Pod undocumented
826 0 my $self = shift;
827 0 ▶ my $tag = shift or die "missing required tag";
Branch: 1 branch
BranchTrueFalseTotal
my $tag = shift() or die "missing required tag" 0 0 0
828 0 ▶ my $opts = shift // {};
Condition0%0/2
shift() // {}
l!l
00
MC/DC0%0/1
shift() // {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
829 0 ▶ my $sort = $opts->{'sort'} // 'viral';
Condition0%0/2
$opts->{"sort"} // "viral"
l!l
00
MC/DC0%0/1
$opts->{"sort"} // "viral"
$opts->{"sort"}
Truth table0%0/2
A
A= $opts->{"sort"}
Aresult
11
00
830 0 ▶ my $page = $opts->{'page'} // 0;
Condition0%0/2
$opts->{"page"} // 0
l!l
00
MC/DC0%0/1
$opts->{"page"} // 0
$opts->{"page"}
Truth table0%0/2
A
A= $opts->{"page"}
Aresult
11
00
831 0 ▶ my $window = $opts->{'window'} // 'week';
Condition0%0/2
$opts->{"window"} // "week"
l!l
00
MC/DC0%0/1
$opts->{"window"} // "week"
$opts->{"window"}
Truth table0%0/2
A
A= $opts->{"window"}
Aresult
11
00
832  
833 0 ▶ return $self->request(("/gallery/t/$tag/$sort" . ($sort eq 'top' ? "/$window" : "") . "/$page"));
Branch: 1 branch
BranchTrueFalseTotal
$sort eq 'top' ? : 0 0 0
834 }
835  
836 0 ▶sub gallery_tag_info {
Subroutine gallery_tag_info: not called CC=2 SCAR=17.9
Pod undocumented
837 0 my $self = shift;
838 0 ▶ my $tag = shift or die "missing required tag";
Branch: 1 branch
BranchTrueFalseTotal
my $tag = shift() or die "missing required tag" 0 0 0
839 0 return $self->request("/gallery/tag_info/$tag");
840 }
841  
842 0 ▶sub gallery_tags {
Subroutine gallery_tags: not called CC=1 SCAR=6.9
Pod undocumented
843 0 my $self = shift;
844 0 return $self->request("/tags");
845 }
846  
847 # Image
848 0 ▶sub image {
Subroutine image: not called CC=2 SCAR=17.9
Pod undocumented
849 0 my $self = shift;
850 0 ▶ my $id = shift or die "missing required image id";
Branch: 1 branch
BranchTrueFalseTotal
my $id = shift() or die "missing required image id" 0 0 0
851 0 return $self->request("/image/$id");
852 }
853  
854 0 ▶sub image_upload {
Subroutine image_upload: not called CC=9 SCAR=45.0
Pod undocumented
855 0 my $self = shift;
856 0 ▶ my $src = shift or die "missing required image/video src";
Branch: 1 branch
BranchTrueFalseTotal
my $src = shift() or die "missing required image/video src" 0 0 0
857 0 ▶ my $type = shift or die "missing required image/video type";
Branch: 1 branch
BranchTrueFalseTotal
my $type = shift() or die "missing required image/video type" 0 0 0
858 0 ▶ my $opts = shift // {};
Condition0%0/2
shift() // {}
l!l
00
MC/DC0%0/1
shift() // {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
859 0 my $data = {'image' => $src, 'type' => $type};
860 0 my %hdr = ();
861  
862 0 ▶ $data->{'title'} = $opts->{'title'} if $opts->{'title'};
Branch: 1 branch
BranchTrueFalseTotal
if $opts->{"title"} 0 0 0
863 0 ▶ $data->{'description'} = $opts->{'description'} if $opts->{'description'};
Branch: 1 branch
BranchTrueFalseTotal
if $opts->{"description"} 0 0 0
864  
865 0 ▶ if ($type eq 'file') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "file") 0 0 0
866 0 ▶ die "file doesnt exist at path: $src" unless -e $src;
Branch: 1 branch
BranchTrueFalseTotal
unless -e $src 0 0 0
867 0 ▶ die "provided src file path is not a file" unless -f $src;
Branch: 1 branch
BranchTrueFalseTotal
unless -f $src 0 0 0
868 0 $data->{'image'} = [$src];
869 0 %hdr = (Content_Type => 'form-data');
870 }
871  
872 0 return $self->request("/image", 'POST', $data, \%hdr);
873 }
874  
875 0 ▶sub image_delete {
Subroutine image_delete: not called CC=2 SCAR=17.9
Pod undocumented
876 0 my $self = shift;
877 0 ▶ my $id = shift or die "missing required image id";
Branch: 1 branch
BranchTrueFalseTotal
my $id = shift() or die "missing required image id" 0 0 0
878 0 return $self->request("/image/$id", 'DELETE');
879 }
880  
881 0 ▶sub image_favorite {
Subroutine image_favorite: not called CC=2 SCAR=17.9
Pod undocumented
882 0 my $self = shift;
883 0 ▶ my $id = shift or die "missing required image id";
Branch: 1 branch
BranchTrueFalseTotal
my $id = shift() or die "missing required image id" 0 0 0
884 0 return $self->request("/image/$id/favorite", 'POST');
885 }
886  
887 0 ▶sub image_update {
Subroutine image_update: not called CC=3 SCAR=24.8
Pod undocumented
888 0 my $self = shift;
889 0 ▶ my $id = shift or die "missing required image id";
Branch: 1 branch
BranchTrueFalseTotal
my $id = shift() or die "missing required image id" 0 0 0
890 0 ▶ my $opts = shift // {};
Condition0%0/2
shift() // {}
l!l
00
MC/DC0%0/1
shift() // {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
891 0 return $self->request("/image/$id", 'POST', $opts);
892 }
893  
894 # Feed
895 0 ▶sub feed {
Subroutine feed: not called CC=1 SCAR=6.9
Pod undocumented
896 0 my $self = shift;
897 0 return $self->request("/feed");
898 }
899  
900 =head1 NAME
901  
902 ImgurAPI::Client - Imgur API client
903  
904 =head1 DESCRIPTION
905  
906 This is a client module for interfacing with the Imgur API.
907  
908 =head1 SYNOPSIS
909  
910 =head2 Instantiation
911  
912 use ImgurAPI::Client;
913  
914 my $client = ImgurAPI::Client->new({
915 'client_id' => 'your_client_id',
916 'access_token' => 'your_access_token'
917 });
918  
919 my $upload = $client->image_upload("helloimgur.png", 'file', {title => 'title', description => 'desc'});
920 my $image_info = $client->image($upload->{'data'}->{'id'};
921  
922 =head2 Authorization
923  
924 Imgur uses OAuth 2.0 for authentication. OAuth 2.0 has four steps: registration, authorization, making authenticated requests and getting new access tokens after the initial one expires using a refresh token and client secret.
925  
926 After registering a client application with Imgur L<here|https://api.imgur.com/oauth2/addclient>, the user will need to manually authorize it. Generate a authorization url using the C<oauth2_authorize_url> method and redirect the user to the generated url. The user will be prompted to authorize the application and upon authorization, the user will be redirected to the callback endpoint URL that was specified during application registration. The callback endpoint should collect the access token and refresh token and store them somewhere your code on the backend can pull the access token from and then pass it to the client. You can also visit the authorization url in the browser and manually pull the access token, refresh token and other parameters out of the redirect url and store them somewhere your code can pull them without having a collector endpoint setup. View the official imgur documentation for authorization L<here|https://apidocs.imgur.com/#authorization-and-oauth>.
927  
928 =head2 Authentication
929  
930 The client can be authenticated by setting the access token and client id. Those can be set a couple of ways. The first way is to do it is by passing them to the constructor:
931  
932 my $client = ImgurAPI::Client->new({
933 'client_id' => 'your_client_id',
934 'client_secret' => 'your_client_secret'
935 'access_token' => 'your_access_token'
936 });
937  
938 The second way is to use the setter methods:
939  
940 $client->set_access_token('your_access_token');
941 $client->set_client_id('your_client_id');
942  
943 =head2 Refreshing Access Tokens
944  
945 Access tokens expire after a period of time. To get a new access token, you can use the C<refresh_access_token> method. This method requires the refresh token, client id and client secret. You can pass these values to the method or set them using the setter methods. If you don't pass them and they're not set, the method will die. If the function is successful it will update the internal access_token and refresh_token to use for subsequent requests and then return them in a hashref.
946  
947 my %args = (
948 'refresh_token' => 'your_refresh_token',
949 'client_id' => 'your_client_id',
950 'client_secret' => 'your_client_secret'
951 );
952 my $refresh_token = get_refresh_token_from_datastore();
953  
954 my $resp = $client->refresh_access_token(\%args);
955 my $new_refresh_token = $resp->{'refresh_token'};
956  
957 # Store the new refresh token somewhere persistent so it can be used later when the new access token expires.
958  
959  
960 =head2 METHODS
961  
962 =head3 new
963  
964 $client = ImgurAPI::Client->new(\%args);
965  
966 Valid constructor arguments are:
967  
968 =over 4
969  
970 =item *
971  
972 C<access_key> - Access token used to authenticate requests.
973  
974 =item *
975  
976 C<client_id> - Client identifier used for authorization, refresh token requests and unauthenticated requests.
977  
978 =item *
979  
980 C<client_secret> - Client secret used for acquiring a refresh token.
981  
982 =item *
983  
984 C<format_type> - Api endpoint response format type. Options are C<json> (default) and C<xml>.
985  
986 =item *
987  
988 C<oauth_cb_state> - A parameter that's appended to the OAuth2 authorization callback URL. May be useful if you want to pass along a tracking value to the callback endpoint / collector.
989  
990 =item *
991  
992 C<rapidapi_key> - Commercial use api key provided by RapidAPI.
993  
994 =item *
995  
996 C<user_agent> - User agent string to use for requests (default: 'ImgurAPI::Client/X.X.X')
997  
998 =back
999  
1000 A getter and setter method is provided for each constructor arg.
1001  
1002 =head3 SETTER METHODS
1003  
1004  
1005 =head4 set_access_token
1006  
1007 $client->set_access_token('your_access_token');
1008  
1009 =head4 set_client_id
1010  
1011 $client->set_client_id('your_client_id');
1012  
1013 =head4 set_client_secret
1014  
1015 $client->set_client_secret('your_client_secret');
1016  
1017 =head4 set_format_type
1018  
1019 $client->set_format_type('xml');
1020  
1021 =head4 set_oauth_cb_state
1022  
1023 $client->set_oauth_cb_state('your_oauth_cb_state');
1024  
1025 =head4 set_rapidapi_key
1026  
1027 $client->set_rapidapi_key('rapidapi_key');
1028  
1029 =head4 set_user_agent
1030  
1031 $client->set_user_agent('your_user_agent');
1032  
1033 =head3 GETTER METHODS
1034  
1035 =head4 access_token
1036  
1037 $access_tok = $client->access_token;
1038  
1039 =head4 client_id
1040  
1041 $client_id = $client->client_id;
1042  
1043 =head4 client_secret
1044  
1045 $client_secret = $client->client_secret;
1046  
1047 =head4 format_type
1048  
1049 $format_type = $client->format_type;
1050  
1051 =head4 oauth_cb_state
1052  
1053 $oauth_cb_state = $client->oauth_cb_state;
1054  
1055 =head4 rapidapi_key
1056  
1057 $rapidapi_key = $client->rapidapi_key;
1058  
1059 =head4 response
1060  
1061 $response = $client->response;
1062  
1063 This method will return the last response object from the last request.
1064  
1065 =head4 response_content
1066  
1067 $response_content = $client->response_content;
1068  
1069 This method will return the last response content from the last request.
1070  
1071 =head4 ratelimit_headers
1072  
1073 $ratelimit_headers = $client->ratelimit_headers;
1074  
1075 This method will return a hashref containing the rate limit headers from the last request. The keys returned are:
1076  
1077 =head4 user_agent
1078  
1079 $user_agent = $client->user_agent;
1080  
1081 Returns the current user agent string.
1082  
1083 =over 4
1084  
1085 =item *
1086  
1087 C<userlimit> - The total credits that can be allocated.
1088  
1089 =item *
1090  
1091 C<userremaining> - The total credits remaining.
1092  
1093 =item *
1094  
1095 C<userreset> - Timestamp (unix epoch) for when the credits will be reset.
1096  
1097 =item *
1098  
1099 C<clientlimit> - Total credits that can be allocated for the application in a day.
1100  
1101 =item *
1102  
1103 C<clientremaining> - Total credits remaining for the application in a day.
1104  
1105 =back
1106  
1107 You can also get rate limit information by calling the C<credits> method.
1108  
1109  
1110 =head3 API REQUEST METHODS
1111  
1112  
1113 =head4 ACCOUNT
1114  
1115 =head5 account
1116  
1117 $resp = $client->account($username);
1118  
1119 Get account information for a given username. Pass C<me> as the username to get the account information for the authenticated user.
1120  
1121 =head5 account_album
1122  
1123 $resp = $client->account_album($username, $album_id);
1124  
1125 Get information about a specific account album. Pass C<me> as the username to get the account information for the authenticated user.
1126  
1127 =head5 account_album_count
1128  
1129 $resp = $client->account_album_count($username);
1130  
1131 Get the total number of albums associated with an account. Pass C<me> as the username to get the account information for the authenticated user.
1132  
1133 =head5 account_album_delete
1134  
1135 $resp = $client->account_album_delete($username, $album_id);
1136  
1137 Delete a specific album. Pass C<me> as the username to get the account information for the authenticated user.
1138  
1139 =head5 account_album_ids
1140  
1141 $resp = $client->account_album_ids($username, \%opts);
1142  
1143 Get all the album ids associated with the account. Pass C<me> as the username to get the account information for the authenticated user.
1144  
1145 Valid C<\%opts> keys are:
1146  
1147 =over 4
1148  
1149 =item *
1150  
1151 C<page> - Page number
1152  
1153 =back
1154  
1155 =head5 account_albums
1156  
1157 $resp = $client->account_albums($username, \%opts);
1158  
1159 Valid C<\%opts> keys are:
1160  
1161 =over 4
1162  
1163 =item *
1164  
1165 C<page> - Page number
1166  
1167 =back
1168  
1169 =head5 account_block_status
1170  
1171 $resp = $client->account_block_status($username);
1172  
1173 Get the current block status for a user.
1174  
1175 =head5 account_block_create
1176  
1177 $resp = $client->account_block_create($username);
1178  
1179 Block a user.
1180  
1181 =head5 account_block_delete
1182  
1183 $resp = $client->account_block_delete($username);
1184  
1185 Unblock a user.
1186  
1187 =head5 account_blocks
1188  
1189 $resp = $client->account_blocks;
1190  
1191 Get the list of usernames that have been blocked.
1192  
1193 =head5 account_comment
1194  
1195 $resp = $client->account_comment($username, $comment_id);
1196  
1197 Get information about a specific account comment.
1198  
1199 =head5 account_comment_count
1200  
1201 $resp = $client->account_comment_count($username);
1202  
1203 Get the total number of comments associated with the account username.
1204  
1205 =head5 account_comment_delete
1206  
1207 $resp = $client->account_comment_delete($username, $comment_id);
1208  
1209 Delete a specific account comment.
1210  
1211 =head5 account_comment_ids
1212  
1213 $resp = $client->account_comment_ids($username, \%opts);
1214  
1215 Valid C<\%opts> keys are:
1216  
1217 =over 4
1218  
1219 =item *
1220  
1221 C<page> - Page number
1222  
1223 =item *
1224  
1225 C<sort> - Sort order. Options are C<best>, C<worst> and C<newest> (default)
1226  
1227 =back
1228  
1229 =head5 account_comments
1230  
1231 $resp = $client->account_comments($username, \%opts);
1232  
1233 Valid C<\%opts> keys are:
1234  
1235 =over 4
1236  
1237 =item *
1238  
1239 C<page> - Page number
1240  
1241 =item *
1242  
1243 C<sort> - Sort order. Options are C<best>, C<worst> and C<newest> (default)
1244  
1245 =back
1246  
1247 =head5 account_delete
1248  
1249 $resp = $client->account_delete($password, \%opts);
1250  
1251 Valid C<\%opts> keys are:
1252  
1253 =over 4
1254  
1255 =item *
1256  
1257 C<reasons> - Array reference of reasons for deleting the account
1258  
1259 =item *
1260  
1261 C<feedback> - Feedback in the form of a string for Imgur.
1262  
1263 =back
1264  
1265 =head5 account_favorites
1266  
1267 $resp = $client->account_favorites($username, \%opts);
1268  
1269 Valid C<\%opts> keys are:
1270  
1271 =over 4
1272  
1273 =item *
1274  
1275 C<page> - Page number
1276  
1277 =item *
1278  
1279 C<sort> - Sort order. Options are C<oldest> or C<newest> (default)
1280  
1281 =back
1282  
1283 =head5 account_gallery_favorites
1284  
1285 $resp = $client->account_gallery_favorites($username, \%opts);
1286  
1287 Valid C<\%opts> keys are:
1288  
1289 =over 4
1290  
1291 =item *
1292  
1293 C<page> - Page number
1294  
1295 =item *
1296  
1297 C<sort> - Sort order. Options are C<oldest> or C<newest> (default)
1298  
1299 =back
1300  
1301 =head5 account_image
1302  
1303 $resp = $client->account_image($username, $image_id);
1304  
1305 Get information about a specific image in the account.
1306  
1307 =head5 account_image_count
1308  
1309 $resp = $client->account_image_count($username);
1310  
1311 Get the total number of images associated with the account.
1312  
1313 =head5 account_image_delete
1314  
1315 $resp = $client->account_image_delete($username, $image_id);
1316  
1317 Delete a specific image.
1318  
1319 =head5 account_image_ids
1320  
1321 $resp = $client->account_image_ids($username, \%opts);
1322  
1323 Valid C<\%opts> keys are:
1324  
1325 =over 4
1326  
1327 =item *
1328  
1329 C<page> - Page number
1330  
1331 =back
1332  
1333 =head5 account_images
1334  
1335 $resp = $client->account_images($username, \%opts);
1336  
1337 Valid C<\%opts> keys are:
1338  
1339 =over 4
1340  
1341 =item *
1342  
1343 C<page> - Page number
1344  
1345 =back
1346  
1347 =head5 account_reply_notifications
1348  
1349 $resp = $client->account_reply_notifications($username, \%opts);
1350  
1351 Valid C<\%opts> keys are:
1352  
1353 =over 4
1354  
1355 =item *
1356  
1357 C<new> - Boolean value. True for unviewed notifications and false for viewed notifications.
1358  
1359 =back
1360  
1361 =head5 account_settings
1362  
1363 $resp = $client->account_settings($username);
1364  
1365 Get account settings for a given username.
1366  
1367 =head5 account_settings_update
1368  
1369 $resp = $client->account_settings_update($username, \%opts);
1370  
1371 Update an account's settings.
1372  
1373 Valid C<\%opts> keys are:
1374  
1375 =over 4
1376  
1377 =item *
1378  
1379 C<bio> - A string for the bio.
1380  
1381 =item *
1382  
1383 C<public_images> - A boolean value to set images to public or not by default.
1384  
1385 =item *
1386  
1387 C<messaging_enabled> - A boolean value to allow messaging or not.
1388  
1389 =item *
1390  
1391 C<accepted_gallery_terms> - A boolean value to accept the gallery terms.
1392  
1393 =item *
1394  
1395 C<username> - A valid username between 4 and 63 alphanumeric characters.
1396  
1397 =item *
1398  
1399 C<show_mature> - A boolean value to show mature images in gallery list endpoints.
1400  
1401 =item *
1402  
1403 C<newsletter_subscribed> - A boolean value, true to subscribe to the newsletter, false to unsubscribe from the newsletter.
1404  
1405 =back
1406  
1407 =head5 account_submissions
1408  
1409 $resp = $client->account_submissions($username, \%opts);
1410  
1411 Valid C<\%opts> keys are:
1412  
1413 =over 4
1414  
1415 =item *
1416  
1417 C<page> - Page number
1418  
1419 =back
1420  
1421 =head5 account_tag_follow
1422  
1423 $resp = $client->account_tag_follow($tag);
1424  
1425 Follow a tag.
1426  
1427 =head5 account_tag_unfollow
1428  
1429 $resp = $client->account_tag_unfollow($tag);
1430  
1431 Unfollow a tag.
1432  
1433 =head5 account_verify_email_send
1434  
1435 $resp = $client->account_verify_email_send($username);
1436  
1437 Send a verification email.
1438  
1439 =head5 account_verify_email_status
1440  
1441 $resp = $client->account_verify_email_status($username);
1442  
1443 Get the status of the verification email.
1444  
1445 =head4 ALBUM
1446  
1447 =head5 album
1448  
1449 $resp = $client->album($album_id);
1450  
1451 Get information about a specific album.
1452  
1453 =head5 album_create
1454  
1455 $resp = $client->album_create(\%opts);
1456  
1457 =over 4
1458  
1459 =item *
1460  
1461 C<ids> - Array reference of image ids.
1462  
1463 =item *
1464  
1465 C<title> - Title of the album.
1466  
1467 =item *
1468  
1469 C<description> - Description of the album.
1470  
1471 =item *
1472  
1473 C<cover> - Image id of the cover image.
1474  
1475 =back
1476  
1477 =head5 album_delete
1478  
1479 $resp = $client->album_delete($album_id);
1480  
1481 Delete an album.
1482  
1483 =head5 album_favorite
1484  
1485 $resp = $client->album_favorite($album_id);
1486  
1487 Favorite an album.
1488  
1489 =head5 album_image
1490  
1491 $resp = $client->album_image($album_id, $image_id);
1492  
1493 Get information about a specific image in an album.
1494  
1495 =head5 album_images
1496  
1497 $resp = $client->album_images($album_id);
1498  
1499 Get all the images in an album.
1500  
1501 =head5 album_images_add
1502  
1503 $resp = $client->album_images_add($album_id, \@image_ids);
1504  
1505 Add images to an album.
1506  
1507 =head5 album_images_delete
1508  
1509 $resp = $client->album_images_delete($album_id, \@image_ids);
1510  
1511 Delete images from an album.
1512  
1513 =head5 album_images_set
1514  
1515 $resp = $client->album_images_set($album_id, \@image_ids);
1516  
1517 Set the images for an album.
1518  
1519 =head5 album_update
1520  
1521 $resp = $client->album_update($album_id, \%opts);
1522  
1523 Update an album. Valid C<\%opts> keys are:
1524  
1525 =over 4
1526  
1527 =item *
1528  
1529 C<ids> - Array reference of image ids.
1530  
1531 =item *
1532  
1533 C<title> - Title of the album.
1534  
1535 =item *
1536  
1537 C<description> - Description of the album.
1538  
1539 =item *
1540  
1541 C<cover> - Image id of the cover image.
1542  
1543 =back
1544  
1545 =head4 COMMENT
1546  
1547 =head5 comment
1548  
1549 $resp = $client->comment($comment_id);
1550  
1551 Get information about a specific comment.
1552  
1553 =head5 comment_create
1554  
1555 $resp = $client->comment_create($image_id, $comment);
1556  
1557 Create a new comment on an image.
1558  
1559 =head5 comment_delete
1560  
1561 $resp = $client->comment_delete($comment_id);
1562  
1563 Delete a comment.
1564  
1565 =head5 comment_replies
1566  
1567 $resp = $client->comment_replies($comment_id);
1568  
1569 Get the replies for a specific comment.
1570  
1571 =head5 comment_reply
1572  
1573 $resp = $client->comment_reply($image_id, $comment_id, $comment);
1574  
1575 Create a new reply to a comment.
1576  
1577 =head5 comment_report
1578  
1579 $resp = $client->comment_report($comment_id, $reason);
1580  
1581 Report a comment with a reason. Valid reasons are:
1582  
1583 =over 4
1584  
1585 =item *
1586  
1587 C<1> - Doesn't belong on Imgur
1588  
1589 =item *
1590  
1591 C<2> - Spam
1592  
1593 =item *
1594  
1595 C<3> - Abusive
1596  
1597 =item *
1598  
1599 C<4> - Mature content not marked as mature
1600  
1601 =item *
1602  
1603 C<5> - Pornography
1604  
1605 =back
1606  
1607 =head5 comment_vote
1608  
1609 $resp = $client->comment_vote($comment_id, $vote);
1610  
1611 Cast a vote on a comment. Valid vote values are C<up>, C<down> and C<veto>.
1612  
1613 =head4 GALLERY
1614  
1615 =head5 gallery
1616  
1617 $resp = $client->gallery(\%opts);
1618  
1619 Get gallery images.
1620  
1621 Validation options are:
1622  
1623 =over 4
1624  
1625 =item *
1626  
1627 C<section> - Section. Options are C<hot> (default), C<top> and C<user>.
1628  
1629 =item *
1630  
1631 C<sort> - Sort order. Options are C<viral> (default), C<top>, C<time>, C<rising>.
1632  
1633 =item *
1634  
1635 C<page> - Page number.
1636  
1637 =item *
1638  
1639 C<window> - Time window. Options are C<day>, C<week>, C<month>, C<year>, C<all>.
1640  
1641 =item *
1642  
1643 C<show_viral> - Show or hide viral images in the gallery. Default is C<1>.
1644  
1645 =item *
1646  
1647 C<album_previews> - Show or hide album previews in the gallery. Default is C<1>.
1648  
1649 =back
1650  
1651 =head5 gallery_album
1652  
1653 $resp = $client->gallery_album($album_id);
1654  
1655 Get additional information about an album in the gallery.
1656  
1657  
1658 Get information about a specific gallery album.
1659  
1660 =head5 gallery_image
1661  
1662 $resp = $client->gallery_image($image_id);
1663  
1664 Get additional information about an image in the gallery.
1665  
1666 =head5 gallery_item_comment
1667  
1668 $resp = $client->gallery_item_comment($item_id, $comment);
1669  
1670 Create a new comment on a gallery item.
1671  
1672 =head5 gallery_item_comment_info
1673  
1674 $resp = $client->gallery_item_comment_info($item_id, $comment_id);
1675  
1676 Get information about a specific comment on a gallery item.
1677  
1678 =head5 gallery_item_comments
1679  
1680 $resp = $client->gallery_item_comments($item_id);
1681  
1682 Get all the comments on a gallery item.
1683  
1684 =head5 gallery_item_report
1685  
1686 $resp = $client->gallery_item_report($item_id, \%opts);
1687  
1688 Report an Image in the gallery
1689  
1690  
1691 Report a gallery item. Valid C<\%opts> keys are:
1692  
1693 =over 4
1694  
1695 =item *
1696  
1697 C<reason> - Reason for reporting the item. Options are C<1> (doesn't belong on Imgur), C<2> (spam), C<3> (abusive), C<4> (mature content not marked as mature), C<5> (pornography).
1698  
1699 =back
1700  
1701 =head5 gallery_item_tags
1702  
1703 $resp = $client->gallery_item_tags($item_id);
1704  
1705 Get the tags for a gallery item.
1706  
1707 =head5 gallery_item_tags_update
1708  
1709 $resp = $client->gallery_item_tags_update($item_id, \@tags);
1710  
1711 Update the tags for a gallery item.
1712  
1713 =head5 gallery_item_vote
1714  
1715 $resp = $client->gallery_item_vote($item_id, $vote);
1716  
1717 Cast a vote on a gallery item. Valid vote values are C<up>, C<down> and C<veto>.
1718  
1719 =head5 gallery_item_votes
1720  
1721 $resp = $client->gallery_item_votes($item_id);
1722  
1723 Get the votes for a gallery item.
1724  
1725 =head5 gallery_image_remove
1726  
1727 $resp = $client->gallery_image_remove($image_id);
1728  
1729 Remove an image from the gallery.
1730  
1731 =head5 gallery_search
1732  
1733 $resp = $client->gallery_search(\%opts);
1734  
1735 Search the gallery. Valid C<\%opts> keys are:
1736  
1737 =over 4
1738  
1739 =item *
1740  
1741 C<q> - Query string (ignored if C<advanced> is set).
1742  
1743 =item *
1744  
1745 C<sort> - Sort order. Options are C<time> (default), C<viral>, C<top>, C<rising>.
1746  
1747 =item *
1748  
1749 C<window> - Time window. Options are C<all> (default), C<day>, C<week>, C<month>, C<year>.
1750  
1751 =item *
1752  
1753 C<page> - Page number.
1754  
1755 =item *
1756  
1757 C<adv> - Advanced search options
1758  
1759 =over 4
1760  
1761 =item *
1762  
1763 C<q_all> - Search for all of these words.
1764  
1765 =item *
1766  
1767 C<q_any> - Search for any of these words.
1768  
1769 =item *
1770  
1771 C<q_exactly> - Search for exactly this word or phrase.
1772  
1773 =item *
1774  
1775 C<q_not> - Exclude results matching this.
1776  
1777 =item *
1778  
1779 C<q_type> - Show results for any file type, or specific file types. C<jpg>, C<png>, C<gif>, C<anigif> (animated gif), C<album>.
1780  
1781 =item *
1782  
1783 C<q_size_px> - Return images that are greater or equal to the width/height you specify. C<300x300>.
1784  
1785 =back
1786  
1787 =back
1788  
1789 =head5 gallery_share_image
1790  
1791 $resp = $client->gallery_share_image($image_id, $title, \%opts);
1792  
1793 Share an image. Valid C<\%opts> keys are:
1794  
1795 =over 4
1796  
1797 =item *
1798  
1799 C<topic> - Topic of the shared image.
1800  
1801 =item *
1802  
1803 C<terms> - Terms of the shared image.
1804  
1805 =item *
1806  
1807 C<mature> - Boolean value to mark the shared image as mature.
1808  
1809 =item *
1810  
1811 C<tags> - Array reference of tags for the shared image.
1812  
1813 =back
1814  
1815 =head5 gallery_share_album
1816  
1817 $resp = $client->gallery_share_album($album_id, $title, \%opts);
1818  
1819 Share an album. Valid C<\%opts> keys are:
1820  
1821 =over 4
1822  
1823 =item *
1824  
1825 C<topic> - Topic of the shared image.
1826  
1827 =item *
1828  
1829 C<terms> - Terms of the shared image.
1830  
1831 =item *
1832  
1833 C<mature> - Boolean value to mark the shared image as mature.
1834  
1835 =item *
1836  
1837 C<tags> - Array reference of tags for the shared image.
1838  
1839 =back
1840  
1841 =head5 gallery_subreddit
1842  
1843 $resp = $client->gallery_subreddit($subreddit, \%opts);
1844  
1845 Get images from a subreddit.
1846  
1847 C<$subreddit> is the name of the subreddit to get images from.
1848  
1849 Valid C<\%opts> keys are:
1850  
1851 =over 4
1852  
1853 =item *
1854  
1855 C<sort> - Sort order. Options are C<viral> (default), C<time>, C<top> and C<rising>.
1856  
1857 =item *
1858  
1859 C<page> - Page number (default is 0)
1860  
1861 =item *
1862  
1863 C<window> - Window of time. Options are C<day>, C<week> (default), C<month>, C<year>, C<all>.
1864 I can't wait until NY AG starts seizing trumps assets starting monday
1865  
1866 =back
1867  
1868 =head5 gallery_subreddit_image
1869  
1870 $resp = $client->gallery_subreddit_image('subreddit', $image_id);
1871  
1872 =head5 gallery_tag
1873  
1874 $resp = $client->gallery_tag($tag, \%opts);
1875  
1876 Returns tag metadata, and posts tagged with the C<$tag> provided
1877  
1878 =over 4
1879  
1880 =item *
1881  
1882 C<sort> - Sort order. Options are C<viral> (default), C<time>, C<top> and C<rising>.
1883  
1884 =item *
1885  
1886 C<page> - Page number (default is 0)
1887  
1888 =item *
1889  
1890 C<window> - Window of time. Options are C<day>, C<week> (default), C<month>, C<year>, C<all>.
1891 I can't wait until NY AG starts seizing trumps assets starting monday
1892  
1893 =back
1894  
1895 =head5 gallery_tag_info
1896  
1897 $resp = $client->gallery_tag_info($tag);
1898  
1899 Get gallery tag information.
1900  
1901 =head5 gallery_tags
1902  
1903 $resp = $client->gallery_tags;
1904  
1905 Gets a list of default tags
1906  
1907 =head4 IMAGE
1908  
1909 =head5 image
1910  
1911 $resp = $client->image($image_id);
1912  
1913 Get information about a specific image.
1914  
1915 =head5 image_upload
1916  
1917 $resp = $client->image_upload($src, $type, \%opts);
1918  
1919 Upload an image or video to imgur.
1920  
1921 C<$src> Path, URL or Base64 encoding of the image or video file.
1922 C<$type> Content type can be either C<file>, C<url> or C<base64>.
1923  
1924 Valid C<\%opts> keys are:
1925  
1926 =over 4
1927  
1928 =item *
1929  
1930 C<title> - Title of the image.
1931  
1932 =item *
1933  
1934 C<description> - Description of the image.
1935  
1936 =back
1937  
1938 =head5 image_delete
1939  
1940 $resp = $client->image_delete($image_id);
1941  
1942 Delete an image.
1943  
1944 =head5 image_favorite
1945  
1946 $resp = $client->image_favorite($image_id);
1947  
1948 Favorite an image.
1949  
1950 =head5 image_update
1951  
1952 $resp = $client->image_update($image_id, \%opts);
1953  
1954 Update an image.
1955  
1956 Valid C<\%opts> keys are:
1957  
1958 =over 4
1959  
1960 =item *
1961  
1962 C<title> - Title of the image.
1963  
1964 =item *
1965  
1966 C<description> - Description of the image.
1967  
1968 =back
1969  
1970 =head4 FEED
1971  
1972 =head5 feed
1973  
1974 $resp = $client->feed;
1975  
1976 Get the authenticated user's feed.
1977  
1978 =head1 AUTHOR
1979  
1980 Dillan Hildebrand
1981  
1982 =head1 LICENSE
1983  
1984 MIT
1985  
1986 =cut
1987  
1988 1 1;
↑ Summary