| 1 | package WWW::Asana::Task; | ||||||||||||||||||||||||||
| 2 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||
| 3 | 1 | $WWW::Asana::Task::AUTHORITY = 'cpan:GETTY'; | |||||||||||||||||||||||||
| 4 | } | ||||||||||||||||||||||||||
| 5 | { | ||||||||||||||||||||||||||
| 6 | 1 | $WWW::Asana::Task::VERSION = '0.003'; | |||||||||||||||||||||||||
| 7 | } | ||||||||||||||||||||||||||
| 8 | # ABSTRACT: Asana Task Class | ||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||
| 10 | 1 | ▶ | use MooX; | ||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||
| 12 | 1 | with 'WWW::Asana::Role::HasClient'; | |||||||||||||||||||||||||
| 13 | 1 | with 'WWW::Asana::Role::HasResponse'; | |||||||||||||||||||||||||
| 14 | 1 | with 'WWW::Asana::Role::NewFromResponse'; | |||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||
| 16 | 1 | with 'WWW::Asana::Role::HasFollowers'; | |||||||||||||||||||||||||
| 17 | 1 | with 'WWW::Asana::Role::HasStories'; | |||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||
| 19 | 1 | with 'WWW::Asana::Role::CanReload'; | |||||||||||||||||||||||||
| 20 | 1 | with 'WWW::Asana::Role::CanUpdate'; | |||||||||||||||||||||||||
| 21 | 1 | with 'WWW::Asana::Role::CanCreate'; | |||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||
| 23 | 1 | ▶ | use DateTime::Format::ISO8601; | ||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||
| 25 | 0 | ▶ | sub own_base_args { 'tasks', shift->id } | ||||||||||||||||||||||||
|
Subroutine
own_base_args: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||
| 26 | 0 | ▶ | sub reload_base_args { 'Task', 'GET' } | ||||||||||||||||||||||||
|
Subroutine
reload_base_args: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||
| 27 | 0 | ▶ | sub update_args { | ||||||||||||||||||||||||
|
Subroutine
update_args: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||
| 28 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||
| 29 | 0 | ▶ | 'Task', 'PUT', $self->own_base_args, $self->value_args, sub { workspace => $self->workspace }; | ||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||
| 31 | 0 | ▶ | sub create_args { | ||||||||||||||||||||||||
|
Subroutine
create_args: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||
| 32 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||
| 33 | 0 | ▶ | 'Task', 'POST', 'tasks', $self->value_args, sub { workspace => $self->workspace }; | ||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub value_args { | ||||||||||||||||||||||||
|
Subroutine
value_args: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||
| 37 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||
| 38 | return { | ||||||||||||||||||||||||||
| 39 | 0 | ▶ | workspace => $self->workspace->id, | ||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||
| 40 | assignee => $self->has_assignee ? $self->assignee->id : undef, | ||||||||||||||||||||||||||
| 41 | $self->has_name ? ( name => $self->name ) : (), | ||||||||||||||||||||||||||
| 42 | $self->has_notes ? ( notes => $self->notes ) : (), | ||||||||||||||||||||||||||
| 43 | $self->has_completed ? ( completed => $self->completed_value ) : (), | ||||||||||||||||||||||||||
| 44 | $self->has_due_on ? ( due_on => $self->due_on_value ) : (), | ||||||||||||||||||||||||||
| 45 | }; | ||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||
| 48 | 1 | has id => ( | |||||||||||||||||||||||||
| 49 | is => 'ro', | ||||||||||||||||||||||||||
| 50 | predicate => 1, | ||||||||||||||||||||||||||
| 51 | ); | ||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||
| 53 | has assignee => ( | ||||||||||||||||||||||||||
| 54 | is => 'rw', | ||||||||||||||||||||||||||
| 55 | 0 | ▶ | isa => sub { | ||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||
| 56 | 0 | ▶ | die "assignee must be a WWW::Asana::User" unless ref $_[0] eq 'WWW::Asana::User'; | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 57 | }, | ||||||||||||||||||||||||||
| 58 | 1 | predicate => 1, | |||||||||||||||||||||||||
| 59 | clearer => 'clear_assignee', | ||||||||||||||||||||||||||
| 60 | ); | ||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||
| 62 | has assignee_status => ( | ||||||||||||||||||||||||||
| 63 | is => 'ro', | ||||||||||||||||||||||||||
| 64 | 0 | ▶ | isa => sub { | ||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||
| 65 | die "assignee_status must be inbox, later, today or upcoming" | ||||||||||||||||||||||||||
| 66 | 0 | ▶ | unless grep { $_[0] eq $_ } qw( inbox later today upcoming ); | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 67 | }, | ||||||||||||||||||||||||||
| 68 | 1 | ); | |||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||
| 70 | has created_at => ( | ||||||||||||||||||||||||||
| 71 | is => 'ro', | ||||||||||||||||||||||||||
| 72 | 0 | ▶ | isa => sub { | ||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||
| 73 | 0 | ▶ | die "created_at must be a DateTime" unless ref $_[0] eq 'DateTime'; | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 74 | }, | ||||||||||||||||||||||||||
| 75 | 1 | predicate => 1, | |||||||||||||||||||||||||
| 76 | ); | ||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||
| 78 | 1 | has completed => ( | |||||||||||||||||||||||||
| 79 | is => 'rw', | ||||||||||||||||||||||||||
| 80 | predicate => 1, | ||||||||||||||||||||||||||
| 81 | ); | ||||||||||||||||||||||||||
| 82 | 0 | ▶ | sub completed_value { shift->completed ? 'true' : 'false' } | ||||||||||||||||||||||||
|
Subroutine
completed_value: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||
| 84 | has completed_at => ( | ||||||||||||||||||||||||||
| 85 | is => 'ro', | ||||||||||||||||||||||||||
| 86 | 0 | ▶ | isa => sub { | ||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||
| 87 | 0 | ▶ | die "completed_at must be a DateTime" unless ref $_[0] eq 'DateTime'; | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 88 | }, | ||||||||||||||||||||||||||
| 89 | 1 | predicate => 1, | |||||||||||||||||||||||||
| 90 | ); | ||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||
| 92 | has due_on => ( | ||||||||||||||||||||||||||
| 93 | is => 'rw', | ||||||||||||||||||||||||||
| 94 | 0 | ▶ | isa => sub { | ||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||
| 95 | 0 | ▶ | die "due_on must be a DateTime" unless ref $_[0] eq 'DateTime'; | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 96 | }, | ||||||||||||||||||||||||||
| 97 | 1 | predicate => 1, | |||||||||||||||||||||||||
| 98 | clearer => 'clear_due_on', | ||||||||||||||||||||||||||
| 99 | ); | ||||||||||||||||||||||||||
| 100 | 0 | ▶ | sub due_on_value { shift->due_on->ymd('-') } | ||||||||||||||||||||||||
|
Subroutine
due_on_value: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||
| 102 | 1 | has name => ( | |||||||||||||||||||||||||
| 103 | is => 'rw', | ||||||||||||||||||||||||||
| 104 | predicate => 1, | ||||||||||||||||||||||||||
| 105 | ); | ||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||
| 107 | 1 | has notes => ( | |||||||||||||||||||||||||
| 108 | is => 'rw', | ||||||||||||||||||||||||||
| 109 | predicate => 1, | ||||||||||||||||||||||||||
| 110 | ); | ||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||
| 112 | has workspace => ( | ||||||||||||||||||||||||||
| 113 | is => 'rw', | ||||||||||||||||||||||||||
| 114 | 0 | ▶ | isa => sub { | ||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||
| 115 | 0 | ▶ | die "workspace must be a WWW::Asana::Workspace" unless ref $_[0] eq 'WWW::Asana::Workspace'; | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 116 | }, | ||||||||||||||||||||||||||
| 117 | 1 | required => 1, | |||||||||||||||||||||||||
| 118 | ); | ||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||
| 120 | 0 | ▶ | sub projects { | ||||||||||||||||||||||||
|
Subroutine
projects: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||
| 121 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||
| 122 | 0 | ▶ | $self->do('[Project]', 'GET', $self->own_base_args, 'projects', sub { workspace => $self->workspace }); | ||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||
| 125 | 0 | ▶ | sub add_project { | ||||||||||||||||||||||||
|
Subroutine
add_project: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||
| 126 | 0 | my ( $self, $project ) = @_; | |||||||||||||||||||||||||
| 127 | 0 | ▶ | return $self->do('', 'POST', $self->own_base_args, 'addProject', { project => $project->id } ) eq 1 ? 1 : 0; | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||
| 130 | 0 | ▶ | sub remove_project { | ||||||||||||||||||||||||
|
Subroutine
remove_project: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||
| 131 | 0 | my ( $self, $project ) = @_; | |||||||||||||||||||||||||
| 132 | 0 | ▶ | return $self->do('', 'POST', $self->own_base_args, 'removeProject', { project => $project->id } ) eq 1 ? 1 : 0; | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||
| 135 | 0 | ▶ | sub tags { | ||||||||||||||||||||||||
|
Subroutine
tags: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||
| 136 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||
| 137 | 0 | ▶ | $self->do('[Tag]', 'GET', $self->own_base_args, 'tags', sub { workspace => $self->workspace }); | ||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||
| 140 | 0 | ▶ | sub add_tag { | ||||||||||||||||||||||||
|
Subroutine
add_tag: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||
| 141 | 0 | my ( $self, $tag ) = @_; | |||||||||||||||||||||||||
| 142 | 0 | ▶ | return $self->do('', 'POST', $self->own_base_args, 'addTag', { tag => $tag->id } ) eq 1 ? 1 : 0; | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||
| 145 | 0 | ▶ | sub remove_tag { | ||||||||||||||||||||||||
|
Subroutine
remove_tag: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||
| 146 | 0 | my ( $self, $tag ) = @_; | |||||||||||||||||||||||||
| 147 | 0 | ▶ | return $self->do('', 'POST', $self->own_base_args, 'removeTag', { tag => $tag->id } ) eq 1 ? 1 : 0; | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||
| 150 | 1 | 1; | |||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||
| 152 | __END__ | ||||||||||||||||||||||||||