Twilio/Rest/Chat/V1/Service.pm

filter: Statementstmt 83.2% 104 / 125 Branchbran 100% 6 / 6 Conditioncond 57.1% 4 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 82.1% 46 / 56 Podpod n/a totaltotal 80.8% 160 / 198 CC 7 SCAR 3.0
CC
7
Cov
83%
page
2.0
update
2.0
new
2.0
CRAP 1.4
« Twilio/Rest/Conversations/V2/Configuration.pm ↑ Summary Twilio/Rest/IpMessaging/V1/Service.pm »
1 # Generated by tools/generate.pl from Twilio's OpenAPI specs. Do not edit this file.
2 package Twilio::Rest::Chat::V1::Service;
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::Chat::V1::ServiceList;
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 36 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
16 36 my ($class, $version) = @_;
17 36 my $self = $class->SUPER::new($version);
18 36 $self->{solution} = {};
19 36 $self->{uri} = '/Services';
20 36 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::V1::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::V1::ServicePage->new($self->{version}, $response, $self->{solution});
66 }
67  
68 34 ▶sub get_context {
Subroutine get_context: called CC=1 SCAR=0.0
69 34 my ($self, $sid) = @_;
70 34 return Twilio::Rest::Chat::V1::ServiceContext->new($self->{version}, $sid);
71 }
72  
73 package Twilio::Rest::Chat::V1::ServicePage;
74  
75 3 ▶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::V1::ServiceInstance->new($self->{version}, $payload);
82 }
83  
84 package Twilio::Rest::Chat::V1::ServiceContext;
85  
86 3 ▶use parent 'Twilio::InstanceContext';
Subroutine BEGIN: called CC=1 SCAR=0.0
87  
88 3 ▶use Twilio::Serialize;
Subroutine BEGIN: called CC=1 SCAR=0.0
89  
90 34 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
91 34 my ($class, $version, $sid) = @_;
92 34 my $self = $class->SUPER::new($version);
93 34 $self->{solution} = { sid => $sid };
94 34 $self->{uri} = join q{}, '/Services/', Twilio::Serialize::path_segment($sid);
95 34 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 'Notifications.AddedToChannel.Enabled' =>
124 Twilio::Serialize::boolean_to_string($options->{notifications_added_to_channel_enabled}),
125 'Notifications.AddedToChannel.Template' => $options->{notifications_added_to_channel_template},
126 'Notifications.InvitedToChannel.Enabled' =>
127 Twilio::Serialize::boolean_to_string($options->{notifications_invited_to_channel_enabled}),
128 'Notifications.InvitedToChannel.Template' =>
129 $options->{notifications_invited_to_channel_template},
130 'Notifications.NewMessage.Enabled' =>
131 Twilio::Serialize::boolean_to_string($options->{notifications_new_message_enabled}),
132 'Notifications.NewMessage.Template' => $options->{notifications_new_message_template},
133 'Notifications.RemovedFromChannel.Enabled' =>
134 Twilio::Serialize::boolean_to_string($options->{notifications_removed_from_channel_enabled}),
135 'Notifications.RemovedFromChannel.Template' =>
136 $options->{notifications_removed_from_channel_template},
137 PostWebhookUrl => $options->{post_webhook_url},
138 PreWebhookUrl => $options->{pre_webhook_url},
139 ReachabilityEnabled => Twilio::Serialize::boolean_to_string($options->{reachability_enabled}),
140 ReadStatusEnabled => Twilio::Serialize::boolean_to_string($options->{read_status_enabled}),
141 TypingIndicatorTimeout => $options->{typing_indicator_timeout},
142 WebhookFilters => $options->{webhook_filters},
143 WebhookMethod => $options->{webhook_method},
144 'Webhooks.OnChannelAdd.Method' => $options->{webhooks_on_channel_add_method},
145 'Webhooks.OnChannelAdd.Url' => $options->{webhooks_on_channel_add_url},
146 'Webhooks.OnChannelAdded.Method' => $options->{webhooks_on_channel_added_method},
147 'Webhooks.OnChannelAdded.Url' => $options->{webhooks_on_channel_added_url},
148 'Webhooks.OnChannelDestroy.Method' => $options->{webhooks_on_channel_destroy_method},
149 'Webhooks.OnChannelDestroy.Url' => $options->{webhooks_on_channel_destroy_url},
150 'Webhooks.OnChannelDestroyed.Method' => $options->{webhooks_on_channel_destroyed_method},
151 'Webhooks.OnChannelDestroyed.Url' => $options->{webhooks_on_channel_destroyed_url},
152 'Webhooks.OnChannelUpdate.Method' => $options->{webhooks_on_channel_update_method},
153 'Webhooks.OnChannelUpdate.Url' => $options->{webhooks_on_channel_update_url},
154 'Webhooks.OnChannelUpdated.Method' => $options->{webhooks_on_channel_updated_method},
155 'Webhooks.OnChannelUpdated.Url' => $options->{webhooks_on_channel_updated_url},
156 'Webhooks.OnMemberAdd.Method' => $options->{webhooks_on_member_add_method},
157 'Webhooks.OnMemberAdd.Url' => $options->{webhooks_on_member_add_url},
158 'Webhooks.OnMemberAdded.Method' => $options->{webhooks_on_member_added_method},
159 'Webhooks.OnMemberAdded.Url' => $options->{webhooks_on_member_added_url},
160 'Webhooks.OnMemberRemove.Method' => $options->{webhooks_on_member_remove_method},
161 'Webhooks.OnMemberRemove.Url' => $options->{webhooks_on_member_remove_url},
162 'Webhooks.OnMemberRemoved.Method' => $options->{webhooks_on_member_removed_method},
163 'Webhooks.OnMemberRemoved.Url' => $options->{webhooks_on_member_removed_url},
164 'Webhooks.OnMessageRemove.Method' => $options->{webhooks_on_message_remove_method},
165 'Webhooks.OnMessageRemove.Url' => $options->{webhooks_on_message_remove_url},
166 'Webhooks.OnMessageRemoved.Method' => $options->{webhooks_on_message_removed_method},
167 'Webhooks.OnMessageRemoved.Url' => $options->{webhooks_on_message_removed_url},
168 'Webhooks.OnMessageSend.Method' => $options->{webhooks_on_message_send_method},
169 'Webhooks.OnMessageSend.Url' => $options->{webhooks_on_message_send_url},
170 'Webhooks.OnMessageSent.Method' => $options->{webhooks_on_message_sent_method},
171 'Webhooks.OnMessageSent.Url' => $options->{webhooks_on_message_sent_url},
172 'Webhooks.OnMessageUpdate.Method' => $options->{webhooks_on_message_update_method},
173 'Webhooks.OnMessageUpdate.Url' => $options->{webhooks_on_message_update_url},
174 'Webhooks.OnMessageUpdated.Method' => $options->{webhooks_on_message_updated_method},
175 'Webhooks.OnMessageUpdated.Url' => $options->{webhooks_on_message_updated_url},
176 1 };
177  
178 my $response =
179 1 $self->{version}->handle_request('POST', $self->{uri}, 'update', { data => $data });
180 1 return $self->_build_instance($response);
181 }
182  
183 2 ▶sub _build_instance {
Subroutine _build_instance: called CC=1 SCAR=0.0
184 2 my ($self, $response) = @_;
185 return Twilio::Rest::Chat::V1::ServiceInstance->new($self->{version}, $response->get_content,
186 2 $self->{solution}{sid});
187 }
188  
189 19 ▶sub channels {
Subroutine channels: called CC=2 SCAR=6.9
190 19 my ($self, $sid) = @_;
191 19 require Twilio::Rest::Chat::V1::Service::Channel;
192 my $list =
193 19 Twilio::Rest::Chat::V1::Service::ChannelList->new($self->{version}, $self->{solution}{sid});
194 19 ▶ return defined $sid ? $list->get_context($sid) : $list;
Branch: 1 branch
BranchTrueFalseTotal
defined $sid ? : 17 2 19
195 }
196  
197 5 ▶sub roles {
Subroutine roles: called CC=2 SCAR=6.9
198 5 my ($self, $sid) = @_;
199 5 require Twilio::Rest::Chat::V1::Service::Role;
200 my $list =
201 5 Twilio::Rest::Chat::V1::Service::RoleList->new($self->{version}, $self->{solution}{sid});
202 5 ▶ return defined $sid ? $list->get_context($sid) : $list;
Branch: 1 branch
BranchTrueFalseTotal
defined $sid ? : 3 2 5
203 }
204  
205 7 ▶sub users {
Subroutine users: called CC=2 SCAR=6.9
206 7 my ($self, $sid) = @_;
207 7 require Twilio::Rest::Chat::V1::Service::User;
208 my $list =
209 7 Twilio::Rest::Chat::V1::Service::UserList->new($self->{version}, $self->{solution}{sid});
210 7 ▶ return defined $sid ? $list->get_context($sid) : $list;
Branch: 1 branch
BranchTrueFalseTotal
defined $sid ? : 5 2 7
211 }
212  
213 package Twilio::Rest::Chat::V1::ServiceInstance;
214  
215 3 ▶use parent 'Twilio::InstanceResource';
Subroutine BEGIN: called CC=1 SCAR=0.0
216  
217 3 ▶use Twilio::Deserialize;
Subroutine BEGIN: called CC=1 SCAR=0.0
218  
219 4 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
220 4 my ($class, $version, $payload, $sid) = @_;
221 4 my $self = $class->SUPER::new($version, $payload);
222 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
223 4 return $self;
224 }
225  
226 0 ▶sub delete {
Subroutine delete: not called CC=1 SCAR=6.9
227 0 my ($self, @arguments) = @_;
228 0 return $self->_context->delete(@arguments);
229 }
230  
231 0 ▶sub fetch {
Subroutine fetch: not called CC=1 SCAR=6.9
232 0 my ($self, @arguments) = @_;
233 0 return $self->_context->fetch(@arguments);
234 }
235  
236 0 ▶sub update {
Subroutine update: not called CC=1 SCAR=6.9
237 0 my ($self, @arguments) = @_;
238 0 return $self->_context->update(@arguments);
239 }
240  
241 0 ▶sub channels {
Subroutine channels: not called CC=1 SCAR=6.9
242 0 my ($self, @arguments) = @_;
243 0 return $self->_context->channels(@arguments);
244 }
245  
246 0 ▶sub roles {
Subroutine roles: not called CC=1 SCAR=6.9
247 0 my ($self, @arguments) = @_;
248 0 return $self->_context->roles(@arguments);
249 }
250  
251 0 ▶sub users {
Subroutine users: not called CC=1 SCAR=6.9
252 0 my ($self, @arguments) = @_;
253 0 return $self->_context->users(@arguments);
254 }
255  
256 0 ▶sub _context {
Subroutine _context: not called CC=1 SCAR=6.9
257 0 my ($self) = @_;
258 0 return Twilio::Rest::Chat::V1::ServiceContext->new($self->{version}, $self->{solution}{sid});
259 }
260  
261 4 ▶sub account_sid { return $_[0]{properties}{account_sid} }
Subroutine account_sid: called CC=1 SCAR=0.0
262 4 ▶sub consumption_report_interval { return $_[0]{properties}{consumption_report_interval} }
Subroutine consumption_report_interval: called CC=1 SCAR=0.0
263 4 ▶sub date_created { return Twilio::Deserialize::date_time($_[0]{properties}{date_created}) }
Subroutine date_created: called CC=1 SCAR=0.0
264 4 ▶sub date_updated { return Twilio::Deserialize::date_time($_[0]{properties}{date_updated}) }
Subroutine date_updated: called CC=1 SCAR=0.0
265 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
266 4 ▶sub default_channel_role_sid { return $_[0]{properties}{default_channel_role_sid} }
Subroutine default_channel_role_sid: called CC=1 SCAR=0.0
267 4 ▶sub default_service_role_sid { return $_[0]{properties}{default_service_role_sid} }
Subroutine default_service_role_sid: called CC=1 SCAR=0.0
268 4 ▶sub friendly_name { return $_[0]{properties}{friendly_name} }
Subroutine friendly_name: called CC=1 SCAR=0.0
269 4 ▶sub limits { return $_[0]{properties}{limits} }
Subroutine limits: called CC=1 SCAR=0.0
270 4 ▶sub links { return $_[0]{properties}{links} }
Subroutine links: called CC=1 SCAR=0.0
271 4 ▶sub notifications { return $_[0]{properties}{notifications} }
Subroutine notifications: called CC=1 SCAR=0.0
272 4 ▶sub post_webhook_url { return $_[0]{properties}{post_webhook_url} }
Subroutine post_webhook_url: called CC=1 SCAR=0.0
273 4 ▶sub pre_webhook_url { return $_[0]{properties}{pre_webhook_url} }
Subroutine pre_webhook_url: called CC=1 SCAR=0.0
274 4 ▶sub reachability_enabled { return $_[0]{properties}{reachability_enabled} }
Subroutine reachability_enabled: called CC=1 SCAR=0.0
275 4 ▶sub read_status_enabled { return $_[0]{properties}{read_status_enabled} }
Subroutine read_status_enabled: 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 typing_indicator_timeout { return $_[0]{properties}{typing_indicator_timeout} }
Subroutine typing_indicator_timeout: called CC=1 SCAR=0.0
278 4 ▶sub url { return $_[0]{properties}{url} }
Subroutine url: called CC=1 SCAR=0.0
279 4 ▶sub webhook_filters { return $_[0]{properties}{webhook_filters} }
Subroutine webhook_filters: called CC=1 SCAR=0.0
280 4 ▶sub webhook_method { return $_[0]{properties}{webhook_method} }
Subroutine webhook_method: called CC=1 SCAR=0.0
281 4 ▶sub webhooks { return $_[0]{properties}{webhooks} }
Subroutine webhooks: called CC=1 SCAR=0.0
282  
283 3 1;
284  
285 __END__
« Twilio/Rest/Conversations/V2/Configuration.pm ↑ Summary Twilio/Rest/IpMessaging/V1/Service.pm »