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

filter: Statementstmt 84.3% 81 / 96 Branchbran n/a Conditioncond 55.5% 5 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 81.5% 31 / 38 Podpod n/a totaltotal 79.0% 117 / 148 CC 5 SCAR 3.1
CC
5
Cov
82%
create
2.0
page
2.0
update
2.0
CRAP 1.4
« Twilio/Rest/Chat/V2/Service/Channel/Webhook.pm ↑ Summary Twilio/Rest/IpMessaging/V2/Service/Channel/Webhook.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::Webhook;
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::Conversation::WebhookList;
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, $chat_service_sid, $conversation_sid) = @_;
17 5 my $self = $class->SUPER::new($version);
18 $self->{solution} =
19 5 { chat_service_sid => $chat_service_sid, conversation_sid => $conversation_sid };
20 5 $self->{uri} = join q{}, '/Services/', Twilio::Serialize::path_segment($chat_service_sid),
21 '/Conversations/', Twilio::Serialize::path_segment($conversation_sid), '/Webhooks';
22 5 return $self;
23 }
24  
25 1 ▶sub create {
Subroutine create: called CC=2 SCAR=7.0
26 1 my ($self, $target, $options) = @_;
27 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
28  
29 my $data = {
30 Target => $target,
31 'Configuration.Filters' => $options->{configuration_filters},
32 'Configuration.FlowSid' => $options->{configuration_flow_sid},
33 'Configuration.Method' => $options->{configuration_method},
34 'Configuration.ReplayAfter' => $options->{configuration_replay_after},
35 'Configuration.Triggers' => $options->{configuration_triggers},
36 'Configuration.Url' => $options->{configuration_url},
37 1 };
38  
39 my $response =
40 1 $self->{version}->handle_request('POST', $self->{uri}, 'create', { data => $data });
41 return Twilio::Rest::Conversations::V1::Service::Conversation::WebhookInstance->new(
42 $self->{version}, $response->get_content,
43 $self->{solution}{chat_service_sid},
44 $self->{solution}{conversation_sid}
45 1 );
46 }
47  
48 0 ▶sub read {
Subroutine read: not called CC=1 SCAR=6.9
49 0 my ($self, @arguments) = @_;
50 0 return $self->read_records(@arguments);
51 }
52  
53 0 ▶sub stream {
Subroutine stream: not called CC=1 SCAR=6.9
54 0 my ($self, @arguments) = @_;
55 0 return $self->stream_records(@arguments);
56 }
57  
58 1 ▶sub page {
Subroutine page: called CC=2 SCAR=7.0
59 1 my ($self, $options, $page_size, $page_token, $page_number) = @_;
60 1 ▶ $options //= {};
Condition50%1/2
$options //= {}
l!l
01
MC/DC0%0/1
$options //= {}
$options
Truth table50%1/2
A
A= $options
Aresult
11
00
61  
62 1 my $params = {
63 PageToken => $page_token,
64 Page => $page_number,
65 PageSize => $page_size,
66 };
67  
68 1 my $response = $self->{version}->page('GET', $self->{uri}, { params => $params });
69 1 return $self->_build_page($response);
70 }
71  
72 0 ▶sub get_page {
Subroutine get_page: not called CC=1 SCAR=6.9
73 0 my ($self, $target_url) = @_;
74 0 my $client = $self->{version}->get_domain->get_client;
75 0 return $self->_build_page($client->request('GET', $target_url));
76 }
77  
78 1 ▶sub _build_page {
Subroutine _build_page: called CC=1 SCAR=0.0
79 1 my ($self, $response) = @_;
80 return Twilio::Rest::Conversations::V1::Service::Conversation::WebhookPage->new($self->{version},
81 1 $response, $self->{solution});
82 }
83  
84 3 ▶sub get_context {
Subroutine get_context: called CC=1 SCAR=0.0
85 3 my ($self, $sid) = @_;
86 return Twilio::Rest::Conversations::V1::Service::Conversation::WebhookContext->new(
87 $self->{version},
88 $self->{solution}{chat_service_sid},
89 3 $self->{solution}{conversation_sid}, $sid
90 );
91 }
92  
93 package Twilio::Rest::Conversations::V1::Service::Conversation::WebhookPage;
94  
95 2 ▶use parent 'Twilio::Page';
Subroutine BEGIN: called CC=1 SCAR=0.0
96  
97 1 ▶sub records_key { return 'webhooks' }
Subroutine records_key: called CC=1 SCAR=0.0
98  
99 1 ▶sub build_instance {
Subroutine build_instance: called CC=1 SCAR=0.0
100 1 my ($self, $payload) = @_;
101 return Twilio::Rest::Conversations::V1::Service::Conversation::WebhookInstance->new(
102 $self->{version}, $payload,
103 $self->{solution}{chat_service_sid},
104 $self->{solution}{conversation_sid}
105 1 );
106 }
107  
108 package Twilio::Rest::Conversations::V1::Service::Conversation::WebhookContext;
109  
110 2 ▶use parent 'Twilio::InstanceContext';
Subroutine BEGIN: called CC=1 SCAR=0.0
111  
112 2 ▶use Twilio::Serialize;
Subroutine BEGIN: called CC=1 SCAR=0.0
113  
114 3 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
115 3 my ($class, $version, $chat_service_sid, $conversation_sid, $sid) = @_;
116 3 my $self = $class->SUPER::new($version);
117 $self->{solution} =
118 3 { chat_service_sid => $chat_service_sid, conversation_sid => $conversation_sid, sid => $sid };
119 3 $self->{uri} = join q{}, '/Services/', Twilio::Serialize::path_segment($chat_service_sid),
120 '/Conversations/', Twilio::Serialize::path_segment($conversation_sid), '/Webhooks/',
121 Twilio::Serialize::path_segment($sid);
122 3 return $self;
123 }
124  
125 1 ▶sub delete {
Subroutine delete: called CC=1 SCAR=0.0
126 1 my ($self) = @_;
127 1 $self->{version}->handle_request('DELETE', $self->{uri}, 'delete');
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 'Configuration.Filters' => $options->{configuration_filters},
144 'Configuration.FlowSid' => $options->{configuration_flow_sid},
145 'Configuration.Method' => $options->{configuration_method},
146 'Configuration.Triggers' => $options->{configuration_triggers},
147 'Configuration.Url' => $options->{configuration_url},
148 1 };
149  
150 my $response =
151 1 $self->{version}->handle_request('POST', $self->{uri}, 'update', { data => $data });
152 1 return $self->_build_instance($response);
153 }
154  
155 2 ▶sub _build_instance {
Subroutine _build_instance: called CC=1 SCAR=0.0
156 2 my ($self, $response) = @_;
157 return Twilio::Rest::Conversations::V1::Service::Conversation::WebhookInstance->new(
158 $self->{version}, $response->get_content,
159 $self->{solution}{chat_service_sid},
160 $self->{solution}{conversation_sid},
161 $self->{solution}{sid}
162 2 );
163 }
164  
165 package Twilio::Rest::Conversations::V1::Service::Conversation::WebhookInstance;
166  
167 2 ▶use parent 'Twilio::InstanceResource';
Subroutine BEGIN: called CC=1 SCAR=0.0
168  
169 2 ▶use Twilio::Deserialize;
Subroutine BEGIN: called CC=1 SCAR=0.0
170  
171 4 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
172 4 my ($class, $version, $payload, $chat_service_sid, $conversation_sid, $sid) = @_;
173 4 my $self = $class->SUPER::new($version, $payload);
174 $self->{solution} = {
175 chat_service_sid => $chat_service_sid,
176 conversation_sid => $conversation_sid,
177 sid => $sid // $self->{properties}{sid}
178 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
179 4 return $self;
180 }
181  
182 0 ▶sub delete {
Subroutine delete: not called CC=1 SCAR=6.9
183 0 my ($self, @arguments) = @_;
184 0 return $self->_context->delete(@arguments);
185 }
186  
187 0 ▶sub fetch {
Subroutine fetch: not called CC=1 SCAR=6.9
188 0 my ($self, @arguments) = @_;
189 0 return $self->_context->fetch(@arguments);
190 }
191  
192 0 ▶sub update {
Subroutine update: not called CC=1 SCAR=6.9
193 0 my ($self, @arguments) = @_;
194 0 return $self->_context->update(@arguments);
195 }
196  
197 0 ▶sub _context {
Subroutine _context: not called CC=1 SCAR=6.9
198 0 my ($self) = @_;
199 return Twilio::Rest::Conversations::V1::Service::Conversation::WebhookContext->new(
200 $self->{version},
201 $self->{solution}{chat_service_sid},
202 $self->{solution}{conversation_sid},
203 $self->{solution}{sid}
204 0 );
205 }
206  
207 4 ▶sub account_sid { return $_[0]{properties}{account_sid} }
Subroutine account_sid: called CC=1 SCAR=0.0
208 4 ▶sub chat_service_sid { return $_[0]{properties}{chat_service_sid} }
Subroutine chat_service_sid: called CC=1 SCAR=0.0
209 4 ▶sub configuration { return $_[0]{properties}{configuration} }
Subroutine configuration: called CC=1 SCAR=0.0
210 4 ▶sub conversation_sid { return $_[0]{properties}{conversation_sid} }
Subroutine conversation_sid: called CC=1 SCAR=0.0
211 4 ▶sub date_created { return Twilio::Deserialize::date_time($_[0]{properties}{date_created}) }
Subroutine date_created: called CC=1 SCAR=0.0
212 4 ▶sub date_updated { return Twilio::Deserialize::date_time($_[0]{properties}{date_updated}) }
Subroutine date_updated: called CC=1 SCAR=0.0
213 4 ▶sub sid { return $_[0]{properties}{sid} }
Subroutine sid: called CC=1 SCAR=0.0
214 4 ▶sub target { return $_[0]{properties}{target} }
Subroutine target: called CC=1 SCAR=0.0
215 4 ▶sub url { return $_[0]{properties}{url} }
Subroutine url: called CC=1 SCAR=0.0
216  
217 2 1;
218  
219 __END__
« Twilio/Rest/Chat/V2/Service/Channel/Webhook.pm ↑ Summary Twilio/Rest/IpMessaging/V2/Service/Channel/Webhook.pm »