Twilio/Rest/Chat/V2/Service/Channel.pm

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