Twilio/Rest/IpMessaging/V2/Service/User.pm

filter: Statementstmt 83.1% 94 / 113 Branchbran 100% 4 / 4 Conditioncond 55.5% 5 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 80.8% 38 / 47 Podpod n/a totaltotal 79.2% 141 / 178 CC 7 SCAR 3.4
CC
7
Cov
82%
create
2.0
page
2.0
update
2.0
CRAP 1.4
« Twilio/Rest/Chat/V2/Service/User.pm ↑ Summary Twilio/Rest/Proxy/V1/Service.pm »
1 # Generated by tools/generate.pl from Twilio's OpenAPI specs. Do not edit this file.
2 package Twilio::Rest::IpMessaging::V2::Service::User;
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::IpMessaging::V2::Service::UserList;
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 12 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
16 12 my ($class, $version, $service_sid) = @_;
17 12 my $self = $class->SUPER::new($version);
18 12 $self->{solution} = { service_sid => $service_sid };
19 12 $self->{uri} = join q{}, '/Services/', Twilio::Serialize::path_segment($service_sid), '/Users';
20 12 return $self;
21 }
22  
23 1 ▶sub create {
Subroutine create: called CC=2 SCAR=7.0
24 1 my ($self, $identity, $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 Identity => $identity,
29 Attributes => $options->{attributes},
30 FriendlyName => $options->{friendly_name},
31 RoleSid => $options->{role_sid},
32 1 };
33  
34 my $response = $self->{version}->handle_request(
35 'POST',
36 $self->{uri},
37 'create',
38 {
39 data => $data,
40 headers => { 'X-Twilio-Webhook-Enabled' => $options->{x_twilio_webhook_enabled}, }
41 }
42 1 );
43 return Twilio::Rest::IpMessaging::V2::Service::UserInstance->new($self->{version},
44 1 $response->get_content, $self->{solution}{service_sid});
45 }
46  
47 0 ▶sub read {
Subroutine read: not called CC=1 SCAR=6.9
48 0 my ($self, @arguments) = @_;
49 0 return $self->read_records(@arguments);
50 }
51  
52 0 ▶sub stream {
Subroutine stream: not called CC=1 SCAR=6.9
53 0 my ($self, @arguments) = @_;
54 0 return $self->stream_records(@arguments);
55 }
56  
57 1 ▶sub page {
Subroutine page: called CC=2 SCAR=7.0
58 1 my ($self, $options, $page_size, $page_token, $page_number) = @_;
59 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
60  
61 1 my $params = {
62 PageToken => $page_token,
63 Page => $page_number,
64 PageSize => $page_size,
65 };
66  
67 1 my $response = $self->{version}->page('GET', $self->{uri}, { params => $params });
68 1 return $self->_build_page($response);
69 }
70  
71 0 ▶sub get_page {
Subroutine get_page: not called CC=1 SCAR=6.9
72 0 my ($self, $target_url) = @_;
73 0 my $client = $self->{version}->get_domain->get_client;
74 0 return $self->_build_page($client->request('GET', $target_url));
75 }
76  
77 1 ▶sub _build_page {
Subroutine _build_page: called CC=1 SCAR=0.0
78 1 my ($self, $response) = @_;
79 return Twilio::Rest::IpMessaging::V2::Service::UserPage->new($self->{version}, $response,
80 1 $self->{solution});
81 }
82  
83 10 ▶sub get_context {
Subroutine get_context: called CC=1 SCAR=0.0
84 10 my ($self, $sid) = @_;
85 return Twilio::Rest::IpMessaging::V2::Service::UserContext->new($self->{version},
86 10 $self->{solution}{service_sid}, $sid);
87 }
88  
89 package Twilio::Rest::IpMessaging::V2::Service::UserPage;
90  
91 2 ▶use parent 'Twilio::Page';
Subroutine BEGIN: called CC=1 SCAR=0.0
92  
93 1 ▶sub records_key { return 'users' }
Subroutine records_key: called CC=1 SCAR=0.0
94  
95 1 ▶sub build_instance {
Subroutine build_instance: called CC=1 SCAR=0.0
96 1 my ($self, $payload) = @_;
97 return Twilio::Rest::IpMessaging::V2::Service::UserInstance->new($self->{version}, $payload,
98 1 $self->{solution}{service_sid});
99 }
100  
101 package Twilio::Rest::IpMessaging::V2::Service::UserContext;
102  
103 2 ▶use parent 'Twilio::InstanceContext';
Subroutine BEGIN: called CC=1 SCAR=0.0
104  
105 2 ▶use Twilio::Serialize;
Subroutine BEGIN: called CC=1 SCAR=0.0
106  
107 10 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
108 10 my ($class, $version, $service_sid, $sid) = @_;
109 10 my $self = $class->SUPER::new($version);
110 10 $self->{solution} = { service_sid => $service_sid, sid => $sid };
111 10 $self->{uri} = join q{}, '/Services/', Twilio::Serialize::path_segment($service_sid), '/Users/',
112 Twilio::Serialize::path_segment($sid);
113 10 return $self;
114 }
115  
116 1 ▶sub delete {
Subroutine delete: called CC=1 SCAR=0.0
117 1 my ($self) = @_;
118 1 $self->{version}->handle_request('DELETE', $self->{uri}, 'delete');
119 1 return 1;
120 }
121  
122 1 ▶sub fetch {
Subroutine fetch: called CC=1 SCAR=0.0
123 1 my ($self) = @_;
124  
125 1 my $response = $self->{version}->handle_request('GET', $self->{uri}, 'fetch');
126 1 return $self->_build_instance($response);
127 }
128  
129 1 ▶sub update {
Subroutine update: called CC=2 SCAR=7.0
130 1 my ($self, $options) = @_;
131 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
132  
133 my $data = {
134 Attributes => $options->{attributes},
135 FriendlyName => $options->{friendly_name},
136 RoleSid => $options->{role_sid},
137 1 };
138  
139 my $response = $self->{version}->handle_request(
140 'POST',
141 $self->{uri},
142 'update',
143 {
144 data => $data,
145 headers => { 'X-Twilio-Webhook-Enabled' => $options->{x_twilio_webhook_enabled}, }
146 }
147 1 );
148 1 return $self->_build_instance($response);
149 }
150  
151 2 ▶sub _build_instance {
Subroutine _build_instance: called CC=1 SCAR=0.0
152 2 my ($self, $response) = @_;
153 return Twilio::Rest::IpMessaging::V2::Service::UserInstance->new(
154 $self->{version}, $response->get_content,
155 $self->{solution}{service_sid}, $self->{solution}{sid}
156 2 );
157 }
158  
159 3 ▶sub user_bindings {
Subroutine user_bindings: called CC=2 SCAR=6.9
160 3 my ($self, $sid) = @_;
161 3 require Twilio::Rest::IpMessaging::V2::Service::User::UserBinding;
162 my $list = Twilio::Rest::IpMessaging::V2::Service::User::UserBindingList->new(
163 $self->{version},
164 $self->{solution}{service_sid},
165 $self->{solution}{sid}
166 3 );
167 3 ▶ return defined $sid ? $list->get_context($sid) : $list;
Branch: 1 branch
BranchTrueFalseTotal
defined $sid ? : 2 1 3
168 }
169  
170 4 ▶sub user_channels {
Subroutine user_channels: called CC=2 SCAR=6.9
171 4 my ($self, $channel_sid) = @_;
172 4 require Twilio::Rest::IpMessaging::V2::Service::User::UserChannel;
173 my $list = Twilio::Rest::IpMessaging::V2::Service::User::UserChannelList->new(
174 $self->{version},
175 $self->{solution}{service_sid},
176 $self->{solution}{sid}
177 4 );
178 4 ▶ return defined $channel_sid ? $list->get_context($channel_sid) : $list;
Branch: 1 branch
BranchTrueFalseTotal
defined $channel_sid ? : 3 1 4
179 }
180  
181 package Twilio::Rest::IpMessaging::V2::Service::UserInstance;
182  
183 2 ▶use parent 'Twilio::InstanceResource';
Subroutine BEGIN: called CC=1 SCAR=0.0
184  
185 2 ▶use Twilio::Deserialize;
Subroutine BEGIN: called CC=1 SCAR=0.0
186  
187 4 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
188 4 my ($class, $version, $payload, $service_sid, $sid) = @_;
189 4 my $self = $class->SUPER::new($version, $payload);
190 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
191 4 return $self;
192 }
193  
194 0 ▶sub delete {
Subroutine delete: not called CC=1 SCAR=6.9
195 0 my ($self, @arguments) = @_;
196 0 return $self->_context->delete(@arguments);
197 }
198  
199 0 ▶sub fetch {
Subroutine fetch: not called CC=1 SCAR=6.9
200 0 my ($self, @arguments) = @_;
201 0 return $self->_context->fetch(@arguments);
202 }
203  
204 0 ▶sub update {
Subroutine update: not called CC=1 SCAR=6.9
205 0 my ($self, @arguments) = @_;
206 0 return $self->_context->update(@arguments);
207 }
208  
209 0 ▶sub user_bindings {
Subroutine user_bindings: not called CC=1 SCAR=6.9
210 0 my ($self, @arguments) = @_;
211 0 return $self->_context->user_bindings(@arguments);
212 }
213  
214 0 ▶sub user_channels {
Subroutine user_channels: not called CC=1 SCAR=6.9
215 0 my ($self, @arguments) = @_;
216 0 return $self->_context->user_channels(@arguments);
217 }
218  
219 0 ▶sub _context {
Subroutine _context: not called CC=1 SCAR=6.9
220 0 my ($self) = @_;
221 return Twilio::Rest::IpMessaging::V2::Service::UserContext->new(
222 $self->{version},
223 $self->{solution}{service_sid},
224 $self->{solution}{sid}
225 0 );
226 }
227  
228 4 ▶sub account_sid { return $_[0]{properties}{account_sid} }
Subroutine account_sid: called CC=1 SCAR=0.0
229 4 ▶sub attributes { return $_[0]{properties}{attributes} }
Subroutine attributes: called CC=1 SCAR=0.0
230 4 ▶sub date_created { return Twilio::Deserialize::date_time($_[0]{properties}{date_created}) }
Subroutine date_created: called CC=1 SCAR=0.0
231 4 ▶sub date_updated { return Twilio::Deserialize::date_time($_[0]{properties}{date_updated}) }
Subroutine date_updated: called CC=1 SCAR=0.0
232 4 ▶sub friendly_name { return $_[0]{properties}{friendly_name} }
Subroutine friendly_name: called CC=1 SCAR=0.0
233 4 ▶sub identity { return $_[0]{properties}{identity} }
Subroutine identity: called CC=1 SCAR=0.0
234 4 ▶sub is_notifiable { return $_[0]{properties}{is_notifiable} }
Subroutine is_notifiable: called CC=1 SCAR=0.0
235 4 ▶sub is_online { return $_[0]{properties}{is_online} }
Subroutine is_online: called CC=1 SCAR=0.0
236 4 ▶sub joined_channels_count { return $_[0]{properties}{joined_channels_count} }
Subroutine joined_channels_count: called CC=1 SCAR=0.0
237 4 ▶sub links { return $_[0]{properties}{links} }
Subroutine links: called CC=1 SCAR=0.0
238 4 ▶sub role_sid { return $_[0]{properties}{role_sid} }
Subroutine role_sid: called CC=1 SCAR=0.0
239 4 ▶sub service_sid { return $_[0]{properties}{service_sid} }
Subroutine service_sid: called CC=1 SCAR=0.0
240 4 ▶sub sid { return $_[0]{properties}{sid} }
Subroutine sid: called CC=1 SCAR=0.0
241 4 ▶sub url { return $_[0]{properties}{url} }
Subroutine url: called CC=1 SCAR=0.0
242  
243 2 1;
244  
245 __END__
« Twilio/Rest/Chat/V2/Service/User.pm ↑ Summary Twilio/Rest/Proxy/V1/Service.pm »