Twilio/Rest/Api/V2010/Account/Message.pm

filter: Statementstmt 100% 118 / 118 Branchbran 100% 2 / 2 Conditioncond 100% 9 / 9 MC/DCmcdc 100% 5 / 5 Subroutinesub 100% 53 / 53 Podpod n/a totaltotal 100% 187 / 187 CC 6 SCAR 1.6
CC
6
Cov
100%
create
2.0
page
2.0
update
2.0
CRAP 1.2
« Twilio/Rest/Accounts/V1/MessagingGeopermissions.pm ↑ Summary Twilio/Rest/Messaging/V1/DomainCerts.pm »
1 # Generated by tools/generate.pl from Twilio's OpenAPI specs. Do not edit this file.
2 package Twilio::Rest::Api::V2010::Account::Message;
3  
4 12 ▶use 5.016;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 12 our $VERSION = '2.001';
8  
9 package Twilio::Rest::Api::V2010::Account::MessageList;
10  
11 12 ▶use parent 'Twilio::ListResource';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 12 ▶use Twilio::Serialize;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 86 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
16 86 my ($class, $version, $account_sid) = @_;
17 86 my $self = $class->SUPER::new($version);
18 86 $self->{solution} = { account_sid => $account_sid };
19 86 $self->{uri} = join q{}, '/Accounts/', Twilio::Serialize::path_segment($account_sid),
20 '/Messages.json';
21 86 return $self;
22 }
23  
24 20 ▶sub create {
Subroutine create: called CC=2 SCAR=6.9
25 20 my ($self, $to, $options) = @_;
26 20 ▶ $options //= {};
Condition100%2/2
$options //= {}
l!l
182
MC/DC100%1/1
$options //= {}
$options
Truth table100%2/2
A
A= $options
Aresult
11
00
27  
28 my $data = {
29 To => $to,
30 AddressRetention => $options->{address_retention},
31 ApplicationSid => $options->{application_sid},
32 Attempt => $options->{attempt},
33 Body => $options->{body},
34 ContentRetention => $options->{content_retention},
35 ContentSid => $options->{content_sid},
36 ContentVariables => $options->{content_variables},
37 FallbackFrom => $options->{fallback_from},
38 ForceDelivery => Twilio::Serialize::boolean_to_string($options->{force_delivery}),
39 From => $options->{from},
40 MaxPrice => $options->{max_price},
41 MediaUrl => $options->{media_url},
42 MessageIntent => $options->{message_intent},
43 MessagingServiceSid => $options->{messaging_service_sid},
44 PersistentAction => $options->{persistent_action},
45 ProvideFeedback => Twilio::Serialize::boolean_to_string($options->{provide_feedback}),
46 RiskCheck => $options->{risk_check},
47 ScheduleType => $options->{schedule_type},
48 SendAsMms => Twilio::Serialize::boolean_to_string($options->{send_as_mms}),
49 SendAt => Twilio::Serialize::iso8601_date_time($options->{send_at}),
50 ShortenUrls => Twilio::Serialize::boolean_to_string($options->{shorten_urls}),
51 SmartEncoded => Twilio::Serialize::boolean_to_string($options->{smart_encoded}),
52 StatusCallback => $options->{status_callback},
53 TrafficType => $options->{traffic_type},
54 ValidityPeriod => $options->{validity_period},
55 20 };
56  
57 my $response =
58 20 $self->{version}->handle_request('POST', $self->{uri}, 'create', { data => $data });
59 return Twilio::Rest::Api::V2010::Account::MessageInstance->new($self->{version},
60 18 $response->get_content, $self->{solution}{account_sid});
61 }
62  
63 15 ▶sub read {
Subroutine read: called CC=1 SCAR=0.0
64 15 my ($self, @arguments) = @_;
65 15 return $self->read_records(@arguments);
66 }
67  
68 3 ▶sub stream {
Subroutine stream: called CC=1 SCAR=0.0
69 3 my ($self, @arguments) = @_;
70 3 return $self->stream_records(@arguments);
71 }
72  
73 21 ▶sub page {
Subroutine page: called CC=2 SCAR=6.9
74 21 my ($self, $options, $page_size, $page_token, $page_number) = @_;
75 21 ▶ $options //= {};
Condition100%2/2
$options //= {}
l!l
147
MC/DC100%1/1
$options //= {}
$options
Truth table100%2/2
A
A= $options
Aresult
11
00
76  
77 my $params = {
78 DateSent => Twilio::Serialize::iso8601_date_time($options->{date_sent}),
79 'DateSent<' => Twilio::Serialize::iso8601_date_time($options->{date_sent_before}),
80 'DateSent>' => Twilio::Serialize::iso8601_date_time($options->{date_sent_after}),
81 From => $options->{from},
82 To => $options->{to},
83 21 PageToken => $page_token,
84 Page => $page_number,
85 PageSize => $page_size,
86 };
87  
88 21 my $response = $self->{version}->page('GET', $self->{uri}, { params => $params });
89 21 return $self->_build_page($response);
90 }
91  
92 1 ▶sub get_page {
Subroutine get_page: called CC=1 SCAR=0.0
93 1 my ($self, $target_url) = @_;
94 1 my $client = $self->{version}->get_domain->get_client;
95 1 return $self->_build_page($client->request('GET', $target_url));
96 }
97  
98 22 ▶sub _build_page {
Subroutine _build_page: called CC=1 SCAR=0.0
99 22 my ($self, $response) = @_;
100 return Twilio::Rest::Api::V2010::Account::MessagePage->new($self->{version}, $response,
101 22 $self->{solution});
102 }
103  
104 43 ▶sub get_context {
Subroutine get_context: called CC=1 SCAR=0.0
105 43 my ($self, $sid) = @_;
106 return Twilio::Rest::Api::V2010::Account::MessageContext->new($self->{version},
107 43 $self->{solution}{account_sid}, $sid);
108 }
109  
110 package Twilio::Rest::Api::V2010::Account::MessagePage;
111  
112 12 ▶use parent 'Twilio::Page';
Subroutine BEGIN: called CC=1 SCAR=0.0
113  
114 25 ▶sub records_key { return 'messages' }
Subroutine records_key: called CC=1 SCAR=0.0
115  
116 20 ▶sub build_instance {
Subroutine build_instance: called CC=1 SCAR=0.0
117 20 my ($self, $payload) = @_;
118 return Twilio::Rest::Api::V2010::Account::MessageInstance->new($self->{version}, $payload,
119 20 $self->{solution}{account_sid});
120 }
121  
122 package Twilio::Rest::Api::V2010::Account::MessageContext;
123  
124 12 ▶use parent 'Twilio::InstanceContext';
Subroutine BEGIN: called CC=1 SCAR=0.0
125  
126 12 ▶use Twilio::Serialize;
Subroutine BEGIN: called CC=1 SCAR=0.0
127  
128 51 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
129 51 my ($class, $version, $account_sid, $sid) = @_;
130 51 my $self = $class->SUPER::new($version);
131 51 $self->{solution} = { account_sid => $account_sid, sid => $sid };
132 51 $self->{uri} = join q{}, '/Accounts/', Twilio::Serialize::path_segment($account_sid),
133 '/Messages/', Twilio::Serialize::path_segment($sid), '.json';
134 51 return $self;
135 }
136  
137 6 ▶sub delete {
Subroutine delete: called CC=1 SCAR=0.0
138 6 my ($self) = @_;
139 6 $self->{version}->handle_request('DELETE', $self->{uri}, 'delete');
140 5 return 1;
141 }
142  
143 28 ▶sub fetch {
Subroutine fetch: called CC=1 SCAR=0.0
144 28 my ($self) = @_;
145  
146 28 my $response = $self->{version}->handle_request('GET', $self->{uri}, 'fetch');
147 25 return $self->_build_instance($response);
148 }
149  
150 6 ▶sub update {
Subroutine update: called CC=2 SCAR=6.9
151 6 my ($self, $options) = @_;
152 6 ▶ $options //= {};
Condition100%2/2
$options //= {}
l!l
51
MC/DC100%1/1
$options //= {}
$options
Truth table100%2/2
A
A= $options
Aresult
11
00
153  
154 my $data = {
155 Body => $options->{body},
156 Status => $options->{status},
157 6 };
158  
159 my $response =
160 6 $self->{version}->handle_request('POST', $self->{uri}, 'update', { data => $data });
161 5 return $self->_build_instance($response);
162 }
163  
164 30 ▶sub _build_instance {
Subroutine _build_instance: called CC=1 SCAR=0.0
165 30 my ($self, $response) = @_;
166 return Twilio::Rest::Api::V2010::Account::MessageInstance->new(
167 $self->{version}, $response->get_content,
168 $self->{solution}{account_sid}, $self->{solution}{sid}
169 30 );
170 }
171  
172 2 ▶sub feedback {
Subroutine feedback: called CC=1 SCAR=0.0
173 2 my ($self) = @_;
174 2 require Twilio::Rest::Api::V2010::Account::Message::Feedback;
175 return Twilio::Rest::Api::V2010::Account::Message::FeedbackList->new(
176 $self->{version},
177 $self->{solution}{account_sid},
178 $self->{solution}{sid}
179 2 );
180 }
181  
182 7 ▶sub media {
Subroutine media: called CC=2 SCAR=6.9
183 7 my ($self, $sid) = @_;
184 7 require Twilio::Rest::Api::V2010::Account::Message::Media;
185 my $list = Twilio::Rest::Api::V2010::Account::Message::MediaList->new(
186 $self->{version},
187 $self->{solution}{account_sid},
188 $self->{solution}{sid}
189 7 );
190 7 ▶ return defined $sid ? $list->get_context($sid) : $list;
Branch: 1 branch
BranchTrueFalseTotal
defined $sid ? : 3 4 7
191 }
192  
193 package Twilio::Rest::Api::V2010::Account::MessageInstance;
194  
195 12 ▶use parent 'Twilio::InstanceResource';
Subroutine BEGIN: called CC=1 SCAR=0.0
196  
197 12 ▶use Twilio::Deserialize;
Subroutine BEGIN: called CC=1 SCAR=0.0
198  
199 68 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
200 68 my ($class, $version, $payload, $account_sid, $sid) = @_;
201 68 my $self = $class->SUPER::new($version, $payload);
202 68 ▶ $self->{solution} = { account_sid => $account_sid, sid => $sid // $self->{properties}{sid} };
Condition100%3/3
$sid // $self->{"properties"}{"sid"}
l!l&&r!l&&!r
30371
MC/DC100%2/2
$sid // $self->{"properties"}{"sid"}
$sid $self->{"properties"}{"sid"}
Truth table100%3/3
A // B
A= $sidB= $self->{"properties"}{"sid"}
ABresult
1X1
011
000
203 68 return $self;
204 }
205  
206 1 ▶sub delete {
Subroutine delete: called CC=1 SCAR=0.0
207 1 my ($self, @arguments) = @_;
208 1 return $self->_context->delete(@arguments);
209 }
210  
211 2 ▶sub fetch {
Subroutine fetch: called CC=1 SCAR=0.0
212 2 my ($self, @arguments) = @_;
213 2 return $self->_context->fetch(@arguments);
214 }
215  
216 1 ▶sub update {
Subroutine update: called CC=1 SCAR=0.0
217 1 my ($self, @arguments) = @_;
218 1 return $self->_context->update(@arguments);
219 }
220  
221 1 ▶sub feedback {
Subroutine feedback: called CC=1 SCAR=0.0
222 1 my ($self, @arguments) = @_;
223 1 return $self->_context->feedback(@arguments);
224 }
225  
226 3 ▶sub media {
Subroutine media: called CC=1 SCAR=0.0
227 3 my ($self, @arguments) = @_;
228 3 return $self->_context->media(@arguments);
229 }
230  
231 8 ▶sub _context {
Subroutine _context: called CC=1 SCAR=0.0
232 8 my ($self) = @_;
233 return Twilio::Rest::Api::V2010::Account::MessageContext->new(
234 $self->{version},
235 $self->{solution}{account_sid},
236 $self->{solution}{sid}
237 8 );
238 }
239  
240 5 ▶sub account_sid { return $_[0]{properties}{account_sid} }
Subroutine account_sid: called CC=1 SCAR=0.0
241 5 ▶sub api_version { return $_[0]{properties}{api_version} }
Subroutine api_version: called CC=1 SCAR=0.0
242 12 ▶sub body { return $_[0]{properties}{body} }
Subroutine body: called CC=1 SCAR=0.0
243 7 ▶sub date_created { return Twilio::Deserialize::date_time($_[0]{properties}{date_created}) }
Subroutine date_created: called CC=1 SCAR=0.0
244 7 ▶sub date_sent { return Twilio::Deserialize::date_time($_[0]{properties}{date_sent}) }
Subroutine date_sent: called CC=1 SCAR=0.0
245 5 ▶sub date_updated { return Twilio::Deserialize::date_time($_[0]{properties}{date_updated}) }
Subroutine date_updated: called CC=1 SCAR=0.0
246 5 ▶sub direction { return $_[0]{properties}{direction} }
Subroutine direction: called CC=1 SCAR=0.0
247 5 ▶sub error_code { return $_[0]{properties}{error_code} }
Subroutine error_code: called CC=1 SCAR=0.0
248 5 ▶sub error_message { return $_[0]{properties}{error_message} }
Subroutine error_message: called CC=1 SCAR=0.0
249 6 ▶sub from { return $_[0]{properties}{from} }
Subroutine from: called CC=1 SCAR=0.0
250 5 ▶sub messaging_service_sid { return $_[0]{properties}{messaging_service_sid} }
Subroutine messaging_service_sid: called CC=1 SCAR=0.0
251 5 ▶sub num_media { return $_[0]{properties}{num_media} }
Subroutine num_media: called CC=1 SCAR=0.0
252 5 ▶sub num_segments { return $_[0]{properties}{num_segments} }
Subroutine num_segments: called CC=1 SCAR=0.0
253 5 ▶sub price { return $_[0]{properties}{price} }
Subroutine price: called CC=1 SCAR=0.0
254 5 ▶sub price_unit { return $_[0]{properties}{price_unit} }
Subroutine price_unit: called CC=1 SCAR=0.0
255 30 ▶sub sid { return $_[0]{properties}{sid} }
Subroutine sid: called CC=1 SCAR=0.0
256 12 ▶sub status { return $_[0]{properties}{status} }
Subroutine status: called CC=1 SCAR=0.0
257 6 ▶sub subresource_uris { return $_[0]{properties}{subresource_uris} }
Subroutine subresource_uris: called CC=1 SCAR=0.0
258 5 ▶sub to { return $_[0]{properties}{to} }
Subroutine to: called CC=1 SCAR=0.0
259 5 ▶sub uri { return $_[0]{properties}{uri} }
Subroutine uri: called CC=1 SCAR=0.0
260  
261 12 1;
262  
263 __END__
« Twilio/Rest/Accounts/V1/MessagingGeopermissions.pm ↑ Summary Twilio/Rest/Messaging/V1/DomainCerts.pm »