RestApi/GmailApi1/Draft.pm

filter: Statementstmt 78.4% 40 / 51 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 92.3% 12 / 13 Podpod 88.8% 8 / 9 totaltotal 80.5% 62 / 77 CC 3 SCAR 4.0
CC
3
Cov
76%
get
3.0
create_raw
2.0
send
1.1
CRAP 1.5
« RestApi/SheetsApi4/RangeGroup/Tie/Iterator.pm ↑ Summary RestApi/CalendarApi3.pm »
1 package Google::RestApi::GmailApi1::Draft;
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 { 'drafts' }
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=1 SCAR=0.0
Pod documented
25 1 my $self = shift;
26 1 state $check = signature(
27 bless => !!0,
28 named => [
29 to => Str,
30 subject => Str,
31 body => Str,
32 from => Str, { optional => 1 },
33 cc => Str, { optional => 1 },
34 bcc => Str, { optional => 1 },
35 content_type => Str, { default => 'text/plain' },
36 ],
37 );
38 1 my $p = $check->(@_);
39  
40 1 my $raw = $self->gmail_api()->_build_mime(%$p);
41  
42 1 DEBUG("Creating draft");
43 1 my $result = $self->gmail_api()->api(
44 uri => 'drafts',
45 method => 'post',
46 content => { message => { raw => $raw } },
47 );
48 1 return ref($self)->new(gmail_api => $self->gmail_api(), id => $result->{id});
49 }
50  
51 0 ▶sub create_raw {
Subroutine create_raw: not called CC=1 SCAR=6.9
Pod documented
52 0 my $self = shift;
53 0 state $check = signature(
54 bless => !!0,
55 named => [
56 raw => Str,
57 ],
58 );
59 0 my $p = $check->(@_);
60  
61 0 DEBUG("Creating draft from raw message");
62 my $result = $self->gmail_api()->api(
63 uri => 'drafts',
64 method => 'post',
65 content => { message => { raw => $p->{raw} } },
66 0 );
67 0 return ref($self)->new(gmail_api => $self->gmail_api(), id => $result->{id});
68 }
69  
70 2 ▶sub get {
Subroutine get: called CC=3 SCAR=11.1
Pod documented
71 2 my $self = shift;
72 2 state $check = signature(
73 bless => !!0,
74 named => [
75 format => Str, { optional => 1 },
76 fields => Str, { optional => 1 },
77 ],
78 );
79 2 my $p = $check->(@_);
80  
81 2 $self->require_id('get');
82  
83 1 my %params;
84 1 ▶ $params{format} = $p->{format} if defined $p->{format};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"format"} 0 1 1
85 1 ▶ $params{fields} = $p->{fields} if defined $p->{fields};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"fields"} 0 1 1
86  
87 1 return $self->api(params => \%params);
88 }
89  
90 1 ▶sub update {
Subroutine update: called CC=1 SCAR=0.8
Pod documented
91 1 my $self = shift;
92 1 state $check = signature(
93 bless => !!0,
94 named => [
95 to => Str,
96 subject => Str,
97 body => Str,
98 from => Str, { optional => 1 },
99 cc => Str, { optional => 1 },
100 bcc => Str, { optional => 1 },
101 content_type => Str, { default => 'text/plain' },
102 ],
103 );
104 1 my $p = $check->(@_);
105  
106 1 $self->require_id('update');
107  
108 0 my $raw = $self->gmail_api()->_build_mime(%$p);
109  
110 0 DEBUG(sprintf("Updating draft '%s'", $self->{id}));
111 0 return $self->api(
112 method => 'put',
113 content => { message => { raw => $raw } },
114 );
115 }
116  
117 1 ▶sub send {
Subroutine send: called CC=1 SCAR=1.2
Pod documented
118 1 my $self = shift;
119  
120 1 $self->require_id('send');
121  
122 0 DEBUG(sprintf("Sending draft '%s'", $self->{id}));
123 return $self->gmail_api()->api(
124 uri => 'drafts/send',
125 method => 'post',
126 content => { id => $self->{id} },
127 0 );
128 }
129  
130 2 ▶sub delete {
Subroutine delete: called CC=1 SCAR=0.0
Pod documented
131 2 my $self = shift;
132  
133 2 $self->require_id('delete');
134  
135 1 DEBUG(sprintf("Deleting draft '%s'", $self->{id}));
136 1 return $self->api(method => 'delete');
137 }
138  
139 1 ▶sub draft_id { shift->{id}; }
Subroutine draft_id: called CC=1 SCAR=0.0
Pod documented
140 5 ▶sub gmail_api { shift->{gmail_api}; }
Subroutine gmail_api: called CC=1 SCAR=0.0
Pod documented
141  
142 2 1;
143  
144 __END__
« RestApi/SheetsApi4/RangeGroup/Tie/Iterator.pm ↑ Summary RestApi/CalendarApi3.pm »