Twilio/Rest/Conversations/V1/User.pm

filter: Statementstmt 84.1% 90 / 107 Branchbran 100% 2 / 2 Conditioncond 54.5% 6 / 11 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 81.8% 36 / 44 Podpod n/a totaltotal 78.8% 134 / 170 CC 7 SCAR 3.4
CC
7
Cov
82%
delete
2.0
create
2.0
page
2.0
CRAP 1.4
« Twilio/Rest/Conversations/V1/Service/User.pm ↑ Summary Twilio/Rest/Chat/V2/Service/User.pm »
1 # Generated by tools/generate.pl from Twilio's OpenAPI specs. Do not edit this file.
2 package Twilio::Rest::Conversations::V1::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::Conversations::V1::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 9 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
16 9 my ($class, $version) = @_;
17 9 my $self = $class->SUPER::new($version);
18 9 $self->{solution} = {};
19 9 $self->{uri} = '/Users';
20 9 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::Conversations::V1::UserInstance->new($self->{version},
44 1 $response->get_content);
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::Conversations::V1::UserPage->new($self->{version}, $response,
80 1 $self->{solution});
81 }
82  
83 7 ▶sub get_context {
Subroutine get_context: called CC=1 SCAR=0.0
84 7 my ($self, $sid) = @_;
85 7 return Twilio::Rest::Conversations::V1::UserContext->new($self->{version}, $sid);
86 }
87  
88 package Twilio::Rest::Conversations::V1::UserPage;
89  
90 2 ▶use parent 'Twilio::Page';
Subroutine BEGIN: called CC=1 SCAR=0.0
91  
92 1 ▶sub records_key { return 'users' }
Subroutine records_key: called CC=1 SCAR=0.0
93  
94 1 ▶sub build_instance {
Subroutine build_instance: called CC=1 SCAR=0.0
95 1 my ($self, $payload) = @_;
96 1 return Twilio::Rest::Conversations::V1::UserInstance->new($self->{version}, $payload);
97 }
98  
99 package Twilio::Rest::Conversations::V1::UserContext;
100  
101 2 ▶use parent 'Twilio::InstanceContext';
Subroutine BEGIN: called CC=1 SCAR=0.0
102  
103 2 ▶use Twilio::Serialize;
Subroutine BEGIN: called CC=1 SCAR=0.0
104  
105 7 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
106 7 my ($class, $version, $sid) = @_;
107 7 my $self = $class->SUPER::new($version);
108 7 $self->{solution} = { sid => $sid };
109 7 $self->{uri} = join q{}, '/Users/', Twilio::Serialize::path_segment($sid);
110 7 return $self;
111 }
112  
113 1 ▶sub delete {
Subroutine delete: called CC=2 SCAR=7.0
114 1 my ($self, $options) = @_;
115 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
116 $self->{version}->handle_request('DELETE', $self->{uri}, 'delete',
117 1 { headers => { 'X-Twilio-Webhook-Enabled' => $options->{x_twilio_webhook_enabled}, } });
118 1 return 1;
119 }
120  
121 1 ▶sub fetch {
Subroutine fetch: called CC=1 SCAR=0.0
122 1 my ($self) = @_;
123  
124 1 my $response = $self->{version}->handle_request('GET', $self->{uri}, 'fetch');
125 1 return $self->_build_instance($response);
126 }
127  
128 1 ▶sub update {
Subroutine update: called CC=2 SCAR=7.0
129 1 my ($self, $options) = @_;
130 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
131  
132 my $data = {
133 Attributes => $options->{attributes},
134 FriendlyName => $options->{friendly_name},
135 RoleSid => $options->{role_sid},
136 1 };
137  
138 my $response = $self->{version}->handle_request(
139 'POST',
140 $self->{uri},
141 'update',
142 {
143 data => $data,
144 headers => { 'X-Twilio-Webhook-Enabled' => $options->{x_twilio_webhook_enabled}, }
145 }
146 1 );
147 1 return $self->_build_instance($response);
148 }
149  
150 2 ▶sub _build_instance {
Subroutine _build_instance: called CC=1 SCAR=0.0
151 2 my ($self, $response) = @_;
152 return Twilio::Rest::Conversations::V1::UserInstance->new($self->{version},
153 2 $response->get_content, $self->{solution}{sid});
154 }
155  
156 4 ▶sub user_conversations {
Subroutine user_conversations: called CC=2 SCAR=6.9
157 4 my ($self, $conversation_sid) = @_;
158 4 require Twilio::Rest::Conversations::V1::User::UserConversation;
159 my $list = Twilio::Rest::Conversations::V1::User::UserConversationList->new($self->{version},
160 4 $self->{solution}{sid});
161 4 ▶ return defined $conversation_sid ? $list->get_context($conversation_sid) : $list;
Branch: 1 branch
BranchTrueFalseTotal
defined $conversation_sid ? : 3 1 4
162 }
163  
164 package Twilio::Rest::Conversations::V1::UserInstance;
165  
166 2 ▶use parent 'Twilio::InstanceResource';
Subroutine BEGIN: called CC=1 SCAR=0.0
167  
168 2 ▶use Twilio::Deserialize;
Subroutine BEGIN: called CC=1 SCAR=0.0
169  
170 4 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
171 4 my ($class, $version, $payload, $sid) = @_;
172 4 my $self = $class->SUPER::new($version, $payload);
173 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
174 4 return $self;
175 }
176  
177 0 ▶sub delete {
Subroutine delete: not called CC=1 SCAR=6.9
178 0 my ($self, @arguments) = @_;
179 0 return $self->_context->delete(@arguments);
180 }
181  
182 0 ▶sub fetch {
Subroutine fetch: not called CC=1 SCAR=6.9
183 0 my ($self, @arguments) = @_;
184 0 return $self->_context->fetch(@arguments);
185 }
186  
187 0 ▶sub update {
Subroutine update: not called CC=1 SCAR=6.9
188 0 my ($self, @arguments) = @_;
189 0 return $self->_context->update(@arguments);
190 }
191  
192 0 ▶sub user_conversations {
Subroutine user_conversations: not called CC=1 SCAR=6.9
193 0 my ($self, @arguments) = @_;
194 0 return $self->_context->user_conversations(@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::UserContext->new($self->{version},
200 0 $self->{solution}{sid});
201 }
202  
203 4 ▶sub account_sid { return $_[0]{properties}{account_sid} }
Subroutine account_sid: called CC=1 SCAR=0.0
204 4 ▶sub attributes { return $_[0]{properties}{attributes} }
Subroutine attributes: called CC=1 SCAR=0.0
205 4 ▶sub chat_service_sid { return $_[0]{properties}{chat_service_sid} }
Subroutine chat_service_sid: called CC=1 SCAR=0.0
206 4 ▶sub date_created { return Twilio::Deserialize::date_time($_[0]{properties}{date_created}) }
Subroutine date_created: called CC=1 SCAR=0.0
207 4 ▶sub date_updated { return Twilio::Deserialize::date_time($_[0]{properties}{date_updated}) }
Subroutine date_updated: called CC=1 SCAR=0.0
208 4 ▶sub friendly_name { return $_[0]{properties}{friendly_name} }
Subroutine friendly_name: called CC=1 SCAR=0.0
209 4 ▶sub identity { return $_[0]{properties}{identity} }
Subroutine identity: called CC=1 SCAR=0.0
210 4 ▶sub is_notifiable { return $_[0]{properties}{is_notifiable} }
Subroutine is_notifiable: called CC=1 SCAR=0.0
211 4 ▶sub is_online { return $_[0]{properties}{is_online} }
Subroutine is_online: called CC=1 SCAR=0.0
212 4 ▶sub links { return $_[0]{properties}{links} }
Subroutine links: called CC=1 SCAR=0.0
213 4 ▶sub role_sid { return $_[0]{properties}{role_sid} }
Subroutine role_sid: called CC=1 SCAR=0.0
214 4 ▶sub sid { return $_[0]{properties}{sid} }
Subroutine sid: 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/Conversations/V1/Service/User.pm ↑ Summary Twilio/Rest/Chat/V2/Service/User.pm »