| 1 | package Google::RestApi::GmailApi1::Label; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | our $VERSION = '2.2.5'; | |||||||||
| 4 | |||||||||||
| 5 | 2 | ▶ | use Google::RestApi::Setup; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 2 | ▶ | use parent 'Google::RestApi::SubResource'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 6 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 10 | 6 | my $class = shift; | |||||||||
| 11 | 6 | state $check = signature( | |||||||||
| 12 | bless => !!0, | ||||||||||
| 13 | named => [ | ||||||||||
| 14 | gmail_api => HasApi, | ||||||||||
| 15 | id => Str, { optional => 1 }, | ||||||||||
| 16 | ], | ||||||||||
| 17 | ); | ||||||||||
| 18 | 6 | return bless $check->(@_), $class; | |||||||||
| 19 | } | ||||||||||
| 20 | |||||||||||
| 21 | 2 | ▶ | sub _uri_base { 'labels' } | ||||||||
|
Subroutine
_uri_base: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 2 | ▶ | sub _parent_accessor { 'gmail_api' } | ||||||||
|
Subroutine
_parent_accessor: called CC=1 SCAR=0.0
| |||||||||||
| 23 | |||||||||||
| 24 | 1 | ▶ | sub create { | ||||||||
|
Subroutine
create: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||
| 25 | 1 | my $self = shift; | |||||||||
| 26 | 1 | state $check = signature( | |||||||||
| 27 | bless => !!0, | ||||||||||
| 28 | named => [ | ||||||||||
| 29 | name => Str, | ||||||||||
| 30 | label_list_visibility => Str, { optional => 1 }, | ||||||||||
| 31 | message_list_visibility => Str, { optional => 1 }, | ||||||||||
| 32 | _extra_ => slurpy HashRef, | ||||||||||
| 33 | ], | ||||||||||
| 34 | ); | ||||||||||
| 35 | 1 | my $p = named_extra($check->(@_)); | |||||||||
| 36 | |||||||||||
| 37 | my %content = ( | ||||||||||
| 38 | name => delete $p->{name}, | ||||||||||
| 39 | 1 | ); | |||||||||
| 40 | $content{labelListVisibility} = delete $p->{label_list_visibility} | ||||||||||
| 41 | 1 | ▶ | if defined $p->{label_list_visibility}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | $content{messageListVisibility} = delete $p->{message_list_visibility} | ||||||||||
| 43 | 1 | ▶ | if defined $p->{message_list_visibility}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | |||||||||||
| 45 | 1 | DEBUG("Creating label '$content{name}'"); | |||||||||
| 46 | 1 | my $result = $self->gmail_api()->api( | |||||||||
| 47 | uri => 'labels', | ||||||||||
| 48 | method => 'post', | ||||||||||
| 49 | content => \%content, | ||||||||||
| 50 | ); | ||||||||||
| 51 | 1 | return ref($self)->new(gmail_api => $self->gmail_api(), id => $result->{id}); | |||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | 2 | ▶ | sub get { | ||||||||
|
Subroutine
get: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 55 | 2 | my $self = shift; | |||||||||
| 56 | 2 | state $check = signature( | |||||||||
| 57 | bless => !!0, | ||||||||||
| 58 | named => [ | ||||||||||
| 59 | fields => Str, { optional => 1 }, | ||||||||||
| 60 | ], | ||||||||||
| 61 | ); | ||||||||||
| 62 | 2 | my $p = $check->(@_); | |||||||||
| 63 | |||||||||||
| 64 | 2 | $self->require_id('get'); | |||||||||
| 65 | |||||||||||
| 66 | 1 | my %params; | |||||||||
| 67 | 1 | ▶ | $params{fields} = $p->{fields} if defined $p->{fields}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 68 | |||||||||||
| 69 | 1 | return $self->api(params => \%params); | |||||||||
| 70 | } | ||||||||||
| 71 | |||||||||||
| 72 | 1 | ▶ | sub update { | ||||||||
|
Subroutine
update: called CC=4 SCAR=23.7
Pod
documented
| |||||||||||
| 73 | 1 | my $self = shift; | |||||||||
| 74 | 1 | state $check = signature( | |||||||||
| 75 | bless => !!0, | ||||||||||
| 76 | named => [ | ||||||||||
| 77 | name => Str, { optional => 1 }, | ||||||||||
| 78 | label_list_visibility => Str, { optional => 1 }, | ||||||||||
| 79 | message_list_visibility => Str, { optional => 1 }, | ||||||||||
| 80 | _extra_ => slurpy HashRef, | ||||||||||
| 81 | ], | ||||||||||
| 82 | ); | ||||||||||
| 83 | 1 | my $p = named_extra($check->(@_)); | |||||||||
| 84 | |||||||||||
| 85 | 1 | $self->require_id('update'); | |||||||||
| 86 | |||||||||||
| 87 | 0 | my %content; | |||||||||
| 88 | 0 | ▶ | $content{name} = delete $p->{name} if defined $p->{name}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 89 | $content{labelListVisibility} = delete $p->{label_list_visibility} | ||||||||||
| 90 | 0 | ▶ | if defined $p->{label_list_visibility}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 91 | $content{messageListVisibility} = delete $p->{message_list_visibility} | ||||||||||
| 92 | 0 | ▶ | if defined $p->{message_list_visibility}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 93 | |||||||||||
| 94 | 0 | DEBUG(sprintf("Updating label '%s'", $self->{id})); | |||||||||
| 95 | 0 | return $self->api( | |||||||||
| 96 | method => 'patch', | ||||||||||
| 97 | content => \%content, | ||||||||||
| 98 | ); | ||||||||||
| 99 | } | ||||||||||
| 100 | |||||||||||
| 101 | 2 | ▶ | sub delete { | ||||||||
|
Subroutine
delete: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 102 | 2 | my $self = shift; | |||||||||
| 103 | |||||||||||
| 104 | 2 | $self->require_id('delete'); | |||||||||
| 105 | |||||||||||
| 106 | 1 | DEBUG(sprintf("Deleting label '%s'", $self->{id})); | |||||||||
| 107 | 1 | return $self->api(method => 'delete'); | |||||||||
| 108 | } | ||||||||||
| 109 | |||||||||||
| 110 | 1 | ▶ | sub label_id { shift->{id}; } | ||||||||
|
Subroutine
label_id: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 111 | 4 | ▶ | sub gmail_api { shift->{gmail_api}; } | ||||||||
|
Subroutine
gmail_api: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 112 | |||||||||||
| 113 | 2 | 1; | |||||||||
| 114 | |||||||||||
| 115 | __END__ | ||||||||||