| 1 | package Net::Async::Trello; | ||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Interaction with the trello.com API | ||||||||||||||||||||||||||||||||||||||
| 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 parent qw(IO::Async::Notifier); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||
| 9 | 1 | our $VERSION = '0.007'; | |||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||
| 11 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||
| 13 | Net::Async::Trello - low-level Trello API access | ||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||
| 15 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||
| 17 | Provides a basic interface for interacting with the L<Trello|https://trello.com> webservice. | ||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||
| 19 | It's currently a very crude implementation, implementing a small subset of the available API | ||||||||||||||||||||||||||||||||||||||
| 20 | features. | ||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||
| 22 | =cut | ||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||
| 24 | 1 | ▶ | no indirect; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | use overload '""' => sub { 'Net::Async::Trello' }, bool => sub { 1 }, fallback => 1; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.6
Subroutine
__ANON__: not called CC=1 SCAR=0.6
Subroutine
__ANON__: not called CC=1 SCAR=0.6
| |||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||
| 28 | 1 | ▶ | use Dir::Self; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 29 | 1 | ▶ | use curry; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 30 | 1 | ▶ | use Future; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 31 | 1 | ▶ | use Future::Utils qw(try_repeat); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 32 | 1 | ▶ | use URI; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 33 | 1 | ▶ | use URI::QueryParam; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 34 | 1 | ▶ | use URI::Template; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 35 | 1 | ▶ | use URI::wss; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 36 | 1 | ▶ | use HTTP::Request; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||
| 38 | 1 | ▶ | use JSON::MaybeUTF8 qw(:v1); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 39 | 1 | ▶ | use Syntax::Keyword::Try; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||
| 41 | 1 | ▶ | use File::ShareDir (); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 42 | 1 | ▶ | use Log::Any qw($log); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 43 | 1 | ▶ | use Path::Tiny (); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||
| 45 | 1 | ▶ | use IO::Async::SSL; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||
| 47 | 1 | ▶ | use Net::Async::OAuth::Client; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||
| 49 | 1 | ▶ | use Net::Async::Trello::WS; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||
| 51 | 1 | ▶ | use Net::Async::Trello::Organisation; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 52 | 1 | ▶ | use Net::Async::Trello::Member; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 53 | 1 | ▶ | use Net::Async::Trello::Board; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 54 | 1 | ▶ | use Net::Async::Trello::Card; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 55 | 1 | ▶ | use Net::Async::Trello::CardAction; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 56 | 1 | ▶ | use Net::Async::Trello::List; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||
| 58 | 1 | ▶ | use Ryu::Async; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 59 | 1 | ▶ | use Adapter::Async::OrderedList::Array; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||
| 61 | =head2 me | ||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||
| 63 | Returns profile information for the current user. | ||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||
| 65 | =cut | ||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | sub me { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
me: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 68 | 0 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||
| 69 | $self->http_get( | ||||||||||||||||||||||||||||||||||||||
| 70 | uri => URI->new($self->base_uri . 'members/me') | ||||||||||||||||||||||||||||||||||||||
| 71 | )->transform( | ||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | done => sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 73 | Net::Async::Trello::Member->new( | ||||||||||||||||||||||||||||||||||||||
| 74 | 0 | %{ $_[0] }, | |||||||||||||||||||||||||||||||||||||
| 75 | trello => $self, | ||||||||||||||||||||||||||||||||||||||
| 76 | ) | ||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||
| 78 | ) | ||||||||||||||||||||||||||||||||||||||
| 79 | 0 | } | |||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||
| 81 | =head2 boards | ||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||
| 83 | Returns a L<Ryu::Source> representing the available boards. | ||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||
| 85 | =cut | ||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | sub boards { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
boards: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 88 | 0 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||
| 89 | 0 | $self->api_get_list( | |||||||||||||||||||||||||||||||||||||
| 90 | endpoint => 'boards', | ||||||||||||||||||||||||||||||||||||||
| 91 | class => 'Net::Async::Trello::Board', | ||||||||||||||||||||||||||||||||||||||
| 92 | ) | ||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||
| 95 | =head2 board | ||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||
| 97 | Resolves to the board with the corresponding ID. | ||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||
| 99 | Takes the following named parameters: | ||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||
| 101 | =over 4 | ||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||
| 103 | =item * id - the board ID to request | ||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||
| 105 | =back | ||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||
| 107 | Returns a L<Future>. | ||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||
| 109 | =cut | ||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | sub board { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
board: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 112 | 0 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||
| 113 | 0 | my $id = delete $args{id}; | |||||||||||||||||||||||||||||||||||||
| 114 | 0 | my $uri = URI->new($self->base_uri . 'board/' . $id); | |||||||||||||||||||||||||||||||||||||
| 115 | 0 | $uri->query_param($_ => $args{$_}) for keys %args; | |||||||||||||||||||||||||||||||||||||
| 116 | $self->http_get( | ||||||||||||||||||||||||||||||||||||||
| 117 | uri => $uri | ||||||||||||||||||||||||||||||||||||||
| 118 | )->transform( | ||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | done => sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 120 | Net::Async::Trello::Board->new( | ||||||||||||||||||||||||||||||||||||||
| 121 | 0 | %{ $_[0] }, | |||||||||||||||||||||||||||||||||||||
| 122 | trello => $self, | ||||||||||||||||||||||||||||||||||||||
| 123 | ) | ||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||
| 125 | ) | ||||||||||||||||||||||||||||||||||||||
| 126 | 0 | } | |||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||
| 128 | =head2 card | ||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||
| 130 | Returns information about a specific card. | ||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||
| 132 | Takes the following named parameters: | ||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||
| 134 | =over 4 | ||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||
| 136 | =item * C<id> - the card ID to retrieve | ||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||
| 138 | =back | ||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||
| 140 | Resolves to a L<Net::Async::Trello::Card> instance. | ||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||
| 142 | =cut | ||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | sub card { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
card: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 145 | 0 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||
| 146 | 0 | my $id = delete $args{id}; | |||||||||||||||||||||||||||||||||||||
| 147 | 0 | my $uri = URI->new($self->base_uri . 'cards/' . $id); | |||||||||||||||||||||||||||||||||||||
| 148 | 0 | $uri->query_param($_ => delete $args{$_}) for keys %args; | |||||||||||||||||||||||||||||||||||||
| 149 | $self->http_get( | ||||||||||||||||||||||||||||||||||||||
| 150 | uri => $uri, | ||||||||||||||||||||||||||||||||||||||
| 151 | )->transform( | ||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | done => sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 153 | Net::Async::Trello::Card->new( | ||||||||||||||||||||||||||||||||||||||
| 154 | 0 | %{ $_[0] }, | |||||||||||||||||||||||||||||||||||||
| 155 | trello => $self, | ||||||||||||||||||||||||||||||||||||||
| 156 | ) | ||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||
| 158 | ) | ||||||||||||||||||||||||||||||||||||||
| 159 | 0 | } | |||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||
| 161 | =head2 member | ||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||
| 163 | Returns information about a specific person (board/card member). | ||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||
| 165 | Takes the following named parameters: | ||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||
| 167 | =over 4 | ||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||
| 169 | =item * C<id> - the ID to retrieve | ||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||
| 171 | =back | ||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||
| 173 | Resolves to a L<Net::Async::Trello::Member> instance. | ||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||
| 175 | =cut | ||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | sub member { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
member: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 178 | 0 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||
| 179 | 0 | my $id = delete $args{id}; | |||||||||||||||||||||||||||||||||||||
| 180 | $self->http_get( | ||||||||||||||||||||||||||||||||||||||
| 181 | uri => URI->new($self->base_uri . 'members/' . $id) | ||||||||||||||||||||||||||||||||||||||
| 182 | )->transform( | ||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | done => sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 184 | Net::Async::Trello::Member->new( | ||||||||||||||||||||||||||||||||||||||
| 185 | 0 | %{ $_[0] }, | |||||||||||||||||||||||||||||||||||||
| 186 | trello => $self, | ||||||||||||||||||||||||||||||||||||||
| 187 | ) | ||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||
| 189 | ) | ||||||||||||||||||||||||||||||||||||||
| 190 | 0 | } | |||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||
| 192 | =head2 search | ||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||
| 194 | Performs a search for Trello objects by string, see L<https://developers.trello.com/reference/#search> | ||||||||||||||||||||||||||||||||||||||
| 195 | for details on search options available. | ||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||
| 197 | Example: | ||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||
| 199 | my (%result) = await $trello->search( | ||||||||||||||||||||||||||||||||||||||
| 200 | card_fields => [ qw(name url dateLastActivity) ], | ||||||||||||||||||||||||||||||||||||||
| 201 | query => 'Shopping List', | ||||||||||||||||||||||||||||||||||||||
| 202 | ); | ||||||||||||||||||||||||||||||||||||||
| 203 | # print the url of the first card returned. | ||||||||||||||||||||||||||||||||||||||
| 204 | my $card = $result{cards}->[0]; | ||||||||||||||||||||||||||||||||||||||
| 205 | # This should be a Net::Async::Trello::Card instance, so we have a ->url method: | ||||||||||||||||||||||||||||||||||||||
| 206 | printf "Card %s url\n", $card->url; | ||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||
| 208 | Takes the arguments as shown in the Trello API documentation as named parameters. | ||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||
| 210 | The only compulsory argument is C<query>, the text string to search for. | ||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||
| 212 | Returns a L<Future> which resolves to a list of key-value pairs. | ||||||||||||||||||||||||||||||||||||||
| 213 | The value will be an instance of the appropriate | ||||||||||||||||||||||||||||||||||||||
| 214 | type, with the exception of C<options> which is a plain hashref. | ||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||
| 216 | =cut | ||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | sub search { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
search: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 219 | 0 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||
| 220 | 0 | my $uri = $self->endpoint( | |||||||||||||||||||||||||||||||||||||
| 221 | 'search', | ||||||||||||||||||||||||||||||||||||||
| 222 | ); | ||||||||||||||||||||||||||||||||||||||
| 223 | 0 | $uri->query_param($_ => $args{$_}) for keys %args; | |||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||
| 225 | $self->http_get( | ||||||||||||||||||||||||||||||||||||||
| 226 | uri => $uri, | ||||||||||||||||||||||||||||||||||||||
| 227 | )->transform( | ||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | done => sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||
| 229 | 0 | my ($results) = @_; | |||||||||||||||||||||||||||||||||||||
| 230 | my %types = ( | ||||||||||||||||||||||||||||||||||||||
| 231 | 0 | options => delete($results->{options}), | |||||||||||||||||||||||||||||||||||||
| 232 | ); | ||||||||||||||||||||||||||||||||||||||
| 233 | 0 | for my $type (keys(%{$results})) { | |||||||||||||||||||||||||||||||||||||
| 234 | # Drop the trailing `s` and hope that we don't run into English issues... | ||||||||||||||||||||||||||||||||||||||
| 235 | 0 | my $module_postfix = ucfirst($type =~ s{s$}{}r); | |||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||
| 237 | 0 | $types{$type} = []; | |||||||||||||||||||||||||||||||||||||
| 238 | 0 | for my $item (@{$results->{$type}}) { | |||||||||||||||||||||||||||||||||||||
| 239 | 0 | my $class = 'Net::Async::Trello::' . $module_postfix; | |||||||||||||||||||||||||||||||||||||
| 240 | my $object = $class->new( | ||||||||||||||||||||||||||||||||||||||
| 241 | trello => $self, | ||||||||||||||||||||||||||||||||||||||
| 242 | 0 | %{$item}, | |||||||||||||||||||||||||||||||||||||
| 243 | ); | ||||||||||||||||||||||||||||||||||||||
| 244 | 0 | push @{$types{$type}}, $object; | |||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||
| 247 | 0 | return %types; | |||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||
| 249 | ) | ||||||||||||||||||||||||||||||||||||||
| 250 | 0 | } | |||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | sub configure { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
configure: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 253 | 0 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||
| 254 | 0 | for my $k (grep exists $args{$_}, qw(key secret token token_secret ws_token)) { | |||||||||||||||||||||||||||||||||||||
| 255 | 0 | $self->{$k} = delete $args{$k}; | |||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||
| 257 | 0 | $self->SUPER::configure(%args); | |||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | sub ws_token { shift->{ws_token} } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
ws_token: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | sub key { shift->{key} } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
key: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | sub secret { shift->{secret} } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
secret: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | sub token { shift->{token} } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
token: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | sub token_secret { shift->{token_secret} } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
token_secret: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | sub http { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
http: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 268 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | $self->{http} ||= do { | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"http"} ||= do {
require Net::Async::HTTP;
$self->add_child(my $ua = "Net::Async::HTTP"->new("fail_on_error", 1, "close_after_request", 0, "max_connections_per_host", 2, "pipeline", 1, "max_in_flight", 4, "decode_content", 1, "stall_timeout", 15, "user_agent", "Mozilla/4.0 (perl; Net::Async::Trello; TEAM\@cpan.org)"));
$ua
}
MC/DC0%0/2
$self->{"http"} ||= do {
require Net::Async::HTTP;
$self->add_child(my $ua = "Net::Async::HTTP"->new("fail_on_error", 1, "close_after_request", 0, "max_connections_per_host", 2, "pipeline", 1, "max_in_flight", 4, "decode_content", 1, "stall_timeout", 15, "user_agent", "Mozilla/4.0 (perl; Net::Async::Trello; TEAM\@cpan.org)"));
$ua
}
$self->{"http"}
do {
require Net::Async::HTTP;
$self->add_child(my $ua = "Net::Async::HTTP"->new("fail_on_error", 1, "close_after_request", 0, "max_connections_per_host", 2, "pipeline", 1, "max_in_flight", 4, "decode_content", 1, "stall_timeout", 15, "user_agent", "Mozilla/4.0 (perl; Net::Async::Trello; TEAM\@cpan.org)"));
$ua
}
Truth table0%0/3
A ||= B
A= $self->{"http"}B= do {
require Net::Async::HTTP;
$self->add_child(my $ua = "Net::Async::HTTP"->new("fail_on_error", 1, "close_after_request", 0, "max_connections_per_host", 2, "pipeline", 1, "max_in_flight", 4, "decode_content", 1, "stall_timeout", 15, "user_agent", "Mozilla/4.0 (perl; Net::Async::Trello; TEAM\@cpan.org)"));
$ua
}
| |||||||||||||||||||||||||||||||||||||||
| 270 | 0 | require Net::Async::HTTP; | |||||||||||||||||||||||||||||||||||||
| 271 | 0 | $self->add_child( | |||||||||||||||||||||||||||||||||||||
| 272 | my $ua = Net::Async::HTTP->new( | ||||||||||||||||||||||||||||||||||||||
| 273 | fail_on_error => 1, | ||||||||||||||||||||||||||||||||||||||
| 274 | close_after_request => 0, | ||||||||||||||||||||||||||||||||||||||
| 275 | max_connections_per_host => 2, | ||||||||||||||||||||||||||||||||||||||
| 276 | pipeline => 1, | ||||||||||||||||||||||||||||||||||||||
| 277 | max_in_flight => 4, | ||||||||||||||||||||||||||||||||||||||
| 278 | decode_content => 1, | ||||||||||||||||||||||||||||||||||||||
| 279 | stall_timeout => 15, | ||||||||||||||||||||||||||||||||||||||
| 280 | user_agent => 'Mozilla/4.0 (perl; Net::Async::Trello; TEAM@cpan.org)', | ||||||||||||||||||||||||||||||||||||||
| 281 | ) | ||||||||||||||||||||||||||||||||||||||
| 282 | ); | ||||||||||||||||||||||||||||||||||||||
| 283 | 0 | $ua | |||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||
| 287 | =head1 METHODS - Internal | ||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||
| 289 | None of these are likely to be stable or of much use to external callers. | ||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||
| 291 | =cut | ||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | sub base_uri { shift->{base_uri} //= URI->new('https://api.trello.com/1/') } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
base_uri: not called CC=2 SCAR=17.9
Pod
undocumented
Condition0%0/3
+(shift())->{"base_uri"} //= "URI"->new("https://api.trello.com/1/")
MC/DC0%0/2
+(shift())->{"base_uri"} //= "URI"->new("https://api.trello.com/1/")
+(shift())->{"base_uri"}
"URI"->new("https://api.trello.com/1/")
Truth table0%0/3
A //= B
A= +(shift())->{"base_uri"}B= "URI"->new("https://api.trello.com/1/")
| |||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | sub mime_type { shift->{mime_type} //= 'application/json' } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
mime_type: not called CC=2 SCAR=17.9
Pod
undocumented
Condition0%0/2
+(shift())->{"mime_type"} //= "application/json"
MC/DC0%0/1
+(shift())->{"mime_type"} //= "application/json"
+(shift())->{"mime_type"}
Truth table0%0/2
A
A= +(shift())->{"mime_type"}
| |||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | sub oauth { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
oauth: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 298 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | $self->{oauth} //= Net::Async::OAuth::Client->new( | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"oauth"} //= "Net::Async::OAuth::Client"->new("realm", "Trello", "consumer_key", $self->key, "consumer_secret", $self->secret, "token", $self->token, "token_secret", $self->token_secret)
MC/DC0%0/2
$self->{"oauth"} //= "Net::Async::OAuth::Client"->new("realm", "Trello", "consumer_key", $self->key, "consumer_secret", $self->secret, "token", $self->token, "token_secret", $self->token_secret)
$self->{"oauth"}
"Net::Async::OAuth::Client"->new("realm", "Trello", "consumer_key", $self->key, "consumer_secret", $self->secret, "token", $self->token, "token_secret", $self->token_secret)
Truth table0%0/3
A //= B
A= $self->{"oauth"}B= "Net::Async::OAuth::Client"->new("realm", "Trello", "consumer_key", $self->key, "consumer_secret", $self->secret, "token", $self->token, "token_secret", $self->token_secret)
| |||||||||||||||||||||||||||||||||||||||
| 300 | realm => 'Trello', | ||||||||||||||||||||||||||||||||||||||
| 301 | consumer_key => $self->key, | ||||||||||||||||||||||||||||||||||||||
| 302 | consumer_secret => $self->secret, | ||||||||||||||||||||||||||||||||||||||
| 303 | token => $self->token, | ||||||||||||||||||||||||||||||||||||||
| 304 | token_secret => $self->token_secret, | ||||||||||||||||||||||||||||||||||||||
| 305 | ) | ||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||
| 308 | =head2 endpoints | ||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||
| 310 | =cut | ||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | sub endpoints { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
endpoints: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 313 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | $self->{endpoints} ||= do { | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"endpoints"} ||= do {
my $path = Path::Tiny::path(&__DIR__())->parent(3)->child("share/endpoints.json");
$path = Path::Tiny::path(File::ShareDir::dist_file("Net-Async-Trello", "endpoints.json")) unless $path->exists;
decode_json_text($path->slurp_utf8)
}
MC/DC0%0/2
$self->{"endpoints"} ||= do {
my $path = Path::Tiny::path(&__DIR__())->parent(3)->child("share/endpoints.json");
$path = Path::Tiny::path(File::ShareDir::dist_file("Net-Async-Trello", "endpoints.json")) unless $path->exists;
decode_json_text($path->slurp_utf8)
}
$self->{"endpoints"}
do {
my $path = Path::Tiny::path(&__DIR__())->parent(3)->child("share/endpoints.json");
$path = Path::Tiny::path(File::ShareDir::dist_file("Net-Async-Trello", "endpoints.json")) unless $path->exists;
decode_json_text($path->slurp_utf8)
}
Truth table0%0/3
A ||= B
A= $self->{"endpoints"}B= do {
my $path = Path::Tiny::path(&__DIR__())->parent(3)->child("share/endpoints.json");
$path = Path::Tiny::path(File::ShareDir::dist_file("Net-Async-Trello", "endpoints.json")) unless $path->exists;
decode_json_text($path->slurp_utf8)
}
| |||||||||||||||||||||||||||||||||||||||
| 315 | 0 | my $path = Path::Tiny::path(__DIR__)->parent(3)->child('share/endpoints.json'); | |||||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | $path = Path::Tiny::path( | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 317 | File::ShareDir::dist_file( | ||||||||||||||||||||||||||||||||||||||
| 318 | 'Net-Async-Trello', | ||||||||||||||||||||||||||||||||||||||
| 319 | 'endpoints.json' | ||||||||||||||||||||||||||||||||||||||
| 320 | ) | ||||||||||||||||||||||||||||||||||||||
| 321 | ) unless $path->exists; | ||||||||||||||||||||||||||||||||||||||
| 322 | 0 | decode_json_text($path->slurp_utf8) | |||||||||||||||||||||||||||||||||||||
| 323 | }; | ||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||
| 326 | =head2 endpoint | ||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||
| 328 | =cut | ||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | sub endpoint { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
endpoint: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 331 | 0 | my ($self, $endpoint, %args) = @_; | |||||||||||||||||||||||||||||||||||||
| 332 | URI::Template->new( | ||||||||||||||||||||||||||||||||||||||
| 333 | 0 | $self->endpoints->{$endpoint . '_url'} | |||||||||||||||||||||||||||||||||||||
| 334 | )->process(%args); | ||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | sub http_get { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
http_get: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 338 | 0 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||
| 340 | $args{headers}{Authorization} = $self->oauth->authorization_header( | ||||||||||||||||||||||||||||||||||||||
| 341 | method => 'GET', | ||||||||||||||||||||||||||||||||||||||
| 342 | uri => $args{uri} | ||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ); | |||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||
| 345 | 0 | $log->tracef("GET %s { %s }", ''. $args{uri}, \%args); | |||||||||||||||||||||||||||||||||||||
| 346 | 0 | my $uri = delete $args{uri}; | |||||||||||||||||||||||||||||||||||||
| 347 | 0 | my $count; | |||||||||||||||||||||||||||||||||||||
| 348 | 0 | ▶ | (try_repeat { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 349 | 0 | $self->http->GET( | |||||||||||||||||||||||||||||||||||||
| 350 | $uri, | ||||||||||||||||||||||||||||||||||||||
| 351 | %args | ||||||||||||||||||||||||||||||||||||||
| 352 | ) | ||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | } until => sub { shift->is_done or $count++ > 3 })->then(sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Subroutine
__ANON__: not called CC=3 SCAR=24.8
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 354 | 0 | my ($resp) = @_; | |||||||||||||||||||||||||||||||||||||
| 355 | 0 | $log->tracef("%s => %s", $args{uri}, $resp->decoded_content); | |||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | return { } if $resp->code == 204; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | return { } if 3 == ($resp->code / 100); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 358 | try { | ||||||||||||||||||||||||||||||||||||||
| 359 | 0 | return Future->done(decode_json_utf8($resp->content)) | |||||||||||||||||||||||||||||||||||||
| 360 | 0 | } catch { | |||||||||||||||||||||||||||||||||||||
| 361 | 0 | $log->errorf("JSON decoding error %s from HTTP response %s", $@, $resp->as_string("\n")); | |||||||||||||||||||||||||||||||||||||
| 362 | 0 | return Future->fail($@ => json => $resp); | |||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | })->else(sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||
| 365 | 0 | my ($err, $src, $resp, $req) = @_; | |||||||||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | $src //= ''; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$src //= ""
MC/DC0%0/1
$src //= ""
$src
Truth table0%0/2
A
A= $src
| |||||||||||||||||||||||||||||||||||||||
| 367 | 0 | ▶ | if($src eq 'http') { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | $log->errorf("HTTP error %s, request was %s with response %s", $err, $req && $req->as_string("\n"), $resp && $resp->as_string("\n")); | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$req && $req->as_string("\n")
$resp && $resp->as_string("\n")
MC/DC0%0/2
$req && $req->as_string("\n")
$req
$req->as_string("\n")
MC/DC0%0/2
$resp && $resp->as_string("\n")
$resp
$resp->as_string("\n")
Truth table0%0/3
A && B
A= $reqB= $req->as_string("\n")
Truth table0%0/3
A && B
A= $respB= $resp->as_string("\n")
| |||||||||||||||||||||||||||||||||||||||
| 369 | } else { | ||||||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | $log->errorf("Other failure (%s): %s", $src // 'unknown', $err); | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$src // "unknown"
MC/DC0%0/1
$src // "unknown"
$src
Truth table0%0/2
A
A= $src
| |||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||
| 372 | 0 | Future->fail(@_); | |||||||||||||||||||||||||||||||||||||
| 373 | }) | ||||||||||||||||||||||||||||||||||||||
| 374 | 0 | } | |||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||
| 376 | 0 | ▶ | sub http_post { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
http_post: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 377 | 0 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||
| 379 | $args{headers}{Authorization} = $self->oauth->authorization_header( | ||||||||||||||||||||||||||||||||||||||
| 380 | method => 'GET', | ||||||||||||||||||||||||||||||||||||||
| 381 | uri => $args{uri} | ||||||||||||||||||||||||||||||||||||||
| 382 | 0 | ); | |||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||
| 384 | 0 | $log->tracef("POST %s { %s }", ''. $args{uri}, \%args); | |||||||||||||||||||||||||||||||||||||
| 385 | $self->http->POST( | ||||||||||||||||||||||||||||||||||||||
| 386 | (delete $args{uri}), | ||||||||||||||||||||||||||||||||||||||
| 387 | encode_json_utf8(delete $args{body}), | ||||||||||||||||||||||||||||||||||||||
| 388 | content_type => 'application/json', | ||||||||||||||||||||||||||||||||||||||
| 389 | %args | ||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | )->then(sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||
| 391 | 0 | my ($resp) = @_; | |||||||||||||||||||||||||||||||||||||
| 392 | 0 | $log->tracef("%s => %s", $args{uri}, $resp->decoded_content); | |||||||||||||||||||||||||||||||||||||
| 393 | 0 | ▶ | return { } if $resp->code == 204; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | return { } if 3 == ($resp->code / 100); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 395 | try { | ||||||||||||||||||||||||||||||||||||||
| 396 | 0 | return Future->done(decode_json_utf8($resp->content)) | |||||||||||||||||||||||||||||||||||||
| 397 | 0 | } catch { | |||||||||||||||||||||||||||||||||||||
| 398 | 0 | $log->errorf("JSON decoding error %s from HTTP response %s", $@, $resp->as_string("\n")); | |||||||||||||||||||||||||||||||||||||
| 399 | 0 | return Future->fail($@ => json => $resp); | |||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||
| 401 | 0 | ▶ | })->else(sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||
| 402 | 0 | my ($err, $src, $resp, $req) = @_; | |||||||||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | $src //= ''; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$src //= ""
MC/DC0%0/1
$src //= ""
$src
Truth table0%0/2
A
A= $src
| |||||||||||||||||||||||||||||||||||||||
| 404 | 0 | ▶ | if($src eq 'http') { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 405 | 0 | $log->errorf("HTTP error %s, request was %s with response %s", $err, $req->as_string("\n"), $resp->as_string("\n")); | |||||||||||||||||||||||||||||||||||||
| 406 | } else { | ||||||||||||||||||||||||||||||||||||||
| 407 | 0 | ▶ | $log->errorf("Other failure (%s): %s", $src // 'unknown', $err); | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$src // "unknown"
MC/DC0%0/1
$src // "unknown"
$src
Truth table0%0/2
A
A= $src
| |||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||
| 409 | 0 | Future->fail(@_); | |||||||||||||||||||||||||||||||||||||
| 410 | }) | ||||||||||||||||||||||||||||||||||||||
| 411 | 0 | } | |||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||
| 413 | 0 | ▶ | sub http_put { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
http_put: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 414 | 0 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||
| 416 | $args{headers}{Authorization} = $self->oauth->authorization_header( | ||||||||||||||||||||||||||||||||||||||
| 417 | method => 'PUT', | ||||||||||||||||||||||||||||||||||||||
| 418 | uri => $args{uri} | ||||||||||||||||||||||||||||||||||||||
| 419 | 0 | ); | |||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||
| 421 | 0 | $log->tracef("PUT %s { %s }", ''. $args{uri}, \%args); | |||||||||||||||||||||||||||||||||||||
| 422 | $self->http->PUT( | ||||||||||||||||||||||||||||||||||||||
| 423 | (delete $args{uri}), | ||||||||||||||||||||||||||||||||||||||
| 424 | encode_json_utf8(delete $args{body}), | ||||||||||||||||||||||||||||||||||||||
| 425 | content_type => 'application/json', | ||||||||||||||||||||||||||||||||||||||
| 426 | %args | ||||||||||||||||||||||||||||||||||||||
| 427 | 0 | ▶ | )->then(sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||
| 428 | 0 | my ($resp) = @_; | |||||||||||||||||||||||||||||||||||||
| 429 | 0 | $log->tracef("%s => %s", $args{uri}, $resp->decoded_content); | |||||||||||||||||||||||||||||||||||||
| 430 | 0 | ▶ | return { } if $resp->code == 204; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | return { } if 3 == ($resp->code / 100); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 432 | try { | ||||||||||||||||||||||||||||||||||||||
| 433 | 0 | return Future->done(decode_json_utf8($resp->content)) | |||||||||||||||||||||||||||||||||||||
| 434 | 0 | } catch { | |||||||||||||||||||||||||||||||||||||
| 435 | 0 | $log->errorf("JSON decoding error %s from HTTP response %s", $@, $resp->as_string("\n")); | |||||||||||||||||||||||||||||||||||||
| 436 | 0 | return Future->fail($@ => json => $resp); | |||||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||||
| 438 | 0 | ▶ | })->else(sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||
| 439 | 0 | my ($err, $src, $resp, $req) = @_; | |||||||||||||||||||||||||||||||||||||
| 440 | 0 | ▶ | $src //= ''; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$src //= ""
MC/DC0%0/1
$src //= ""
$src
Truth table0%0/2
A
A= $src
| |||||||||||||||||||||||||||||||||||||||
| 441 | 0 | ▶ | if($src eq 'http') { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 442 | 0 | $log->errorf("HTTP error %s, request was %s with response %s", $err, $req->as_string("\n"), $resp->as_string("\n")); | |||||||||||||||||||||||||||||||||||||
| 443 | } else { | ||||||||||||||||||||||||||||||||||||||
| 444 | 0 | ▶ | $log->errorf("Other failure (%s): %s", $src // 'unknown', $err); | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$src // "unknown"
MC/DC0%0/1
$src // "unknown"
$src
Truth table0%0/2
A
A= $src
| |||||||||||||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||||||||||||
| 446 | 0 | Future->fail(@_); | |||||||||||||||||||||||||||||||||||||
| 447 | }) | ||||||||||||||||||||||||||||||||||||||
| 448 | 0 | } | |||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||
| 450 | 0 | ▶ | sub socket_io { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
socket_io: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 451 | 0 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||
| 453 | 0 | my $uri = $self->endpoint('socket_io'); | |||||||||||||||||||||||||||||||||||||
| 454 | 0 | $args{headers}{Authorization} = $self->oauth->authorization_header( | |||||||||||||||||||||||||||||||||||||
| 455 | method => 'GET', | ||||||||||||||||||||||||||||||||||||||
| 456 | uri => $uri, | ||||||||||||||||||||||||||||||||||||||
| 457 | ); | ||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||
| 459 | 0 | $log->tracef("GET %s { }", ''. $uri); | |||||||||||||||||||||||||||||||||||||
| 460 | $self->http->GET( | ||||||||||||||||||||||||||||||||||||||
| 461 | $uri, | ||||||||||||||||||||||||||||||||||||||
| 462 | %args | ||||||||||||||||||||||||||||||||||||||
| 463 | 0 | ▶ | )->then(sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||
| 464 | 0 | my ($resp) = @_; | |||||||||||||||||||||||||||||||||||||
| 465 | 0 | ▶ | return { } if $resp->code == 204; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 466 | 0 | ▶ | return { } if 3 == ($resp->code / 100); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 467 | 0 | my @info = split /:/, $resp->decoded_content; | |||||||||||||||||||||||||||||||||||||
| 468 | 0 | ▶ | die "expected websocket" unless $info[3] eq 'websocket'; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 469 | 0 | Future->done($info[0]); | |||||||||||||||||||||||||||||||||||||
| 470 | 0 | }); | |||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||
| 473 | 0 | ▶ | sub api_get_list { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
api_get_list: not called CC=6 SCAR=31.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 474 | 1 | ▶ | use Variable::Disposition qw(retain_future); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 475 | 1 | ▶ | use Scalar::Util qw(refaddr); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 476 | 1 | ▶ | use Future::Utils qw(fmap0); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 477 | 1 | ▶ | use namespace::clean qw(retain_future refaddr); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||
| 479 | 0 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||
| 480 | my $label = $args{endpoint} | ||||||||||||||||||||||||||||||||||||||
| 481 | 0 | ▶ | ? ('Trello[' . $args{endpoint} . ']') | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 482 | : (caller 1)[3]; | ||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||
| 484 | 0 | ▶ | die "Must be a member of a ::Loop" unless $self->loop; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||
| 486 | # Hoist our HTTP API call into a source of items | ||||||||||||||||||||||||||||||||||||||
| 487 | 0 | my $src = $self->ryu->source( | |||||||||||||||||||||||||||||||||||||
| 488 | label => $label | ||||||||||||||||||||||||||||||||||||||
| 489 | ); | ||||||||||||||||||||||||||||||||||||||
| 490 | my $uri = $args{endpoint} | ||||||||||||||||||||||||||||||||||||||
| 491 | ? $self->endpoint( | ||||||||||||||||||||||||||||||||||||||
| 492 | $args{endpoint}, | ||||||||||||||||||||||||||||||||||||||
| 493 | 0 | ▶ | %{$args{endpoint_args}} | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 494 | ) | ||||||||||||||||||||||||||||||||||||||
| 495 | : ref($args{uri}) | ||||||||||||||||||||||||||||||||||||||
| 496 | ? $args{uri} | ||||||||||||||||||||||||||||||||||||||
| 497 | : URI->new( | ||||||||||||||||||||||||||||||||||||||
| 498 | $self->base_uri . $args{uri} | ||||||||||||||||||||||||||||||||||||||
| 499 | 0 | ▶ | ); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||
| 501 | 0 | ▶ | my $per_page = (delete $args{per_page}) || 100; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
delete $args{'per_page'} || 100
MC/DC0%0/1
delete $args{'per_page'} || 100
delete $args{'per_page'}
Truth table0%0/2
A
A= delete $args{'per_page'}
| |||||||||||||||||||||||||||||||||||||||
| 502 | 0 | $uri->query_param( | |||||||||||||||||||||||||||||||||||||
| 503 | limit => $per_page | ||||||||||||||||||||||||||||||||||||||
| 504 | ); | ||||||||||||||||||||||||||||||||||||||
| 505 | 0 | ▶ | my $f = (fmap0 { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 506 | # $uri->query_param( | ||||||||||||||||||||||||||||||||||||||
| 507 | # before => $per_page | ||||||||||||||||||||||||||||||||||||||
| 508 | # ); | ||||||||||||||||||||||||||||||||||||||
| 509 | 0 | my $count; | |||||||||||||||||||||||||||||||||||||
| 510 | 0 | ▶ | (try_repeat { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 511 | 0 | $self->http_get( | |||||||||||||||||||||||||||||||||||||
| 512 | uri => $uri, | ||||||||||||||||||||||||||||||||||||||
| 513 | ) | ||||||||||||||||||||||||||||||||||||||
| 514 | 0 | ▶ | } until => sub { shift->is_done or $count++ > 3 })->on_done(sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Subroutine
__ANON__: not called CC=3 SCAR=24.8
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 515 | 0 | $log->tracef("we received %s", $_[0]); | |||||||||||||||||||||||||||||||||||||
| 516 | $src->emit( | ||||||||||||||||||||||||||||||||||||||
| 517 | $args{class}->new( | ||||||||||||||||||||||||||||||||||||||
| 518 | %$_, | ||||||||||||||||||||||||||||||||||||||
| 519 | 0 | ($args{extra} ? %{$args{extra}} : ()), | |||||||||||||||||||||||||||||||||||||
| 520 | trello => $self | ||||||||||||||||||||||||||||||||||||||
| 521 | ) | ||||||||||||||||||||||||||||||||||||||
| 522 | 0 | ▶ | ) for @{ $_[0] }; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 523 | 0 | $src->finish; | |||||||||||||||||||||||||||||||||||||
| 524 | 0 | ▶ | })->on_fail(sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 525 | 0 | $src->fail(@_) | |||||||||||||||||||||||||||||||||||||
| 526 | 0 | ▶ | })->on_cancel(sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 527 | 0 | $src->cancel | |||||||||||||||||||||||||||||||||||||
| 528 | 0 | }); | |||||||||||||||||||||||||||||||||||||
| 529 | 0 | } foreach => [1]); | |||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||
| 531 | # If our source finishes earlier than our HTTP request, then cancel the request | ||||||||||||||||||||||||||||||||||||||
| 532 | 0 | ▶ | $src->completed->on_ready(sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||
| 533 | 0 | ▶ | return if $f->is_ready; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 534 | 0 | $log->tracef("Finishing HTTP request early for %s since our source is no longer active", $label); | |||||||||||||||||||||||||||||||||||||
| 535 | 0 | $f->cancel | |||||||||||||||||||||||||||||||||||||
| 536 | 0 | }); | |||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||
| 538 | # Track active requests | ||||||||||||||||||||||||||||||||||||||
| 539 | 0 | my $refaddr = Scalar::Util::refaddr($f); | |||||||||||||||||||||||||||||||||||||
| 540 | retain_future( | ||||||||||||||||||||||||||||||||||||||
| 541 | $self->pending_requests->push([ { | ||||||||||||||||||||||||||||||||||||||
| 542 | id => $refaddr, | ||||||||||||||||||||||||||||||||||||||
| 543 | src => $src, | ||||||||||||||||||||||||||||||||||||||
| 544 | uri => $args{uri}, | ||||||||||||||||||||||||||||||||||||||
| 545 | future => $f, | ||||||||||||||||||||||||||||||||||||||
| 546 | 0 | ▶ | } ])->then(sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 547 | 0 | ▶ | $f->on_ready(sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 548 | retain_future( | ||||||||||||||||||||||||||||||||||||||
| 549 | 0 | ▶ | $self->pending_requests->extract_first_by(sub { $_->{id} == $refaddr }) | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 550 | 0 | ) | |||||||||||||||||||||||||||||||||||||
| 551 | 0 | }); | |||||||||||||||||||||||||||||||||||||
| 552 | }) | ||||||||||||||||||||||||||||||||||||||
| 553 | 0 | ); | |||||||||||||||||||||||||||||||||||||
| 554 | 0 | $src | |||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||
| 557 | 0 | ▶ | sub pending_requests { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
pending_requests: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 558 | 0 | ▶ | shift->{pending_requests} //= Adapter::Async::OrderedList::Array->new | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
+(shift())->{"pending_requests"} //= "Adapter::Async::OrderedList::Array"->new
MC/DC0%0/2
+(shift())->{"pending_requests"} //= "Adapter::Async::OrderedList::Array"->new
+(shift())->{"pending_requests"}
"Adapter::Async::OrderedList::Array"->new
Truth table0%0/3
A //= B
A= +(shift())->{"pending_requests"}B= "Adapter::Async::OrderedList::Array"->new
| |||||||||||||||||||||||||||||||||||||||
| 559 | } | ||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||
| 561 | 0 | ▶ | sub ryu { shift->{ryu} } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
ryu: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||
| 563 | 0 | ▶ | sub _add_to_loop { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_to_loop: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 564 | 0 | my ($self, $loop) = @_; | |||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||
| 566 | $self->add_child( | ||||||||||||||||||||||||||||||||||||||
| 567 | 0 | $self->{ryu} = Ryu::Async->new | |||||||||||||||||||||||||||||||||||||
| 568 | ); | ||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||
| 572 | 0 | ▶ | sub ws { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
ws: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 573 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||
| 574 | 0 | ▶ | $self->{ws} //= do { | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"ws"} //= do {
$self->add_child(my $ws = "Net::Async::Trello::WS"->new("trello", $self, "token", $self->ws_token));
$ws
}
MC/DC0%0/2
$self->{"ws"} //= do {
$self->add_child(my $ws = "Net::Async::Trello::WS"->new("trello", $self, "token", $self->ws_token));
$ws
}
$self->{"ws"}
do {
$self->add_child(my $ws = "Net::Async::Trello::WS"->new("trello", $self, "token", $self->ws_token));
$ws
}
Truth table0%0/3
A //= B
A= $self->{"ws"}B= do {
$self->add_child(my $ws = "Net::Async::Trello::WS"->new("trello", $self, "token", $self->ws_token));
$ws
}
| |||||||||||||||||||||||||||||||||||||||
| 575 | 0 | $self->add_child( | |||||||||||||||||||||||||||||||||||||
| 576 | my $ws = Net::Async::Trello::WS->new( | ||||||||||||||||||||||||||||||||||||||
| 577 | trello => $self, | ||||||||||||||||||||||||||||||||||||||
| 578 | token => $self->ws_token, | ||||||||||||||||||||||||||||||||||||||
| 579 | ) | ||||||||||||||||||||||||||||||||||||||
| 580 | ); | ||||||||||||||||||||||||||||||||||||||
| 581 | 0 | $ws | |||||||||||||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||||||||||||
| 583 | } | ||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||
| 585 | 0 | ▶ | sub websocket { shift->ws->connection } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
websocket: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||
| 587 | 0 | ▶ | sub oauth_request { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
oauth_request: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 588 | 0 | my ($self, $code) = @_; | |||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||
| 590 | # We don't provide any scope or expiration details at this point. Those are added to the URI in the browser. | ||||||||||||||||||||||||||||||||||||||
| 591 | 0 | my $uri = URI->new('https://trello.com/1/OAuthGetRequestToken'); | |||||||||||||||||||||||||||||||||||||
| 592 | 0 | my $req = HTTP::Request->new(POST => "$uri"); | |||||||||||||||||||||||||||||||||||||
| 593 | 0 | $req->protocol('HTTP/1.1'); | |||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||
| 595 | # $req->header(Authorization => 'Bearer ' . $self->req); | ||||||||||||||||||||||||||||||||||||||
| 596 | 0 | $self->oauth->configure( | |||||||||||||||||||||||||||||||||||||
| 597 | token => '', | ||||||||||||||||||||||||||||||||||||||
| 598 | token_secret => '', | ||||||||||||||||||||||||||||||||||||||
| 599 | ); | ||||||||||||||||||||||||||||||||||||||
| 600 | 0 | my $hdr = $self->oauth->authorization_header( | |||||||||||||||||||||||||||||||||||||
| 601 | method => 'POST', | ||||||||||||||||||||||||||||||||||||||
| 602 | uri => $uri, | ||||||||||||||||||||||||||||||||||||||
| 603 | ); | ||||||||||||||||||||||||||||||||||||||
| 604 | 0 | $req->header('Authorization' => $hdr); | |||||||||||||||||||||||||||||||||||||
| 605 | 0 | $log->tracef("Resulting auth header for userstream was %s", $hdr); | |||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||
| 607 | 0 | $req->header('Host' => $uri->host); | |||||||||||||||||||||||||||||||||||||
| 608 | # $req->header('User-Agent' => 'OAuth gem v0.4.4'); | ||||||||||||||||||||||||||||||||||||||
| 609 | 0 | $req->header('Connection' => 'close'); | |||||||||||||||||||||||||||||||||||||
| 610 | 0 | $req->header('Accept' => '*/*'); | |||||||||||||||||||||||||||||||||||||
| 611 | $self->http->do_request( | ||||||||||||||||||||||||||||||||||||||
| 612 | request => $req, | ||||||||||||||||||||||||||||||||||||||
| 613 | 0 | ▶ | )->then(sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 614 | 0 | my ($resp) = @_; | |||||||||||||||||||||||||||||||||||||
| 615 | 0 | $log->debugf("RequestToken response was %s", $resp->as_string("\n")); | |||||||||||||||||||||||||||||||||||||
| 616 | 0 | my $rslt = URI->new('http://localhost?' . $resp->decoded_content)->query_form_hash; | |||||||||||||||||||||||||||||||||||||
| 617 | 0 | $log->debugf("Extracted token [%s]", $rslt->{oauth_token}); | |||||||||||||||||||||||||||||||||||||
| 618 | 0 | $self->oauth->configure(token => $rslt->{oauth_token}); | |||||||||||||||||||||||||||||||||||||
| 619 | 0 | $log->debugf("Extracted secret [%s]", $rslt->{oauth_token_secret}); | |||||||||||||||||||||||||||||||||||||
| 620 | 0 | $self->oauth->configure(token_secret => $rslt->{oauth_token_secret}); | |||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||
| 622 | 0 | my $auth_uri = URI->new( | |||||||||||||||||||||||||||||||||||||
| 623 | 'https://trello.com/1/OAuthAuthorizeToken' | ||||||||||||||||||||||||||||||||||||||
| 624 | ); | ||||||||||||||||||||||||||||||||||||||
| 625 | 0 | $auth_uri->query_param(oauth_token => $rslt->{oauth_token}); | |||||||||||||||||||||||||||||||||||||
| 626 | 0 | $auth_uri->query_param(scope => 'read,write'); | |||||||||||||||||||||||||||||||||||||
| 627 | 0 | $auth_uri->query_param(name => 'trelloctl'); | |||||||||||||||||||||||||||||||||||||
| 628 | 0 | $auth_uri->query_param(expiration => 'never'); | |||||||||||||||||||||||||||||||||||||
| 629 | 0 | $code->($auth_uri); | |||||||||||||||||||||||||||||||||||||
| 630 | 0 | ▶ | }, sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 631 | 0 | $log->errorf("Failed to do oauth lookup - %s", join ',', @_); | |||||||||||||||||||||||||||||||||||||
| 632 | 0 | die @_; | |||||||||||||||||||||||||||||||||||||
| 633 | 0 | ▶ | })->then(sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 634 | 0 | my ($verify) = @_; | |||||||||||||||||||||||||||||||||||||
| 635 | 0 | my $uri = URI->new('https://trello.com/1/OAuthGetAccessToken'); | |||||||||||||||||||||||||||||||||||||
| 636 | 0 | my $req = HTTP::Request->new(POST => "$uri"); | |||||||||||||||||||||||||||||||||||||
| 637 | 0 | $req->protocol('HTTP/1.1'); | |||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||
| 639 | 0 | my $hdr = $self->oauth->authorization_header( | |||||||||||||||||||||||||||||||||||||
| 640 | method => 'POST', | ||||||||||||||||||||||||||||||||||||||
| 641 | uri => $uri, | ||||||||||||||||||||||||||||||||||||||
| 642 | parameters => { | ||||||||||||||||||||||||||||||||||||||
| 643 | oauth_verifier => $verify | ||||||||||||||||||||||||||||||||||||||
| 644 | } | ||||||||||||||||||||||||||||||||||||||
| 645 | ); | ||||||||||||||||||||||||||||||||||||||
| 646 | 0 | $req->header('Authorization' => $hdr); | |||||||||||||||||||||||||||||||||||||
| 647 | 0 | $log->tracef("Resulting auth header was %s", $hdr); | |||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||
| 649 | 0 | $req->header('Host' => $uri->host); | |||||||||||||||||||||||||||||||||||||
| 650 | 0 | $req->header('Connection' => 'close'); | |||||||||||||||||||||||||||||||||||||
| 651 | 0 | $req->header('Accept' => '*/*'); | |||||||||||||||||||||||||||||||||||||
| 652 | 0 | $self->http->do_request( | |||||||||||||||||||||||||||||||||||||
| 653 | request => $req, | ||||||||||||||||||||||||||||||||||||||
| 654 | ) | ||||||||||||||||||||||||||||||||||||||
| 655 | 0 | ▶ | })->then(sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 656 | 0 | my ($resp) = @_; | |||||||||||||||||||||||||||||||||||||
| 657 | 0 | $log->tracef("GetAccessToken response was %s", $resp->as_string("\n")); | |||||||||||||||||||||||||||||||||||||
| 658 | 0 | my $rslt = URI->new('http://localhost?' . $resp->decoded_content)->query_form_hash; | |||||||||||||||||||||||||||||||||||||
| 659 | 0 | $log->tracef("Extracted token [%s]", $rslt->{oauth_token}); | |||||||||||||||||||||||||||||||||||||
| 660 | 0 | $self->configure(token => $rslt->{oauth_token}); | |||||||||||||||||||||||||||||||||||||
| 661 | 0 | $log->tracef("Extracted secret [%s]", $rslt->{oauth_token_secret}); | |||||||||||||||||||||||||||||||||||||
| 662 | 0 | $self->configure(token_secret => $rslt->{oauth_token_secret}); | |||||||||||||||||||||||||||||||||||||
| 663 | Future->done({ | ||||||||||||||||||||||||||||||||||||||
| 664 | token => $rslt->{oauth_token}, | ||||||||||||||||||||||||||||||||||||||
| 665 | token_secret => $rslt->{oauth_token_secret}, | ||||||||||||||||||||||||||||||||||||||
| 666 | }) | ||||||||||||||||||||||||||||||||||||||
| 667 | 0 | }) | |||||||||||||||||||||||||||||||||||||
| 668 | 0 | } | |||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||
| 670 | 1 | 1; | |||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||
| 672 | __END__ | ||||||||||||||||||||||||||||||||||||||