Twilio/Rest/Chat/V2/Service.pm

filter: Statementstmt 82.7% 110 / 133 Branchbran 100% 8 / 8 Conditioncond 57.1% 4 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 81.6% 49 / 60 Podpod n/a totaltotal 80.6% 171 / 212 CC 8 SCAR 3.2
CC
8
Cov
82%
page
2.0
update
2.0
new
2.0
CRAP 1.4
« Twilio/Rest/Sync/V1/Service/SyncList/SyncListItem.pm ↑ Summary Twilio/Rest/IpMessaging/V2/Service.pm »
1 # Generated by tools/generate.pl from Twilio's OpenAPI specs. Do not edit this file.
2 package Twilio::Rest::Chat::V2::Service;
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::ServiceList;
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 49 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
16 49 my ($class, $version) = @_;
17 49 my $self = $class->SUPER::new($version);
18 49 $self->{solution} = {};
19 49 $self->{uri} = '/Services';
20 49 return $self;
21 }
22  
23 1 ▶sub create {
Subroutine create: called CC=1 SCAR=0.0
24 1 my ($self, $friendly_name) = @_;
25  
26 1 my $data = { FriendlyName => $friendly_name, };
27  
28 my $response =
29 1 $self->{version}->handle_request('POST', $self->{uri}, 'create', { data => $data });
30 1 return Twilio::Rest::Chat::V2::ServiceInstance->new($self->{version}, $response->get_content);
31 }
32  
33 0 ▶sub read {
Subroutine read: not called CC=1 SCAR=6.9
34 0 my ($self, @arguments) = @_;
35 0 return $self->read_records(@arguments);
36 }
37  
38 0 ▶sub stream {
Subroutine stream: not called CC=1 SCAR=6.9
39 0 my ($self, @arguments) = @_;
40 0 return $self->stream_records(@arguments);
41 }
42  
43 1 ▶sub page {
Subroutine page: called CC=2 SCAR=7.0
44 1 my ($self, $options, $page_size, $page_token, $page_number) = @_;
45 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
46  
47 1 my $params = {
48 PageToken => $page_token,
49 Page => $page_number,
50 PageSize => $page_size,
51 };
52  
53 1 my $response = $self->{version}->page('GET', $self->{uri}, { params => $params });
54 1 return $self->_build_page($response);
55 }
56  
57 0 ▶sub get_page {
Subroutine get_page: not called CC=1 SCAR=6.9
58 0 my ($self, $target_url) = @_;
59 0 my $client = $self->{version}->get_domain->get_client;
60 0 return $self->_build_page($client->request('GET', $target_url));
61 }
62  
63 1 ▶sub _build_page {
Subroutine _build_page: called CC=1 SCAR=0.0
64 1 my ($self, $response) = @_;
65 1 return Twilio::Rest::Chat::V2::ServicePage->new($self->{version}, $response, $self->{solution});
66 }
67  
68 47 ▶sub get_context {
Subroutine get_context: called CC=1 SCAR=0.0
69 47 my ($self, $sid) = @_;
70 47 return Twilio::Rest::Chat::V2::ServiceContext->new($self->{version}, $sid);
71 }
72  
73 package Twilio::Rest::Chat::V2::ServicePage;
74  
75 2 ▶use parent 'Twilio::Page';
Subroutine BEGIN: called CC=1 SCAR=0.0
76  
77 1 ▶sub records_key { return 'services' }
Subroutine records_key: called CC=1 SCAR=0.0
78  
79 1 ▶sub build_instance {
Subroutine build_instance: called CC=1 SCAR=0.0
80 1 my ($self, $payload) = @_;
81 1 return Twilio::Rest::Chat::V2::ServiceInstance->new($self->{version}, $payload);
82 }
83  
84 package Twilio::Rest::Chat::V2::ServiceContext;
85  
86 2 ▶use parent 'Twilio::InstanceContext';
Subroutine BEGIN: called CC=1 SCAR=0.0
87  
88 2 ▶use Twilio::Serialize;
Subroutine BEGIN: called CC=1 SCAR=0.0
89  
90 47 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
91 47 my ($class, $version, $sid) = @_;
92 47 my $self = $class->SUPER::new($version);
93 47 $self->{solution} = { sid => $sid };
94 47 $self->{uri} = join q{}, '/Services/', Twilio::Serialize::path_segment($sid);
95 47 return $self;
96 }
97  
98 1 ▶sub delete {
Subroutine delete: called CC=1 SCAR=0.0
99 1 my ($self) = @_;
100 1 $self->{version}->handle_request('DELETE', $self->{uri}, 'delete');
101 1 return 1;
102 }
103  
104 1 ▶sub fetch {
Subroutine fetch: called CC=1 SCAR=0.0
105 1 my ($self) = @_;
106  
107 1 my $response = $self->{version}->handle_request('GET', $self->{uri}, 'fetch');
108 1 return $self->_build_instance($response);
109 }
110  
111 1 ▶sub update {
Subroutine update: called CC=2 SCAR=7.0
112 1 my ($self, $options) = @_;
113 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
114  
115 my $data = {
116 ConsumptionReportInterval => $options->{consumption_report_interval},
117 DefaultChannelCreatorRoleSid => $options->{default_channel_creator_role_sid},
118 DefaultChannelRoleSid => $options->{default_channel_role_sid},
119 DefaultServiceRoleSid => $options->{default_service_role_sid},
120 FriendlyName => $options->{friendly_name},
121 'Limits.ChannelMembers' => $options->{limits_channel_members},
122 'Limits.UserChannels' => $options->{limits_user_channels},
123 'Media.CompatibilityMessage' => $options->{media_compatibility_message},
124 'Notifications.AddedToChannel.Enabled' =>
125 Twilio::Serialize::boolean_to_string($options->{notifications_added_to_channel_enabled}),
126 'Notifications.AddedToChannel.Sound' => $options->{notifications_added_to_channel_sound},
127 'Notifications.AddedToChannel.Template' => $options->{notifications_added_to_channel_template},
128 'Notifications.InvitedToChannel.Enabled' =>
129 Twilio::Serialize::boolean_to_string($options->{notifications_invited_to_channel_enabled}),
130 'Notifications.InvitedToChannel.Sound' => $options->{notifications_invited_to_channel_sound},
131 'Notifications.InvitedToChannel.Template' =>
132 $options->{notifications_invited_to_channel_template},
133 'Notifications.LogEnabled' =>
134 Twilio::Serialize::boolean_to_string($options->{notifications_log_enabled}),
135 'Notifications.NewMessage.BadgeCountEnabled' => Twilio::Serialize::boolean_to_string(
136 $options->{notifications_new_message_badge_count_enabled}
137 ),
138 'Notifications.NewMessage.Enabled' =>
139 Twilio::Serialize::boolean_to_string($options->{notifications_new_message_enabled}),
140 'Notifications.NewMessage.Sound' => $options->{notifications_new_message_sound},
141 'Notifications.NewMessage.Template' => $options->{notifications_new_message_template},
142 'Notifications.RemovedFromChannel.Enabled' =>
143 Twilio::Serialize::boolean_to_string($options->{notifications_removed_from_channel_enabled}),
144 'Notifications.RemovedFromChannel.Sound' =>
145 $options->{notifications_removed_from_channel_sound},
146 'Notifications.RemovedFromChannel.Template' =>
147 $options->{notifications_removed_from_channel_template},
148 PostWebhookRetryCount => $options->{post_webhook_retry_count},
149 PostWebhookUrl => $options->{post_webhook_url},
150 PreWebhookRetryCount => $options->{pre_webhook_retry_count},
151 PreWebhookUrl => $options->{pre_webhook_url},
152 ReachabilityEnabled => Twilio::Serialize::boolean_to_string($options->{reachability_enabled}),
153 ReadStatusEnabled => Twilio::Serialize::boolean_to_string($options->{read_status_enabled}),
154 TypingIndicatorTimeout => $options->{typing_indicator_timeout},
155 WebhookFilters => $options->{webhook_filters},
156 WebhookMethod => $options->{webhook_method},
157 1 };
158  
159 my $response =
160 1 $self->{version}->handle_request('POST', $self->{uri}, 'update', { data => $data });
161 1 return $self->_build_instance($response);
162 }
163  
164 2 ▶sub _build_instance {
Subroutine _build_instance: called CC=1 SCAR=0.0
165 2 my ($self, $response) = @_;
166 return Twilio::Rest::Chat::V2::ServiceInstance->new($self->{version}, $response->get_content,
167 2 $self->{solution}{sid});
168 }
169  
170 3 ▶sub bindings {
Subroutine bindings: called CC=2 SCAR=6.9
171 3 my ($self, $sid) = @_;
172 3 require Twilio::Rest::Chat::V2::Service::Binding;
173 my $list =
174 3 Twilio::Rest::Chat::V2::Service::BindingList->new($self->{version}, $self->{solution}{sid});
175 3 ▶ return defined $sid ? $list->get_context($sid) : $list;
Branch: 1 branch
BranchTrueFalseTotal
defined $sid ? : 2 1 3
176 }
177  
178 24 ▶sub channels {
Subroutine channels: called CC=2 SCAR=6.9
179 24 my ($self, $sid) = @_;
180 24 require Twilio::Rest::Chat::V2::Service::Channel;
181 my $list =
182 24 Twilio::Rest::Chat::V2::Service::ChannelList->new($self->{version}, $self->{solution}{sid});
183 24 ▶ return defined $sid ? $list->get_context($sid) : $list;
Branch: 1 branch
BranchTrueFalseTotal
defined $sid ? : 22 2 24
184 }
185  
186 5 ▶sub roles {
Subroutine roles: called CC=2 SCAR=6.9
187 5 my ($self, $sid) = @_;
188 5 require Twilio::Rest::Chat::V2::Service::Role;
189 my $list =
190 5 Twilio::Rest::Chat::V2::Service::RoleList->new($self->{version}, $self->{solution}{sid});
191 5 ▶ return defined $sid ? $list->get_context($sid) : $list;
Branch: 1 branch
BranchTrueFalseTotal
defined $sid ? : 3 2 5
192 }
193  
194 12 ▶sub users {
Subroutine users: called CC=2 SCAR=6.9
195 12 my ($self, $sid) = @_;
196 12 require Twilio::Rest::Chat::V2::Service::User;
197 my $list =
198 12 Twilio::Rest::Chat::V2::Service::UserList->new($self->{version}, $self->{solution}{sid});
199 12 ▶ return defined $sid ? $list->get_context($sid) : $list;
Branch: 1 branch
BranchTrueFalseTotal
defined $sid ? : 10 2 12
200 }
201  
202 package Twilio::Rest::Chat::V2::ServiceInstance;
203  
204 2 ▶use parent 'Twilio::InstanceResource';
Subroutine BEGIN: called CC=1 SCAR=0.0
205  
206 2 ▶use Twilio::Deserialize;
Subroutine BEGIN: called CC=1 SCAR=0.0
207  
208 4 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
209 4 my ($class, $version, $payload, $sid) = @_;
210 4 my $self = $class->SUPER::new($version, $payload);
211 4 ▶ $self->{solution} = { 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
212 4 return $self;
213 }
214  
215 0 ▶sub delete {
Subroutine delete: not called CC=1 SCAR=6.9
216 0 my ($self, @arguments) = @_;
217 0 return $self->_context->delete(@arguments);
218 }
219  
220 0 ▶sub fetch {
Subroutine fetch: not called CC=1 SCAR=6.9
221 0 my ($self, @arguments) = @_;
222 0 return $self->_context->fetch(@arguments);
223 }
224  
225 0 ▶sub update {
Subroutine update: not called CC=1 SCAR=6.9
226 0 my ($self, @arguments) = @_;
227 0 return $self->_context->update(@arguments);
228 }
229  
230 0 ▶sub bindings {
Subroutine bindings: not called CC=1 SCAR=6.9
231 0 my ($self, @arguments) = @_;
232 0 return $self->_context->bindings(@arguments);
233 }
234  
235 0 ▶sub channels {
Subroutine channels: not called CC=1 SCAR=6.9
236 0 my ($self, @arguments) = @_;
237 0 return $self->_context->channels(@arguments);
238 }
239  
240 0 ▶sub roles {
Subroutine roles: not called CC=1 SCAR=6.9
241 0 my ($self, @arguments) = @_;
242 0 return $self->_context->roles(@arguments);
243 }
244  
245 0 ▶sub users {
Subroutine users: not called CC=1 SCAR=6.9
246 0 my ($self, @arguments) = @_;
247 0 return $self->_context->users(@arguments);
248 }
249  
250 0 ▶sub _context {
Subroutine _context: not called CC=1 SCAR=6.9
251 0 my ($self) = @_;
252 0 return Twilio::Rest::Chat::V2::ServiceContext->new($self->{version}, $self->{solution}{sid});
253 }
254  
255 4 ▶sub account_sid { return $_[0]{properties}{account_sid} }
Subroutine account_sid: called CC=1 SCAR=0.0
256 4 ▶sub consumption_report_interval { return $_[0]{properties}{consumption_report_interval} }
Subroutine consumption_report_interval: called CC=1 SCAR=0.0
257 4 ▶sub date_created { return Twilio::Deserialize::date_time($_[0]{properties}{date_created}) }
Subroutine date_created: called CC=1 SCAR=0.0
258 4 ▶sub date_updated { return Twilio::Deserialize::date_time($_[0]{properties}{date_updated}) }
Subroutine date_updated: called CC=1 SCAR=0.0
259 4 ▶sub default_channel_creator_role_sid { return $_[0]{properties}{default_channel_creator_role_sid} }
Subroutine default_channel_creator_role_sid: called CC=1 SCAR=0.0
260 4 ▶sub default_channel_role_sid { return $_[0]{properties}{default_channel_role_sid} }
Subroutine default_channel_role_sid: called CC=1 SCAR=0.0
261 4 ▶sub default_service_role_sid { return $_[0]{properties}{default_service_role_sid} }
Subroutine default_service_role_sid: called CC=1 SCAR=0.0
262 4 ▶sub friendly_name { return $_[0]{properties}{friendly_name} }
Subroutine friendly_name: called CC=1 SCAR=0.0
263 4 ▶sub limits { return $_[0]{properties}{limits} }
Subroutine limits: called CC=1 SCAR=0.0
264 4 ▶sub links { return $_[0]{properties}{links} }
Subroutine links: called CC=1 SCAR=0.0
265 4 ▶sub media { return $_[0]{properties}{media} }
Subroutine media: called CC=1 SCAR=0.0
266 4 ▶sub notifications { return $_[0]{properties}{notifications} }
Subroutine notifications: called CC=1 SCAR=0.0
267 4 ▶sub post_webhook_retry_count { return $_[0]{properties}{post_webhook_retry_count} }
Subroutine post_webhook_retry_count: called CC=1 SCAR=0.0
268 4 ▶sub post_webhook_url { return $_[0]{properties}{post_webhook_url} }
Subroutine post_webhook_url: called CC=1 SCAR=0.0
269 4 ▶sub pre_webhook_retry_count { return $_[0]{properties}{pre_webhook_retry_count} }
Subroutine pre_webhook_retry_count: called CC=1 SCAR=0.0
270 4 ▶sub pre_webhook_url { return $_[0]{properties}{pre_webhook_url} }
Subroutine pre_webhook_url: called CC=1 SCAR=0.0
271 4 ▶sub reachability_enabled { return $_[0]{properties}{reachability_enabled} }
Subroutine reachability_enabled: called CC=1 SCAR=0.0
272 4 ▶sub read_status_enabled { return $_[0]{properties}{read_status_enabled} }
Subroutine read_status_enabled: called CC=1 SCAR=0.0
273 4 ▶sub sid { return $_[0]{properties}{sid} }
Subroutine sid: called CC=1 SCAR=0.0
274 4 ▶sub typing_indicator_timeout { return $_[0]{properties}{typing_indicator_timeout} }
Subroutine typing_indicator_timeout: called CC=1 SCAR=0.0
275 4 ▶sub url { return $_[0]{properties}{url} }
Subroutine url: called CC=1 SCAR=0.0
276 4 ▶sub webhook_filters { return $_[0]{properties}{webhook_filters} }
Subroutine webhook_filters: called CC=1 SCAR=0.0
277 4 ▶sub webhook_method { return $_[0]{properties}{webhook_method} }
Subroutine webhook_method: called CC=1 SCAR=0.0
278  
279 2 1;
280  
281 __END__
« Twilio/Rest/Sync/V1/Service/SyncList/SyncListItem.pm ↑ Summary Twilio/Rest/IpMessaging/V2/Service.pm »