Twilio/Rest/Conversations/V1/Service/Conversation.pm

filter: Statementstmt 82.5% 99 / 120 Branchbran 100% 6 / 6 Conditioncond 54.5% 6 / 11 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 79.5% 39 / 49 Podpod n/a totaltotal 78.1% 150 / 192 CC 9 SCAR 3.8
CC
9
Cov
81%
delete
2.0
create
2.0
page
2.0
CRAP 1.5
« Twilio/Rest/Conversations/V1/Conversation.pm ↑ Summary Twilio/Rest/Sync/V1/Service.pm »
1 # Generated by tools/generate.pl from Twilio's OpenAPI specs. Do not edit this file.
2 package Twilio::Rest::Conversations::V1::Service::Conversation;
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::Conversations::V1::Service::ConversationList;
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 22 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
16 22 my ($class, $version, $chat_service_sid) = @_;
17 22 my $self = $class->SUPER::new($version);
18 22 $self->{solution} = { chat_service_sid => $chat_service_sid };
19 22 $self->{uri} = join q{}, '/Services/', Twilio::Serialize::path_segment($chat_service_sid),
20 '/Conversations';
21 22 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 'Bindings.Email.Address' => $options->{bindings_email_address},
31 'Bindings.Email.Name' => $options->{bindings_email_name},
32 DateCreated => Twilio::Serialize::iso8601_date_time($options->{date_created}),
33 DateUpdated => Twilio::Serialize::iso8601_date_time($options->{date_updated}),
34 FriendlyName => $options->{friendly_name},
35 MessagingServiceSid => $options->{messaging_service_sid},
36 State => $options->{state},
37 'Timers.Closed' => $options->{timers_closed},
38 'Timers.Inactive' => $options->{timers_inactive},
39 UniqueName => $options->{unique_name},
40 1 };
41  
42 my $response = $self->{version}->handle_request(
43 'POST',
44 $self->{uri},
45 'create',
46 {
47 data => $data,
48 headers => { 'X-Twilio-Webhook-Enabled' => $options->{x_twilio_webhook_enabled}, }
49 }
50 1 );
51 return Twilio::Rest::Conversations::V1::Service::ConversationInstance->new($self->{version},
52 1 $response->get_content, $self->{solution}{chat_service_sid});
53 }
54  
55 0 ▶sub read {
Subroutine read: not called CC=1 SCAR=6.9
56 0 my ($self, @arguments) = @_;
57 0 return $self->read_records(@arguments);
58 }
59  
60 0 ▶sub stream {
Subroutine stream: not called CC=1 SCAR=6.9
61 0 my ($self, @arguments) = @_;
62 0 return $self->stream_records(@arguments);
63 }
64  
65 1 ▶sub page {
Subroutine page: called CC=2 SCAR=7.0
66 1 my ($self, $options, $page_size, $page_token, $page_number) = @_;
67 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
68  
69 my $params = {
70 EndDate => $options->{end_date},
71 StartDate => $options->{start_date},
72 State => $options->{state},
73 1 PageToken => $page_token,
74 Page => $page_number,
75 PageSize => $page_size,
76 };
77  
78 1 my $response = $self->{version}->page('GET', $self->{uri}, { params => $params });
79 1 return $self->_build_page($response);
80 }
81  
82 0 ▶sub get_page {
Subroutine get_page: not called CC=1 SCAR=6.9
83 0 my ($self, $target_url) = @_;
84 0 my $client = $self->{version}->get_domain->get_client;
85 0 return $self->_build_page($client->request('GET', $target_url));
86 }
87  
88 1 ▶sub _build_page {
Subroutine _build_page: called CC=1 SCAR=0.0
89 1 my ($self, $response) = @_;
90 return Twilio::Rest::Conversations::V1::Service::ConversationPage->new($self->{version},
91 1 $response, $self->{solution});
92 }
93  
94 20 ▶sub get_context {
Subroutine get_context: called CC=1 SCAR=0.0
95 20 my ($self, $sid) = @_;
96 return Twilio::Rest::Conversations::V1::Service::ConversationContext->new($self->{version},
97 20 $self->{solution}{chat_service_sid}, $sid);
98 }
99  
100 package Twilio::Rest::Conversations::V1::Service::ConversationPage;
101  
102 2 ▶use parent 'Twilio::Page';
Subroutine BEGIN: called CC=1 SCAR=0.0
103  
104 1 ▶sub records_key { return 'conversations' }
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::Conversations::V1::Service::ConversationInstance->new($self->{version},
109 1 $payload, $self->{solution}{chat_service_sid});
110 }
111  
112 package Twilio::Rest::Conversations::V1::Service::ConversationContext;
113  
114 2 ▶use parent 'Twilio::InstanceContext';
Subroutine BEGIN: called CC=1 SCAR=0.0
115  
116 2 ▶use Twilio::Serialize;
Subroutine BEGIN: called CC=1 SCAR=0.0
117  
118 20 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
119 20 my ($class, $version, $chat_service_sid, $sid) = @_;
120 20 my $self = $class->SUPER::new($version);
121 20 $self->{solution} = { chat_service_sid => $chat_service_sid, sid => $sid };
122 20 $self->{uri} = join q{}, '/Services/', Twilio::Serialize::path_segment($chat_service_sid),
123 '/Conversations/', Twilio::Serialize::path_segment($sid);
124 20 return $self;
125 }
126  
127 1 ▶sub delete {
Subroutine delete: called CC=2 SCAR=7.0
128 1 my ($self, $options) = @_;
129 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
130 $self->{version}->handle_request('DELETE', $self->{uri}, 'delete',
131 1 { headers => { 'X-Twilio-Webhook-Enabled' => $options->{x_twilio_webhook_enabled}, } });
132 1 return 1;
133 }
134  
135 1 ▶sub fetch {
Subroutine fetch: called CC=1 SCAR=0.0
136 1 my ($self) = @_;
137  
138 1 my $response = $self->{version}->handle_request('GET', $self->{uri}, 'fetch');
139 1 return $self->_build_instance($response);
140 }
141  
142 1 ▶sub update {
Subroutine update: called CC=2 SCAR=7.0
143 1 my ($self, $options) = @_;
144 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
145  
146 my $data = {
147 Attributes => $options->{attributes},
148 'Bindings.Email.Address' => $options->{bindings_email_address},
149 'Bindings.Email.Name' => $options->{bindings_email_name},
150 DateCreated => Twilio::Serialize::iso8601_date_time($options->{date_created}),
151 DateUpdated => Twilio::Serialize::iso8601_date_time($options->{date_updated}),
152 FriendlyName => $options->{friendly_name},
153 MessagingServiceSid => $options->{messaging_service_sid},
154 State => $options->{state},
155 'Timers.Closed' => $options->{timers_closed},
156 'Timers.Inactive' => $options->{timers_inactive},
157 UniqueName => $options->{unique_name},
158 1 };
159  
160 my $response = $self->{version}->handle_request(
161 'POST',
162 $self->{uri},
163 'update',
164 {
165 data => $data,
166 headers => { 'X-Twilio-Webhook-Enabled' => $options->{x_twilio_webhook_enabled}, }
167 }
168 1 );
169 1 return $self->_build_instance($response);
170 }
171  
172 2 ▶sub _build_instance {
Subroutine _build_instance: called CC=1 SCAR=0.0
173 2 my ($self, $response) = @_;
174 return Twilio::Rest::Conversations::V1::Service::ConversationInstance->new(
175 $self->{version}, $response->get_content,
176 $self->{solution}{chat_service_sid},
177 $self->{solution}{sid}
178 2 );
179 }
180  
181 7 ▶sub messages {
Subroutine messages: called CC=2 SCAR=6.9
182 7 my ($self, $sid) = @_;
183 7 require Twilio::Rest::Conversations::V1::Service::Conversation::Message;
184 my $list = Twilio::Rest::Conversations::V1::Service::Conversation::MessageList->new(
185 $self->{version},
186 $self->{solution}{chat_service_sid},
187 $self->{solution}{sid}
188 7 );
189 7 ▶ return defined $sid ? $list->get_context($sid) : $list;
Branch: 1 branch
BranchTrueFalseTotal
defined $sid ? : 5 2 7
190 }
191  
192 5 ▶sub participants {
Subroutine participants: called CC=2 SCAR=6.9
193 5 my ($self, $sid) = @_;
194 5 require Twilio::Rest::Conversations::V1::Service::Conversation::Participant;
195 my $list = Twilio::Rest::Conversations::V1::Service::Conversation::ParticipantList->new(
196 $self->{version},
197 $self->{solution}{chat_service_sid},
198 $self->{solution}{sid}
199 5 );
200 5 ▶ return defined $sid ? $list->get_context($sid) : $list;
Branch: 1 branch
BranchTrueFalseTotal
defined $sid ? : 3 2 5
201 }
202  
203 5 ▶sub webhooks {
Subroutine webhooks: called CC=2 SCAR=6.9
204 5 my ($self, $sid) = @_;
205 5 require Twilio::Rest::Conversations::V1::Service::Conversation::Webhook;
206 my $list = Twilio::Rest::Conversations::V1::Service::Conversation::WebhookList->new(
207 $self->{version},
208 $self->{solution}{chat_service_sid},
209 $self->{solution}{sid}
210 5 );
211 5 ▶ return defined $sid ? $list->get_context($sid) : $list;
Branch: 1 branch
BranchTrueFalseTotal
defined $sid ? : 3 2 5
212 }
213  
214 package Twilio::Rest::Conversations::V1::Service::ConversationInstance;
215  
216 2 ▶use parent 'Twilio::InstanceResource';
Subroutine BEGIN: called CC=1 SCAR=0.0
217  
218 2 ▶use Twilio::Deserialize;
Subroutine BEGIN: called CC=1 SCAR=0.0
219  
220 4 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
221 4 my ($class, $version, $payload, $chat_service_sid, $sid) = @_;
222 4 my $self = $class->SUPER::new($version, $payload);
223 $self->{solution} =
224 4 ▶ { chat_service_sid => $chat_service_sid, sid => $sid // $self->{properties}{sid} };
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
225 4 return $self;
226 }
227  
228 0 ▶sub delete {
Subroutine delete: not called CC=1 SCAR=6.9
229 0 my ($self, @arguments) = @_;
230 0 return $self->_context->delete(@arguments);
231 }
232  
233 0 ▶sub fetch {
Subroutine fetch: not called CC=1 SCAR=6.9
234 0 my ($self, @arguments) = @_;
235 0 return $self->_context->fetch(@arguments);
236 }
237  
238 0 ▶sub update {
Subroutine update: not called CC=1 SCAR=6.9
239 0 my ($self, @arguments) = @_;
240 0 return $self->_context->update(@arguments);
241 }
242  
243 0 ▶sub messages {
Subroutine messages: not called CC=1 SCAR=6.9
244 0 my ($self, @arguments) = @_;
245 0 return $self->_context->messages(@arguments);
246 }
247  
248 0 ▶sub participants {
Subroutine participants: not called CC=1 SCAR=6.9
249 0 my ($self, @arguments) = @_;
250 0 return $self->_context->participants(@arguments);
251 }
252  
253 0 ▶sub webhooks {
Subroutine webhooks: not called CC=1 SCAR=6.9
254 0 my ($self, @arguments) = @_;
255 0 return $self->_context->webhooks(@arguments);
256 }
257  
258 0 ▶sub _context {
Subroutine _context: not called CC=1 SCAR=6.9
259 0 my ($self) = @_;
260 return Twilio::Rest::Conversations::V1::Service::ConversationContext->new(
261 $self->{version},
262 $self->{solution}{chat_service_sid},
263 $self->{solution}{sid}
264 0 );
265 }
266  
267 4 ▶sub account_sid { return $_[0]{properties}{account_sid} }
Subroutine account_sid: called CC=1 SCAR=0.0
268 4 ▶sub attributes { return $_[0]{properties}{attributes} }
Subroutine attributes: called CC=1 SCAR=0.0
269 4 ▶sub bindings { return $_[0]{properties}{bindings} }
Subroutine bindings: called CC=1 SCAR=0.0
270 4 ▶sub chat_service_sid { return $_[0]{properties}{chat_service_sid} }
Subroutine chat_service_sid: called CC=1 SCAR=0.0
271 4 ▶sub date_created { return Twilio::Deserialize::date_time($_[0]{properties}{date_created}) }
Subroutine date_created: called CC=1 SCAR=0.0
272 4 ▶sub date_updated { return Twilio::Deserialize::date_time($_[0]{properties}{date_updated}) }
Subroutine date_updated: called CC=1 SCAR=0.0
273 4 ▶sub friendly_name { return $_[0]{properties}{friendly_name} }
Subroutine friendly_name: called CC=1 SCAR=0.0
274 4 ▶sub links { return $_[0]{properties}{links} }
Subroutine links: called CC=1 SCAR=0.0
275 4 ▶sub messaging_service_sid { return $_[0]{properties}{messaging_service_sid} }
Subroutine messaging_service_sid: called CC=1 SCAR=0.0
276 4 ▶sub sid { return $_[0]{properties}{sid} }
Subroutine sid: called CC=1 SCAR=0.0
277 4 ▶sub state { return $_[0]{properties}{state} }
Subroutine state: called CC=1 SCAR=0.0
278 4 ▶sub timers { return $_[0]{properties}{timers} }
Subroutine timers: called CC=1 SCAR=0.0
279 4 ▶sub unique_name { return $_[0]{properties}{unique_name} }
Subroutine unique_name: called CC=1 SCAR=0.0
280 4 ▶sub url { return $_[0]{properties}{url} }
Subroutine url: called CC=1 SCAR=0.0
281  
282 2 1;
283  
284 __END__
« Twilio/Rest/Conversations/V1/Conversation.pm ↑ Summary Twilio/Rest/Sync/V1/Service.pm »