| 1 | package Net::Async::Trello::Card; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | |||||||||||||||
| 6 | 2 | our $VERSION = '0.007'; # VERSION | |||||||||||||
| 7 | |||||||||||||||
| 8 | 2 | ▶ | use parent qw(Net::Async::Trello::Generated::Card); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 9 | |||||||||||||||
| 10 | 2 | ▶ | use Unicode::UTF8 (); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 11 | 2 | ▶ | use Log::Any qw($log); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 12 | |||||||||||||||
| 13 | =head1 NAME | ||||||||||||||
| 14 | |||||||||||||||
| 15 | Net::Async::Trello::Card | ||||||||||||||
| 16 | |||||||||||||||
| 17 | =head1 DESCRIPTION | ||||||||||||||
| 18 | |||||||||||||||
| 19 | Card interaction. | ||||||||||||||
| 20 | |||||||||||||||
| 21 | =cut | ||||||||||||||
| 22 | |||||||||||||||
| 23 | 0 | ▶ | sub history { | ||||||||||||
|
Subroutine
history: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||
| 24 | 0 | my ($self, %args) = @_; | |||||||||||||
| 25 | 0 | my $trello = $self->trello; | |||||||||||||
| 26 | 0 | my $filter = delete $args{filter}; | |||||||||||||
| 27 | 0 | my $uri = URI->new( | |||||||||||||
| 28 | $trello->base_uri . 'cards/' . $self->id . '/actions/?member=false' | ||||||||||||||
| 29 | ); | ||||||||||||||
| 30 | 0 | ▶ | if(ref $filter) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 31 | 0 | $uri->query_param(filter => @$filter) | |||||||||||||
| 32 | } elsif($filter) { | ||||||||||||||
| 33 | 0 | $uri->query_param(filter => $filter) | |||||||||||||
| 34 | } else { | ||||||||||||||
| 35 | 0 | $uri->query_param(filter => 'all') | |||||||||||||
| 36 | } | ||||||||||||||
| 37 | 0 | $uri->query_param($_ => $args{$_}) for keys %args; | |||||||||||||
| 38 | 0 | $trello->api_get_list( | |||||||||||||
| 39 | uri => $uri, | ||||||||||||||
| 40 | class => 'Net::Async::Trello::CardAction', | ||||||||||||||
| 41 | extra => { | ||||||||||||||
| 42 | card => $self | ||||||||||||||
| 43 | } | ||||||||||||||
| 44 | ) | ||||||||||||||
| 45 | } | ||||||||||||||
| 46 | |||||||||||||||
| 47 | 0 | ▶ | sub update { | ||||||||||||
|
Subroutine
update: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 48 | 0 | my ($self, %args) = @_; | |||||||||||||
| 49 | 0 | my $trello = $self->trello; | |||||||||||||
| 50 | 0 | $trello->http_put( | |||||||||||||
| 51 | uri => URI->new( | ||||||||||||||
| 52 | $trello->base_uri . 'cards/' . $self->id | ||||||||||||||
| 53 | ), | ||||||||||||||
| 54 | body => \%args | ||||||||||||||
| 55 | ) | ||||||||||||||
| 56 | } | ||||||||||||||
| 57 | |||||||||||||||
| 58 | =head2 add_comment | ||||||||||||||
| 59 | |||||||||||||||
| 60 | Helper method to add a comment to a card as the current user. | ||||||||||||||
| 61 | |||||||||||||||
| 62 | Takes a single C<$comment> parameter, this should be the text to add (in | ||||||||||||||
| 63 | standard Trello Markdown format). | ||||||||||||||
| 64 | |||||||||||||||
| 65 | =cut | ||||||||||||||
| 66 | |||||||||||||||
| 67 | 0 | ▶ | sub add_comment { | ||||||||||||
|
Subroutine
add_comment: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 68 | 0 | my ($self, $comment) = @_; | |||||||||||||
| 69 | 0 | my $trello = $self->trello; | |||||||||||||
| 70 | 0 | $trello->http_post( | |||||||||||||
| 71 | uri => URI->new( | ||||||||||||||
| 72 | $trello->base_uri . 'cards/' . $self->id . '/actions/comments?text=' . Unicode::UTF8::encode_utf8($comment) | ||||||||||||||
| 73 | ), | ||||||||||||||
| 74 | body => { } | ||||||||||||||
| 75 | ) | ||||||||||||||
| 76 | } | ||||||||||||||
| 77 | |||||||||||||||
| 78 | =head2 in_list_since | ||||||||||||||
| 79 | |||||||||||||||
| 80 | Returns the date when this card was moved to the current list, as an ISO8601 string. | ||||||||||||||
| 81 | |||||||||||||||
| 82 | =cut | ||||||||||||||
| 83 | |||||||||||||||
| 84 | 0 | ▶ | sub in_list_since { | ||||||||||||
|
Subroutine
in_list_since: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 85 | 0 | my ($self, $comment) = @_; | |||||||||||||
| 86 | 0 | my $trello = $self->trello; | |||||||||||||
| 87 | # We call the endpoint with limit=1 here to find the most recent idList update | ||||||||||||||
| 88 | $trello->http_get( | ||||||||||||||
| 89 | uri => URI->new( | ||||||||||||||
| 90 | $trello->base_uri . 'cards/' . $self->id . '/actions?filter=updateCard:idList&limit=1' | ||||||||||||||
| 91 | ), | ||||||||||||||
| 92 | 0 | ▶ | )->then(sub { | ||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||
| 93 | my $date = shift->[0]->{date} | ||||||||||||||
| 94 | 0 | ▶ | or return Future->done($self->created_at); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 95 | 0 | Future->done($date); | |||||||||||||
| 96 | }) | ||||||||||||||
| 97 | 0 | } | |||||||||||||
| 98 | |||||||||||||||
| 99 | =head2 created_at | ||||||||||||||
| 100 | |||||||||||||||
| 101 | Uses the card action history to find when it was created. | ||||||||||||||
| 102 | |||||||||||||||
| 103 | Note that the date is currently embedded in the ID, so if you | ||||||||||||||
| 104 | want to avoid the extra API call you can use that information | ||||||||||||||
| 105 | via an algorithm such as L<https://steveridout.github.io/mongo-object-time/> | ||||||||||||||
| 106 | |||||||||||||||
| 107 | =cut | ||||||||||||||
| 108 | |||||||||||||||
| 109 | 0 | ▶ | sub created_at { | ||||||||||||
|
Subroutine
created_at: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 110 | 0 | my ($self, $comment) = @_; | |||||||||||||
| 111 | 0 | my $trello = $self->trello; | |||||||||||||
| 112 | $trello->http_get( | ||||||||||||||
| 113 | uri => URI->new( | ||||||||||||||
| 114 | $trello->base_uri . 'cards/' . $self->id . '/actions&limit=1&since=0' | ||||||||||||||
| 115 | ), | ||||||||||||||
| 116 | 0 | ▶ | )->then(sub { | ||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||
| 117 | 0 | Future->done(shift->[0]->{date}); | |||||||||||||
| 118 | }) | ||||||||||||||
| 119 | 0 | } | |||||||||||||
| 120 | |||||||||||||||
| 121 | 2 | 1; | |||||||||||||
| 122 | |||||||||||||||
| 123 | =head1 AUTHOR | ||||||||||||||
| 124 | |||||||||||||||
| 125 | Tom Molesworth <TEAM@cpan.org> with contributions from C<@felipe-binary> | ||||||||||||||
| 126 | |||||||||||||||
| 127 | =head1 LICENSE | ||||||||||||||
| 128 | |||||||||||||||
| 129 | Copyright Tom Molesworth 2014-2020. Licensed under the same terms as Perl itself. | ||||||||||||||