Twilio/Rest/IpMessaging/V2/Service/Channel/Message.pm

filter: Statementstmt 85.5% 89 / 104 Branchbran n/a Conditioncond 54.5% 6 / 11 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 84.4% 38 / 45 Podpod n/a totaltotal 80.1% 133 / 166 CC 6 SCAR 2.9
CC
6
Cov
83%
delete
2.0
create
2.0
page
2.0
CRAP 1.3
« Twilio/Rest/Chat/V2/Service/Channel/Message.pm ↑ Summary Twilio/Rest/Marketplace/V1/AvailableAddOn.pm »
1 # Generated by tools/generate.pl from Twilio's OpenAPI specs. Do not edit this file.
2 package Twilio::Rest::IpMessaging::V2::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::IpMessaging::V2::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, $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 Attributes => $options->{attributes},
30 Body => $options->{body},
31 DateCreated => Twilio::Serialize::iso8601_date_time($options->{date_created}),
32 DateUpdated => Twilio::Serialize::iso8601_date_time($options->{date_updated}),
33 From => $options->{from},
34 LastUpdatedBy => $options->{last_updated_by},
35 MediaSid => $options->{media_sid},
36 1 };
37  
38 my $response = $self->{version}->handle_request(
39 'POST',
40 $self->{uri},
41 'create',
42 {
43 data => $data,
44 headers => { 'X-Twilio-Webhook-Enabled' => $options->{x_twilio_webhook_enabled}, }
45 }
46 1 );
47 return Twilio::Rest::IpMessaging::V2::Service::Channel::MessageInstance->new(
48 $self->{version}, $response->get_content,
49 $self->{solution}{service_sid},
50 $self->{solution}{channel_sid}
51 1 );
52 }
53  
54 0 ▶sub read {
Subroutine read: not called CC=1 SCAR=6.9
55 0 my ($self, @arguments) = @_;
56 0 return $self->read_records(@arguments);
57 }
58  
59 0 ▶sub stream {
Subroutine stream: not called CC=1 SCAR=6.9
60 0 my ($self, @arguments) = @_;
61 0 return $self->stream_records(@arguments);
62 }
63  
64 1 ▶sub page {
Subroutine page: called CC=2 SCAR=7.0
65 1 my ($self, $options, $page_size, $page_token, $page_number) = @_;
66 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
67  
68 my $params = {
69 Order => $options->{order},
70 1 PageToken => $page_token,
71 Page => $page_number,
72 PageSize => $page_size,
73 };
74  
75 1 my $response = $self->{version}->page('GET', $self->{uri}, { params => $params });
76 1 return $self->_build_page($response);
77 }
78  
79 0 ▶sub get_page {
Subroutine get_page: not called CC=1 SCAR=6.9
80 0 my ($self, $target_url) = @_;
81 0 my $client = $self->{version}->get_domain->get_client;
82 0 return $self->_build_page($client->request('GET', $target_url));
83 }
84  
85 1 ▶sub _build_page {
Subroutine _build_page: called CC=1 SCAR=0.0
86 1 my ($self, $response) = @_;
87 return Twilio::Rest::IpMessaging::V2::Service::Channel::MessagePage->new($self->{version},
88 1 $response, $self->{solution});
89 }
90  
91 3 ▶sub get_context {
Subroutine get_context: called CC=1 SCAR=0.0
92 3 my ($self, $sid) = @_;
93 return Twilio::Rest::IpMessaging::V2::Service::Channel::MessageContext->new(
94 $self->{version},
95 $self->{solution}{service_sid},
96 3 $self->{solution}{channel_sid}, $sid
97 );
98 }
99  
100 package Twilio::Rest::IpMessaging::V2::Service::Channel::MessagePage;
101  
102 2 ▶use parent 'Twilio::Page';
Subroutine BEGIN: called CC=1 SCAR=0.0
103  
104 1 ▶sub records_key { return 'messages' }
Subroutine records_key: called CC=1 SCAR=0.0
105  
106 1 ▶sub build_instance {
Subroutine build_instance: called CC=1 SCAR=0.0
107 1 my ($self, $payload) = @_;
108 return Twilio::Rest::IpMessaging::V2::Service::Channel::MessageInstance->new(
109 $self->{version}, $payload,
110 $self->{solution}{service_sid},
111 $self->{solution}{channel_sid}
112 1 );
113 }
114  
115 package Twilio::Rest::IpMessaging::V2::Service::Channel::MessageContext;
116  
117 2 ▶use parent 'Twilio::InstanceContext';
Subroutine BEGIN: called CC=1 SCAR=0.0
118  
119 2 ▶use Twilio::Serialize;
Subroutine BEGIN: called CC=1 SCAR=0.0
120  
121 3 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
122 3 my ($class, $version, $service_sid, $channel_sid, $sid) = @_;
123 3 my $self = $class->SUPER::new($version);
124 3 $self->{solution} = { service_sid => $service_sid, channel_sid => $channel_sid, sid => $sid };
125 3 $self->{uri} = join q{}, '/Services/', Twilio::Serialize::path_segment($service_sid),
126 '/Channels/', Twilio::Serialize::path_segment($channel_sid), '/Messages/',
127 Twilio::Serialize::path_segment($sid);
128 3 return $self;
129 }
130  
131 1 ▶sub delete {
Subroutine delete: called CC=2 SCAR=7.0
132 1 my ($self, $options) = @_;
133 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
134 $self->{version}->handle_request('DELETE', $self->{uri}, 'delete',
135 1 { headers => { 'X-Twilio-Webhook-Enabled' => $options->{x_twilio_webhook_enabled}, } });
136 1 return 1;
137 }
138  
139 1 ▶sub fetch {
Subroutine fetch: called CC=1 SCAR=0.0
140 1 my ($self) = @_;
141  
142 1 my $response = $self->{version}->handle_request('GET', $self->{uri}, 'fetch');
143 1 return $self->_build_instance($response);
144 }
145  
146 1 ▶sub update {
Subroutine update: called CC=2 SCAR=7.0
147 1 my ($self, $options) = @_;
148 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
149  
150 my $data = {
151 Attributes => $options->{attributes},
152 Body => $options->{body},
153 DateCreated => Twilio::Serialize::iso8601_date_time($options->{date_created}),
154 DateUpdated => Twilio::Serialize::iso8601_date_time($options->{date_updated}),
155 From => $options->{from},
156 LastUpdatedBy => $options->{last_updated_by},
157 1 };
158  
159 my $response = $self->{version}->handle_request(
160 'POST',
161 $self->{uri},
162 'update',
163 {
164 data => $data,
165 headers => { 'X-Twilio-Webhook-Enabled' => $options->{x_twilio_webhook_enabled}, }
166 }
167 1 );
168 1 return $self->_build_instance($response);
169 }
170  
171 2 ▶sub _build_instance {
Subroutine _build_instance: called CC=1 SCAR=0.0
172 2 my ($self, $response) = @_;
173 return Twilio::Rest::IpMessaging::V2::Service::Channel::MessageInstance->new(
174 $self->{version}, $response->get_content,
175 $self->{solution}{service_sid},
176 $self->{solution}{channel_sid},
177 $self->{solution}{sid}
178 2 );
179 }
180  
181 package Twilio::Rest::IpMessaging::V2::Service::Channel::MessageInstance;
182  
183 2 ▶use parent 'Twilio::InstanceResource';
Subroutine BEGIN: called CC=1 SCAR=0.0
184  
185 2 ▶use Twilio::Deserialize;
Subroutine BEGIN: called CC=1 SCAR=0.0
186  
187 4 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
188 4 my ($class, $version, $payload, $service_sid, $channel_sid, $sid) = @_;
189 4 my $self = $class->SUPER::new($version, $payload);
190 $self->{solution} = {
191 service_sid => $service_sid,
192 channel_sid => $channel_sid,
193 sid => $sid // $self->{properties}{sid}
194 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
195 4 return $self;
196 }
197  
198 0 ▶sub delete {
Subroutine delete: not called CC=1 SCAR=6.9
199 0 my ($self, @arguments) = @_;
200 0 return $self->_context->delete(@arguments);
201 }
202  
203 0 ▶sub fetch {
Subroutine fetch: not called CC=1 SCAR=6.9
204 0 my ($self, @arguments) = @_;
205 0 return $self->_context->fetch(@arguments);
206 }
207  
208 0 ▶sub update {
Subroutine update: not called CC=1 SCAR=6.9
209 0 my ($self, @arguments) = @_;
210 0 return $self->_context->update(@arguments);
211 }
212  
213 0 ▶sub _context {
Subroutine _context: not called CC=1 SCAR=6.9
214 0 my ($self) = @_;
215 return Twilio::Rest::IpMessaging::V2::Service::Channel::MessageContext->new(
216 $self->{version},
217 $self->{solution}{service_sid},
218 $self->{solution}{channel_sid},
219 $self->{solution}{sid}
220 0 );
221 }
222  
223 4 ▶sub account_sid { return $_[0]{properties}{account_sid} }
Subroutine account_sid: called CC=1 SCAR=0.0
224 4 ▶sub attributes { return $_[0]{properties}{attributes} }
Subroutine attributes: called CC=1 SCAR=0.0
225 4 ▶sub body { return $_[0]{properties}{body} }
Subroutine body: called CC=1 SCAR=0.0
226 4 ▶sub channel_sid { return $_[0]{properties}{channel_sid} }
Subroutine channel_sid: called CC=1 SCAR=0.0
227 4 ▶sub date_created { return Twilio::Deserialize::date_time($_[0]{properties}{date_created}) }
Subroutine date_created: called CC=1 SCAR=0.0
228 4 ▶sub date_updated { return Twilio::Deserialize::date_time($_[0]{properties}{date_updated}) }
Subroutine date_updated: called CC=1 SCAR=0.0
229 4 ▶sub from { return $_[0]{properties}{from} }
Subroutine from: called CC=1 SCAR=0.0
230 4 ▶sub index { return $_[0]{properties}{index} }
Subroutine index: called CC=1 SCAR=0.0
231 4 ▶sub last_updated_by { return $_[0]{properties}{last_updated_by} }
Subroutine last_updated_by: called CC=1 SCAR=0.0
232 4 ▶sub media { return $_[0]{properties}{media} }
Subroutine media: called CC=1 SCAR=0.0
233 4 ▶sub service_sid { return $_[0]{properties}{service_sid} }
Subroutine service_sid: called CC=1 SCAR=0.0
234 4 ▶sub sid { return $_[0]{properties}{sid} }
Subroutine sid: called CC=1 SCAR=0.0
235 4 ▶sub to { return $_[0]{properties}{to} }
Subroutine to: called CC=1 SCAR=0.0
236 4 ▶sub type { return $_[0]{properties}{type} }
Subroutine type: called CC=1 SCAR=0.0
237 4 ▶sub url { return $_[0]{properties}{url} }
Subroutine url: called CC=1 SCAR=0.0
238 4 ▶sub was_edited { return $_[0]{properties}{was_edited} }
Subroutine was_edited: called CC=1 SCAR=0.0
239  
240 2 1;
241  
242 __END__
« Twilio/Rest/Chat/V2/Service/Channel/Message.pm ↑ Summary Twilio/Rest/Marketplace/V1/AvailableAddOn.pm »