Twilio/Rest/Chat/V1/Credential.pm

filter: Statementstmt 84.2% 80 / 95 Branchbran n/a Conditioncond 55.5% 5 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 81.0% 30 / 37 Podpod n/a totaltotal 78.7% 115 / 146 CC 5 SCAR 3.1
CC
5
Cov
82%
create
2.0
page
2.0
update
2.0
CRAP 1.4
« Twilio/Rest/Sync/V1/Service/SyncStream.pm ↑ Summary Twilio/Rest/Chat/V2/Credential.pm »
1 # Generated by tools/generate.pl from Twilio's OpenAPI specs. Do not edit this file.
2 package Twilio::Rest::Chat::V1::Credential;
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::V1::CredentialList;
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 5 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
16 5 my ($class, $version) = @_;
17 5 my $self = $class->SUPER::new($version);
18 5 $self->{solution} = {};
19 5 $self->{uri} = '/Credentials';
20 5 return $self;
21 }
22  
23 1 ▶sub create {
Subroutine create: called CC=2 SCAR=7.0
24 1 my ($self, $type, $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 Type => $type,
29 ApiKey => $options->{api_key},
30 Certificate => $options->{certificate},
31 FriendlyName => $options->{friendly_name},
32 PrivateKey => $options->{private_key},
33 Sandbox => Twilio::Serialize::boolean_to_string($options->{sandbox}),
34 Secret => $options->{secret},
35 1 };
36  
37 my $response =
38 1 $self->{version}->handle_request('POST', $self->{uri}, 'create', { data => $data });
39 1 return Twilio::Rest::Chat::V1::CredentialInstance->new($self->{version}, $response->get_content);
40 }
41  
42 0 ▶sub read {
Subroutine read: not called CC=1 SCAR=6.9
43 0 my ($self, @arguments) = @_;
44 0 return $self->read_records(@arguments);
45 }
46  
47 0 ▶sub stream {
Subroutine stream: not called CC=1 SCAR=6.9
48 0 my ($self, @arguments) = @_;
49 0 return $self->stream_records(@arguments);
50 }
51  
52 1 ▶sub page {
Subroutine page: called CC=2 SCAR=7.0
53 1 my ($self, $options, $page_size, $page_token, $page_number) = @_;
54 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
55  
56 1 my $params = {
57 PageToken => $page_token,
58 Page => $page_number,
59 PageSize => $page_size,
60 };
61  
62 1 my $response = $self->{version}->page('GET', $self->{uri}, { params => $params });
63 1 return $self->_build_page($response);
64 }
65  
66 0 ▶sub get_page {
Subroutine get_page: not called CC=1 SCAR=6.9
67 0 my ($self, $target_url) = @_;
68 0 my $client = $self->{version}->get_domain->get_client;
69 0 return $self->_build_page($client->request('GET', $target_url));
70 }
71  
72 1 ▶sub _build_page {
Subroutine _build_page: called CC=1 SCAR=0.0
73 1 my ($self, $response) = @_;
74 return Twilio::Rest::Chat::V1::CredentialPage->new($self->{version}, $response,
75 1 $self->{solution});
76 }
77  
78 3 ▶sub get_context {
Subroutine get_context: called CC=1 SCAR=0.0
79 3 my ($self, $sid) = @_;
80 3 return Twilio::Rest::Chat::V1::CredentialContext->new($self->{version}, $sid);
81 }
82  
83 package Twilio::Rest::Chat::V1::CredentialPage;
84  
85 2 ▶use parent 'Twilio::Page';
Subroutine BEGIN: called CC=1 SCAR=0.0
86  
87 1 ▶sub records_key { return 'credentials' }
Subroutine records_key: called CC=1 SCAR=0.0
88  
89 1 ▶sub build_instance {
Subroutine build_instance: called CC=1 SCAR=0.0
90 1 my ($self, $payload) = @_;
91 1 return Twilio::Rest::Chat::V1::CredentialInstance->new($self->{version}, $payload);
92 }
93  
94 package Twilio::Rest::Chat::V1::CredentialContext;
95  
96 2 ▶use parent 'Twilio::InstanceContext';
Subroutine BEGIN: called CC=1 SCAR=0.0
97  
98 2 ▶use Twilio::Serialize;
Subroutine BEGIN: called CC=1 SCAR=0.0
99  
100 3 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
101 3 my ($class, $version, $sid) = @_;
102 3 my $self = $class->SUPER::new($version);
103 3 $self->{solution} = { sid => $sid };
104 3 $self->{uri} = join q{}, '/Credentials/', Twilio::Serialize::path_segment($sid);
105 3 return $self;
106 }
107  
108 1 ▶sub delete {
Subroutine delete: called CC=1 SCAR=0.0
109 1 my ($self) = @_;
110 1 $self->{version}->handle_request('DELETE', $self->{uri}, 'delete');
111 1 return 1;
112 }
113  
114 1 ▶sub fetch {
Subroutine fetch: called CC=1 SCAR=0.0
115 1 my ($self) = @_;
116  
117 1 my $response = $self->{version}->handle_request('GET', $self->{uri}, 'fetch');
118 1 return $self->_build_instance($response);
119 }
120  
121 1 ▶sub update {
Subroutine update: called CC=2 SCAR=7.0
122 1 my ($self, $options) = @_;
123 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
124  
125 my $data = {
126 ApiKey => $options->{api_key},
127 Certificate => $options->{certificate},
128 FriendlyName => $options->{friendly_name},
129 PrivateKey => $options->{private_key},
130 Sandbox => Twilio::Serialize::boolean_to_string($options->{sandbox}),
131 Secret => $options->{secret},
132 1 };
133  
134 my $response =
135 1 $self->{version}->handle_request('POST', $self->{uri}, 'update', { data => $data });
136 1 return $self->_build_instance($response);
137 }
138  
139 2 ▶sub _build_instance {
Subroutine _build_instance: called CC=1 SCAR=0.0
140 2 my ($self, $response) = @_;
141 return Twilio::Rest::Chat::V1::CredentialInstance->new($self->{version}, $response->get_content,
142 2 $self->{solution}{sid});
143 }
144  
145 package Twilio::Rest::Chat::V1::CredentialInstance;
146  
147 2 ▶use parent 'Twilio::InstanceResource';
Subroutine BEGIN: called CC=1 SCAR=0.0
148  
149 2 ▶use Twilio::Deserialize;
Subroutine BEGIN: called CC=1 SCAR=0.0
150  
151 4 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
152 4 my ($class, $version, $payload, $sid) = @_;
153 4 my $self = $class->SUPER::new($version, $payload);
154 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
155 4 return $self;
156 }
157  
158 0 ▶sub delete {
Subroutine delete: not called CC=1 SCAR=6.9
159 0 my ($self, @arguments) = @_;
160 0 return $self->_context->delete(@arguments);
161 }
162  
163 0 ▶sub fetch {
Subroutine fetch: not called CC=1 SCAR=6.9
164 0 my ($self, @arguments) = @_;
165 0 return $self->_context->fetch(@arguments);
166 }
167  
168 0 ▶sub update {
Subroutine update: not called CC=1 SCAR=6.9
169 0 my ($self, @arguments) = @_;
170 0 return $self->_context->update(@arguments);
171 }
172  
173 0 ▶sub _context {
Subroutine _context: not called CC=1 SCAR=6.9
174 0 my ($self) = @_;
175 0 return Twilio::Rest::Chat::V1::CredentialContext->new($self->{version}, $self->{solution}{sid});
176 }
177  
178 4 ▶sub account_sid { return $_[0]{properties}{account_sid} }
Subroutine account_sid: called CC=1 SCAR=0.0
179 4 ▶sub date_created { return Twilio::Deserialize::date_time($_[0]{properties}{date_created}) }
Subroutine date_created: called CC=1 SCAR=0.0
180 4 ▶sub date_updated { return Twilio::Deserialize::date_time($_[0]{properties}{date_updated}) }
Subroutine date_updated: called CC=1 SCAR=0.0
181 4 ▶sub friendly_name { return $_[0]{properties}{friendly_name} }
Subroutine friendly_name: called CC=1 SCAR=0.0
182 4 ▶sub sandbox { return $_[0]{properties}{sandbox} }
Subroutine sandbox: called CC=1 SCAR=0.0
183 4 ▶sub sid { return $_[0]{properties}{sid} }
Subroutine sid: called CC=1 SCAR=0.0
184 4 ▶sub type { return $_[0]{properties}{type} }
Subroutine type: called CC=1 SCAR=0.0
185 4 ▶sub url { return $_[0]{properties}{url} }
Subroutine url: called CC=1 SCAR=0.0
186  
187 2 1;
188  
189 __END__
« Twilio/Rest/Sync/V1/Service/SyncStream.pm ↑ Summary Twilio/Rest/Chat/V2/Credential.pm »