Twilio/Rest/Chat/V1/Service/Channel/Message.pm

filter: Statementstmt 85.0% 85 / 100 Branchbran n/a Conditioncond 55.5% 5 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 83.3% 35 / 42 Podpod n/a totaltotal 80.1% 125 / 156 CC 5 SCAR 2.8
CC
5
Cov
83%
create
2.0
page
2.0
update
2.0
CRAP 1.3
« Twilio/Rest/Verify/V2/Service/RateLimit/Bucket.pm ↑ Summary Twilio/Rest/IpMessaging/V1/Service/Channel/Message.pm »
1 # Generated by tools/generate.pl from Twilio's OpenAPI specs. Do not edit this file.
2 package Twilio::Rest::Chat::V1::Service::Channel::Message;
3  
4 2 ▶use 5.016;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 our $VERSION = '2.001';
8  
9 package Twilio::Rest::Chat::V1::Service::Channel::MessageList;
10  
11 2 ▶use parent 'Twilio::ListResource';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 2 ▶use Twilio::Serialize;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 5 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
16 5 my ($class, $version, $service_sid, $channel_sid) = @_;
17 5 my $self = $class->SUPER::new($version);
18 5 $self->{solution} = { service_sid => $service_sid, channel_sid => $channel_sid };
19 5 $self->{uri} = join q{}, '/Services/', Twilio::Serialize::path_segment($service_sid),
20 '/Channels/', Twilio::Serialize::path_segment($channel_sid), '/Messages';
21 5 return $self;
22 }
23  
24 1 ▶sub create {
Subroutine create: called CC=2 SCAR=7.0
25 1 my ($self, $body, $options) = @_;
26 1 ▶ $options //= {};
Condition50%1/2
$options //= {}
l!l
10
MC/DC0%0/1
$options //= {}
$options
Truth table50%1/2
A
A= $options
Aresult
11
00
27  
28 my $data = {
29 Body => $body,
30 Attributes => $options->{attributes},
31 From => $options->{from},
32 1 };
33  
34 my $response =
35 1 $self->{version}->handle_request('POST', $self->{uri}, 'create', { data => $data });
36 return Twilio::Rest::Chat::V1::Service::Channel::MessageInstance->new(
37 $self->{version}, $response->get_content,
38 $self->{solution}{service_sid},
39 $self->{solution}{channel_sid}
40 1 );
41 }
42  
43 0 ▶sub read {
Subroutine read: not called CC=1 SCAR=6.9
44 0 my ($self, @arguments) = @_;
45 0 return $self->read_records(@arguments);
46 }
47  
48 0 ▶sub stream {
Subroutine stream: not called CC=1 SCAR=6.9
49 0 my ($self, @arguments) = @_;
50 0 return $self->stream_records(@arguments);
51 }
52  
53 1 ▶sub page {
Subroutine page: called CC=2 SCAR=7.0
54 1 my ($self, $options, $page_size, $page_token, $page_number) = @_;
55 1 ▶ $options //= {};
Condition50%1/2
$options //= {}
l!l
10
MC/DC0%0/1
$options //= {}
$options
Truth table50%1/2
A
A= $options
Aresult
11
00
56  
57 my $params = {
58 Order => $options->{order},
59 1 PageToken => $page_token,
60 Page => $page_number,
61 PageSize => $page_size,
62 };
63  
64 1 my $response = $self->{version}->page('GET', $self->{uri}, { params => $params });
65 1 return $self->_build_page($response);
66 }
67  
68 0 ▶sub get_page {
Subroutine get_page: not called CC=1 SCAR=6.9
69 0 my ($self, $target_url) = @_;
70 0 my $client = $self->{version}->get_domain->get_client;
71 0 return $self->_build_page($client->request('GET', $target_url));
72 }
73  
74 1 ▶sub _build_page {
Subroutine _build_page: called CC=1 SCAR=0.0
75 1 my ($self, $response) = @_;
76 return Twilio::Rest::Chat::V1::Service::Channel::MessagePage->new($self->{version}, $response,
77 1 $self->{solution});
78 }
79  
80 3 ▶sub get_context {
Subroutine get_context: called CC=1 SCAR=0.0
81 3 my ($self, $sid) = @_;
82 return Twilio::Rest::Chat::V1::Service::Channel::MessageContext->new(
83 $self->{version},
84 $self->{solution}{service_sid},
85 3 $self->{solution}{channel_sid}, $sid
86 );
87 }
88  
89 package Twilio::Rest::Chat::V1::Service::Channel::MessagePage;
90  
91 2 ▶use parent 'Twilio::Page';
Subroutine BEGIN: called CC=1 SCAR=0.0
92  
93 1 ▶sub records_key { return 'messages' }
Subroutine records_key: called CC=1 SCAR=0.0
94  
95 1 ▶sub build_instance {
Subroutine build_instance: called CC=1 SCAR=0.0
96 1 my ($self, $payload) = @_;
97 return Twilio::Rest::Chat::V1::Service::Channel::MessageInstance->new(
98 $self->{version}, $payload,
99 $self->{solution}{service_sid},
100 $self->{solution}{channel_sid}
101 1 );
102 }
103  
104 package Twilio::Rest::Chat::V1::Service::Channel::MessageContext;
105  
106 2 ▶use parent 'Twilio::InstanceContext';
Subroutine BEGIN: called CC=1 SCAR=0.0
107  
108 2 ▶use Twilio::Serialize;
Subroutine BEGIN: called CC=1 SCAR=0.0
109  
110 3 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
111 3 my ($class, $version, $service_sid, $channel_sid, $sid) = @_;
112 3 my $self = $class->SUPER::new($version);
113 3 $self->{solution} = { service_sid => $service_sid, channel_sid => $channel_sid, sid => $sid };
114 3 $self->{uri} = join q{}, '/Services/', Twilio::Serialize::path_segment($service_sid),
115 '/Channels/', Twilio::Serialize::path_segment($channel_sid), '/Messages/',
116 Twilio::Serialize::path_segment($sid);
117 3 return $self;
118 }
119  
120 1 ▶sub delete {
Subroutine delete: called CC=1 SCAR=0.0
121 1 my ($self) = @_;
122 1 $self->{version}->handle_request('DELETE', $self->{uri}, 'delete');
123 1 return 1;
124 }
125  
126 1 ▶sub fetch {
Subroutine fetch: called CC=1 SCAR=0.0
127 1 my ($self) = @_;
128  
129 1 my $response = $self->{version}->handle_request('GET', $self->{uri}, 'fetch');
130 1 return $self->_build_instance($response);
131 }
132  
133 1 ▶sub update {
Subroutine update: called CC=2 SCAR=7.0
134 1 my ($self, $options) = @_;
135 1 ▶ $options //= {};
Condition50%1/2
$options //= {}
l!l
10
MC/DC0%0/1
$options //= {}
$options
Truth table50%1/2
A
A= $options
Aresult
11
00
136  
137 my $data = {
138 Attributes => $options->{attributes},
139 Body => $options->{body},
140 1 };
141  
142 my $response =
143 1 $self->{version}->handle_request('POST', $self->{uri}, 'update', { data => $data });
144 1 return $self->_build_instance($response);
145 }
146  
147 2 ▶sub _build_instance {
Subroutine _build_instance: called CC=1 SCAR=0.0
148 2 my ($self, $response) = @_;
149 return Twilio::Rest::Chat::V1::Service::Channel::MessageInstance->new(
150 $self->{version}, $response->get_content,
151 $self->{solution}{service_sid},
152 $self->{solution}{channel_sid},
153 $self->{solution}{sid}
154 2 );
155 }
156  
157 package Twilio::Rest::Chat::V1::Service::Channel::MessageInstance;
158  
159 2 ▶use parent 'Twilio::InstanceResource';
Subroutine BEGIN: called CC=1 SCAR=0.0
160  
161 2 ▶use Twilio::Deserialize;
Subroutine BEGIN: called CC=1 SCAR=0.0
162  
163 4 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
164 4 my ($class, $version, $payload, $service_sid, $channel_sid, $sid) = @_;
165 4 my $self = $class->SUPER::new($version, $payload);
166 $self->{solution} = {
167 service_sid => $service_sid,
168 channel_sid => $channel_sid,
169 sid => $sid // $self->{properties}{sid}
170 4 ▶ };
Condition66%2/3
$sid // $self->{"properties"}{"sid"}
l!l&&r!l&&!r
220
MC/DC0%0/2
$sid // $self->{"properties"}{"sid"}
$sid $self->{"properties"}{"sid"}
Truth table66%2/3
A // B
A= $sidB= $self->{"properties"}{"sid"}
ABresult
1X1
011
000
171 4 return $self;
172 }
173  
174 0 ▶sub delete {
Subroutine delete: not called CC=1 SCAR=6.9
175 0 my ($self, @arguments) = @_;
176 0 return $self->_context->delete(@arguments);
177 }
178  
179 0 ▶sub fetch {
Subroutine fetch: not called CC=1 SCAR=6.9
180 0 my ($self, @arguments) = @_;
181 0 return $self->_context->fetch(@arguments);
182 }
183  
184 0 ▶sub update {
Subroutine update: not called CC=1 SCAR=6.9
185 0 my ($self, @arguments) = @_;
186 0 return $self->_context->update(@arguments);
187 }
188  
189 0 ▶sub _context {
Subroutine _context: not called CC=1 SCAR=6.9
190 0 my ($self) = @_;
191 return Twilio::Rest::Chat::V1::Service::Channel::MessageContext->new(
192 $self->{version},
193 $self->{solution}{service_sid},
194 $self->{solution}{channel_sid},
195 $self->{solution}{sid}
196 0 );
197 }
198  
199 4 ▶sub account_sid { return $_[0]{properties}{account_sid} }
Subroutine account_sid: called CC=1 SCAR=0.0
200 4 ▶sub attributes { return $_[0]{properties}{attributes} }
Subroutine attributes: called CC=1 SCAR=0.0
201 4 ▶sub body { return $_[0]{properties}{body} }
Subroutine body: called CC=1 SCAR=0.0
202 4 ▶sub channel_sid { return $_[0]{properties}{channel_sid} }
Subroutine channel_sid: called CC=1 SCAR=0.0
203 4 ▶sub date_created { return Twilio::Deserialize::date_time($_[0]{properties}{date_created}) }
Subroutine date_created: called CC=1 SCAR=0.0
204 4 ▶sub date_updated { return Twilio::Deserialize::date_time($_[0]{properties}{date_updated}) }
Subroutine date_updated: called CC=1 SCAR=0.0
205 4 ▶sub from { return $_[0]{properties}{from} }
Subroutine from: called CC=1 SCAR=0.0
206 4 ▶sub index { return $_[0]{properties}{index} }
Subroutine index: called CC=1 SCAR=0.0
207 4 ▶sub service_sid { return $_[0]{properties}{service_sid} }
Subroutine service_sid: called CC=1 SCAR=0.0
208 4 ▶sub sid { return $_[0]{properties}{sid} }
Subroutine sid: called CC=1 SCAR=0.0
209 4 ▶sub to { return $_[0]{properties}{to} }
Subroutine to: called CC=1 SCAR=0.0
210 4 ▶sub url { return $_[0]{properties}{url} }
Subroutine url: called CC=1 SCAR=0.0
211 4 ▶sub was_edited { return $_[0]{properties}{was_edited} }
Subroutine was_edited: called CC=1 SCAR=0.0
212  
213 2 1;
214  
215 __END__
« Twilio/Rest/Verify/V2/Service/RateLimit/Bucket.pm ↑ Summary Twilio/Rest/IpMessaging/V1/Service/Channel/Message.pm »