Twilio/Rest/Conversations/V1/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/FlexApi/V1/InsightsQuestionnaires.pm ↑ Summary Twilio/Rest/Conversations/V1/Service/Conversation.pm »
1 # Generated by tools/generate.pl from Twilio's OpenAPI specs. Do not edit this file.
2 package Twilio::Rest::Conversations::V1::Conversation;
3  
4 3 ▶use 5.016;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 our $VERSION = '2.001';
8  
9 package Twilio::Rest::Conversations::V1::ConversationList;
10  
11 3 ▶use parent 'Twilio::ListResource';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 3 ▶use Twilio::Serialize;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 23 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
16 23 my ($class, $version) = @_;
17 23 my $self = $class->SUPER::new($version);
18 23 $self->{solution} = {};
19 23 $self->{uri} = '/Conversations';
20 23 return $self;
21 }
22  
23 2 ▶sub create {
Subroutine create: called CC=2 SCAR=7.0
24 2 my ($self, $options) = @_;
25 2 ▶ $options //= {};
Condition50%1/2
$options //= {}
l!l
20
MC/DC0%0/1
$options //= {}
$options
Truth table50%1/2
A
A= $options
Aresult
11
00
26  
27 my $data = {
28 Attributes => $options->{attributes},
29 'Bindings.Email.Address' => $options->{bindings_email_address},
30 'Bindings.Email.Name' => $options->{bindings_email_name},
31 DateCreated => Twilio::Serialize::iso8601_date_time($options->{date_created}),
32 DateUpdated => Twilio::Serialize::iso8601_date_time($options->{date_updated}),
33 FriendlyName => $options->{friendly_name},
34 MessagingServiceSid => $options->{messaging_service_sid},
35 State => $options->{state},
36 'Timers.Closed' => $options->{timers_closed},
37 'Timers.Inactive' => $options->{timers_inactive},
38 UniqueName => $options->{unique_name},
39 2 };
40  
41 my $response = $self->{version}->handle_request(
42 'POST',
43 $self->{uri},
44 'create',
45 {
46 data => $data,
47 headers => { 'X-Twilio-Webhook-Enabled' => $options->{x_twilio_webhook_enabled}, }
48 }
49 2 );
50 return Twilio::Rest::Conversations::V1::ConversationInstance->new($self->{version},
51 2 $response->get_content);
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 EndDate => $options->{end_date},
70 StartDate => $options->{start_date},
71 State => $options->{state},
72 1 PageToken => $page_token,
73 Page => $page_number,
74 PageSize => $page_size,
75 };
76  
77 1 my $response = $self->{version}->page('GET', $self->{uri}, { params => $params });
78 1 return $self->_build_page($response);
79 }
80  
81 0 ▶sub get_page {
Subroutine get_page: not called CC=1 SCAR=6.9
82 0 my ($self, $target_url) = @_;
83 0 my $client = $self->{version}->get_domain->get_client;
84 0 return $self->_build_page($client->request('GET', $target_url));
85 }
86  
87 1 ▶sub _build_page {
Subroutine _build_page: called CC=1 SCAR=0.0
88 1 my ($self, $response) = @_;
89 return Twilio::Rest::Conversations::V1::ConversationPage->new($self->{version}, $response,
90 1 $self->{solution});
91 }
92  
93 20 ▶sub get_context {
Subroutine get_context: called CC=1 SCAR=0.0
94 20 my ($self, $sid) = @_;
95 20 return Twilio::Rest::Conversations::V1::ConversationContext->new($self->{version}, $sid);
96 }
97  
98 package Twilio::Rest::Conversations::V1::ConversationPage;
99  
100 3 ▶use parent 'Twilio::Page';
Subroutine BEGIN: called CC=1 SCAR=0.0
101  
102 1 ▶sub records_key { return 'conversations' }
Subroutine records_key: called CC=1 SCAR=0.0
103  
104 1 ▶sub build_instance {
Subroutine build_instance: called CC=1 SCAR=0.0
105 1 my ($self, $payload) = @_;
106 1 return Twilio::Rest::Conversations::V1::ConversationInstance->new($self->{version}, $payload);
107 }
108  
109 package Twilio::Rest::Conversations::V1::ConversationContext;
110  
111 3 ▶use parent 'Twilio::InstanceContext';
Subroutine BEGIN: called CC=1 SCAR=0.0
112  
113 3 ▶use Twilio::Serialize;
Subroutine BEGIN: called CC=1 SCAR=0.0
114  
115 20 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
116 20 my ($class, $version, $sid) = @_;
117 20 my $self = $class->SUPER::new($version);
118 20 $self->{solution} = { sid => $sid };
119 20 $self->{uri} = join q{}, '/Conversations/', Twilio::Serialize::path_segment($sid);
120 20 return $self;
121 }
122  
123 1 ▶sub delete {
Subroutine delete: called CC=2 SCAR=7.0
124 1 my ($self, $options) = @_;
125 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
126 $self->{version}->handle_request('DELETE', $self->{uri}, 'delete',
127 1 { headers => { 'X-Twilio-Webhook-Enabled' => $options->{x_twilio_webhook_enabled}, } });
128 1 return 1;
129 }
130  
131 1 ▶sub fetch {
Subroutine fetch: called CC=1 SCAR=0.0
132 1 my ($self) = @_;
133  
134 1 my $response = $self->{version}->handle_request('GET', $self->{uri}, 'fetch');
135 1 return $self->_build_instance($response);
136 }
137  
138 1 ▶sub update {
Subroutine update: called CC=2 SCAR=7.0
139 1 my ($self, $options) = @_;
140 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
141  
142 my $data = {
143 Attributes => $options->{attributes},
144 'Bindings.Email.Address' => $options->{bindings_email_address},
145 'Bindings.Email.Name' => $options->{bindings_email_name},
146 DateCreated => Twilio::Serialize::iso8601_date_time($options->{date_created}),
147 DateUpdated => Twilio::Serialize::iso8601_date_time($options->{date_updated}),
148 FriendlyName => $options->{friendly_name},
149 MessagingServiceSid => $options->{messaging_service_sid},
150 State => $options->{state},
151 'Timers.Closed' => $options->{timers_closed},
152 'Timers.Inactive' => $options->{timers_inactive},
153 UniqueName => $options->{unique_name},
154 1 };
155  
156 my $response = $self->{version}->handle_request(
157 'POST',
158 $self->{uri},
159 'update',
160 {
161 data => $data,
162 headers => { 'X-Twilio-Webhook-Enabled' => $options->{x_twilio_webhook_enabled}, }
163 }
164 1 );
165 1 return $self->_build_instance($response);
166 }
167  
168 2 ▶sub _build_instance {
Subroutine _build_instance: called CC=1 SCAR=0.0
169 2 my ($self, $response) = @_;
170 return Twilio::Rest::Conversations::V1::ConversationInstance->new($self->{version},
171 2 $response->get_content, $self->{solution}{sid});
172 }
173  
174 7 ▶sub messages {
Subroutine messages: called CC=2 SCAR=6.9
175 7 my ($self, $sid) = @_;
176 7 require Twilio::Rest::Conversations::V1::Conversation::Message;
177 my $list = Twilio::Rest::Conversations::V1::Conversation::MessageList->new($self->{version},
178 7 $self->{solution}{sid});
179 7 ▶ return defined $sid ? $list->get_context($sid) : $list;
Branch: 1 branch
BranchTrueFalseTotal
defined $sid ? : 5 2 7
180 }
181  
182 5 ▶sub participants {
Subroutine participants: called CC=2 SCAR=6.9
183 5 my ($self, $sid) = @_;
184 5 require Twilio::Rest::Conversations::V1::Conversation::Participant;
185 my $list = Twilio::Rest::Conversations::V1::Conversation::ParticipantList->new($self->{version},
186 5 $self->{solution}{sid});
187 5 ▶ return defined $sid ? $list->get_context($sid) : $list;
Branch: 1 branch
BranchTrueFalseTotal
defined $sid ? : 3 2 5
188 }
189  
190 5 ▶sub webhooks {
Subroutine webhooks: called CC=2 SCAR=6.9
191 5 my ($self, $sid) = @_;
192 5 require Twilio::Rest::Conversations::V1::Conversation::Webhook;
193 my $list = Twilio::Rest::Conversations::V1::Conversation::WebhookList->new($self->{version},
194 5 $self->{solution}{sid});
195 5 ▶ return defined $sid ? $list->get_context($sid) : $list;
Branch: 1 branch
BranchTrueFalseTotal
defined $sid ? : 3 2 5
196 }
197  
198 package Twilio::Rest::Conversations::V1::ConversationInstance;
199  
200 3 ▶use parent 'Twilio::InstanceResource';
Subroutine BEGIN: called CC=1 SCAR=0.0
201  
202 3 ▶use Twilio::Deserialize;
Subroutine BEGIN: called CC=1 SCAR=0.0
203  
204 5 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
205 5 my ($class, $version, $payload, $sid) = @_;
206 5 my $self = $class->SUPER::new($version, $payload);
207 5 ▶ $self->{solution} = { sid => $sid // $self->{properties}{sid} };
Condition66%2/3
$sid // $self->{"properties"}{"sid"}
l!l&&r!l&&!r
230
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
208 5 return $self;
209 }
210  
211 0 ▶sub delete {
Subroutine delete: not called CC=1 SCAR=6.9
212 0 my ($self, @arguments) = @_;
213 0 return $self->_context->delete(@arguments);
214 }
215  
216 0 ▶sub fetch {
Subroutine fetch: not called CC=1 SCAR=6.9
217 0 my ($self, @arguments) = @_;
218 0 return $self->_context->fetch(@arguments);
219 }
220  
221 0 ▶sub update {
Subroutine update: not called CC=1 SCAR=6.9
222 0 my ($self, @arguments) = @_;
223 0 return $self->_context->update(@arguments);
224 }
225  
226 0 ▶sub messages {
Subroutine messages: not called CC=1 SCAR=6.9
227 0 my ($self, @arguments) = @_;
228 0 return $self->_context->messages(@arguments);
229 }
230  
231 0 ▶sub participants {
Subroutine participants: not called CC=1 SCAR=6.9
232 0 my ($self, @arguments) = @_;
233 0 return $self->_context->participants(@arguments);
234 }
235  
236 0 ▶sub webhooks {
Subroutine webhooks: not called CC=1 SCAR=6.9
237 0 my ($self, @arguments) = @_;
238 0 return $self->_context->webhooks(@arguments);
239 }
240  
241 0 ▶sub _context {
Subroutine _context: not called CC=1 SCAR=6.9
242 0 my ($self) = @_;
243 return Twilio::Rest::Conversations::V1::ConversationContext->new($self->{version},
244 0 $self->{solution}{sid});
245 }
246  
247 4 ▶sub account_sid { return $_[0]{properties}{account_sid} }
Subroutine account_sid: called CC=1 SCAR=0.0
248 4 ▶sub attributes { return $_[0]{properties}{attributes} }
Subroutine attributes: called CC=1 SCAR=0.0
249 4 ▶sub bindings { return $_[0]{properties}{bindings} }
Subroutine bindings: called CC=1 SCAR=0.0
250 4 ▶sub chat_service_sid { return $_[0]{properties}{chat_service_sid} }
Subroutine chat_service_sid: called CC=1 SCAR=0.0
251 4 ▶sub date_created { return Twilio::Deserialize::date_time($_[0]{properties}{date_created}) }
Subroutine date_created: called CC=1 SCAR=0.0
252 4 ▶sub date_updated { return Twilio::Deserialize::date_time($_[0]{properties}{date_updated}) }
Subroutine date_updated: called CC=1 SCAR=0.0
253 4 ▶sub friendly_name { return $_[0]{properties}{friendly_name} }
Subroutine friendly_name: called CC=1 SCAR=0.0
254 4 ▶sub links { return $_[0]{properties}{links} }
Subroutine links: called CC=1 SCAR=0.0
255 4 ▶sub messaging_service_sid { return $_[0]{properties}{messaging_service_sid} }
Subroutine messaging_service_sid: called CC=1 SCAR=0.0
256 4 ▶sub sid { return $_[0]{properties}{sid} }
Subroutine sid: called CC=1 SCAR=0.0
257 4 ▶sub state { return $_[0]{properties}{state} }
Subroutine state: called CC=1 SCAR=0.0
258 4 ▶sub timers { return $_[0]{properties}{timers} }
Subroutine timers: called CC=1 SCAR=0.0
259 4 ▶sub unique_name { return $_[0]{properties}{unique_name} }
Subroutine unique_name: called CC=1 SCAR=0.0
260 4 ▶sub url { return $_[0]{properties}{url} }
Subroutine url: called CC=1 SCAR=0.0
261  
262 3 1;
263  
264 __END__
« Twilio/Rest/FlexApi/V1/InsightsQuestionnaires.pm ↑ Summary Twilio/Rest/Conversations/V1/Service/Conversation.pm »