API/Endpoint/OAuth.pm untested

filter: Statementstmt 0.0% 0 / 21 Branchbran n/a Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 31 CC 1 SCAR 6.9
CC
1
Cov
0%
auth_url
2.0
token
2.0
BEGIN
2.0
CRAP 2.0
1 package Imgur::API::Endpoint::OAuth;
2  
3 use strict;
4 use Mouse;
5 use feature qw(say);
6 extends 'Imgur::API::Endpoint';
7  
8 sub auth_url {
9 my ($this,%options) = @_;
10  
11 $options{state}||='';
12  
13 return $this->path("oauth2/authorize",[],[],{})."?response_type=$options{grant_type}&client_id=".$this->dispatcher->client_id."&state=$options{state}";
14 }
15  
16  
17 sub token {
18 my ($this,%p) = @_;
19  
20 $p{client_id} = $this->dispatcher->client_id;
21 $p{client_secret} = $this->dispatcher->client_secret;
22  
23  
24 my $url = $this->path("oauth2/token",[],[],\%p);
25  
26 say $url;
27
28 return $this->dispatcher->request($url,'post',\%p);
29
30 }
31  
32 1;
33 __PACKAGE__->meta->make_immutable;
34